func()

in internal/core/incremental_analysis.go [159:209]


func (r *defaultAnalysisRunner) RunFunc(hash string, ctx context.Context, c corescan.Context) (bool, int) {
	e := git.CheckoutAndUpdateSubmodule(c.RepositoryRoot(), hash, true, c.LogDir())
	if e != nil {
		log.Fatalf("Cannot checkout commit %s: %v", hash, e)
	}

	log.Infof("Analysing %s", hash)

	// for CLI, we use only bootstrap from this effective yaml
	// all other fields are used from the one (effective aswell) obtained at the start
	localQodanaYamlFullPath := qdyaml.GetLocalNotEffectiveQodanaYamlFullPath(
		c.ProjectDir(),
		c.CustomLocalQodanaYamlPath(),
	)
	effectiveConfigDir, cleanup, err := utils.CreateTempDir("qd-effective-config-")
	if err != nil {
		log.Fatalf("Failed to create Qodana effective config directory: %v", err)
	}
	defer cleanup()

	effectiveConfigFiles, err := effectiveconfig.CreateEffectiveConfigFiles(
		localQodanaYamlFullPath,
		c.GlobalConfigurationsDir(),
		c.GlobalConfigurationId(),
		c.Prod().JbrJava(),
		effectiveConfigDir,
		c.LogDir(),
	)
	if err != nil {
		log.Fatalf("Failed to load Qodana configuration during analysis of commit %s: %v", hash, err)
	}

	// if local qodana yaml doesn't exist on revision, for bootstrap fallback to the one constructed at the start
	var bootstrap string
	if c.LocalQodanaYamlExists() {
		yaml := qdyaml.LoadQodanaYamlByFullPath(effectiveConfigFiles.EffectiveQodanaYamlPath)
		bootstrap = yaml.Bootstrap
	} else {
		bootstrap = c.QodanaYamlConfig().Bootstrap
	}
	// TODO: mention that bootstrap should be relative to the project path
	utils.Bootstrap(bootstrap, c.ProjectDir())

	contextForAnalysis := c.WithEffectiveConfigurationDirOnRevision(effectiveConfigFiles.ConfigDir)
	exitCode := runQodana(ctx, contextForAnalysis)
	if exitCode != 0 && exitCode != 255 {
		log.Errorf("Qodana analysis on %s exited with code %d. Aborting", hash, exitCode)
		return true, exitCode
	}
	return false, exitCode
}