func getAnalyzerFromProject()

in internal/platform/commoncontext/compute.go [212:258]


func getAnalyzerFromProject(
	qodanaCloudToken string,
	projectDir string,
	localNotEffectiveQodanaYamlPathInProject string,
) product.Analyzer {
	qodanaYamlPath := qdyaml.GetLocalNotEffectiveQodanaYamlFullPath(
		projectDir,
		localNotEffectiveQodanaYamlPathInProject,
	)
	qodanaYaml := qdyaml.LoadQodanaYamlByFullPath(qodanaYamlPath)
	if qodanaYaml.Linter == "" && qodanaYaml.Ide == "" && qodanaYaml.Image == "" {
		msg.WarningMessage(
			"No valid `linter:` or `image:` field found in %s. Have you run %s? Running that for you...",
			msg.PrimaryBold(localNotEffectiveQodanaYamlPathInProject),
			msg.PrimaryBold("qodana init"),
		)
		return SelectAnalyzerForPath(projectDir, qodanaCloudToken)
	}
	if qodanaYaml.Ide != "" {
		msg.WarningMessage(
			"`ide:` field in %s is deprecated. Please use `--linter` and `--within-docker=false` instead.",
			qodanaYamlPath,
		)
	}

	if qodanaYaml.Linter != "" && qodanaYaml.Ide != "" {
		log.Fatalf(
			"You have both `linter:` (%s) and `ide:` (%s) fields set in %s. Modify the configuration file to keep one of them",
			qodanaYaml.Linter,
			qodanaYaml.Ide,
			qodanaYamlPath,
		)
		return nil
	}

	if qodanaYaml.Image != "" && qodanaYaml.Ide != "" {
		log.Fatalf(
			"You have both `image:` (%s) and `ide:` (%s) fields set in %s. Modify the configuration file to keep one of them",
			qodanaYaml.Image,
			qodanaYaml.Ide,
			localNotEffectiveQodanaYamlPathInProject,
		)
		return nil
	}

	return guessAnalyzerFromParams(qodanaYaml.Ide, qodanaYaml.Linter, qodanaYaml.Image, qodanaYaml.WithinDocker)
}