in internal/platform/run.go [43:166]
func RunThirdPartyLinterAnalysis(
cliOptions platformcmd.CliOptions,
linter ThirdPartyLinter,
linterInfo thirdpartyscan.LinterInfo,
) (int, error) {
qdenv.InitializeQodanaGlobalEnv(cliOptions)
var err error
commonCtx := commoncontext.Compute3rdParty(
linterInfo.LinterName,
linterInfo.IsEap,
cliOptions.CacheDir,
cliOptions.ResultsDir,
cliOptions.ReportDir,
qdenv.GetQodanaGlobalEnv(qdenv.QodanaToken),
cliOptions.ClearCache,
cliOptions.ProjectDir,
cliOptions.RepositoryRoot,
)
commonCtx, err = correctInitArgsForThirdParty(commonCtx)
if err != nil {
msg.ErrorMessage(err.Error())
return 1, err
}
resultDir := commonCtx.ResultsDir
defer changeResultDirPermissionsInContainer(resultDir)
thirdPartyCloudData := checkLinterLicense(commonCtx)
printLinterLicense(thirdPartyCloudData.LicensePlan, linterInfo)
printQodanaLogo(commonCtx.LogDir(), commonCtx.CacheDir, linterInfo)
mountInfo := extractUtils(linter, commonCtx.CacheDir)
localQodanaYamlFullPath := qdyaml.GetLocalNotEffectiveQodanaYamlFullPath(
commonCtx.ProjectDir,
cliOptions.ConfigName,
)
effectiveDir, cleanup, err := utils.CreateTempDir("qodana-effective-config")
if err != nil {
return 1, fmt.Errorf("failed to create qodana effective configuration dir %v", err)
}
defer cleanup()
qodanaConfigEffectiveFiles, err := effectiveconfig.CreateEffectiveConfigFiles(
localQodanaYamlFullPath,
cliOptions.GlobalConfigurationsDir,
cliOptions.GlobalConfigurationId,
mountInfo.JavaPath,
effectiveDir,
commonCtx.LogDir(),
)
if err != nil {
log.Fatalf("Failed to load Qodana configuration %s", err)
}
qodanaYamlConfig := thirdpartyscan.QodanaYamlConfig{}
if qodanaConfigEffectiveFiles.EffectiveQodanaYamlPath != "" {
yaml := qdyaml.LoadQodanaYamlByFullPath(qodanaConfigEffectiveFiles.EffectiveQodanaYamlPath)
qodanaYamlConfig = thirdpartyscan.YamlConfig(yaml)
}
context := thirdpartyscan.ComputeContext(
cliOptions,
commonCtx,
linterInfo,
mountInfo,
thirdPartyCloudData,
qodanaYamlConfig,
)
LogContext(&context)
events := make([]tooling.FuserEvent, 0)
eventsCh := createFuserEventChannel(&events)
projectIdHash := thirdPartyCloudData.ProjectIdHash
defer func() {
logProjectClose(eventsCh, linterInfo, projectIdHash)
sendFuserEvents(eventsCh, &events, context, GetDeviceIdSalt()[0])
}()
logOs(eventsCh, linterInfo, projectIdHash)
logProjectOpen(eventsCh, linterInfo, projectIdHash)
if err = linter.RunAnalysis(context); err != nil {
msg.ErrorMessage(err.Error())
return 1, err
}
log.Debugf("Java executable path: %s", mountInfo.JavaPath)
thresholds := getFailureThresholds(context)
var analysisResult int
if analysisResult, err = computeBaselinePrintResults(context, thresholds); err != nil {
msg.ErrorMessage(err.Error())
return 1, err
}
if qodanaConfigEffectiveFiles.EffectiveQodanaYamlPath != "" {
err = copyQodanaYamlToLogDir(qodanaConfigEffectiveFiles.EffectiveQodanaYamlPath, context.LogDir())
if err != nil {
msg.ErrorMessage(err.Error())
return 1, err
}
}
if err = convertReportToCloudFormat(context); err != nil {
msg.ErrorMessage(err.Error())
return 1, err
}
sendReportToQodanaServer(context)
newReportUrl := cloud.GetReportUrl(context.ResultsDir())
ProcessSarif(
filepath.Join(context.ResultsDir(), commoncontext.QodanaSarifName),
context.AnalysisId(),
newReportUrl,
false,
context.GenerateCodeClimateReport(),
context.SendBitBucketInsights(),
)
err = writeShortSarifReport(context)
if err != nil {
log.Warnf("Problems writing short SARIF report: %v", err)
}
return analysisResult, nil
}