Skip to content

Commit

Permalink
🐛 Fix bootstrap for the renamed configurations (QD-9009)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiulpin committed Jun 7, 2024
1 parent 26d0b32 commit dc25f94
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func newRootCommand() *cobra.Command {
rootCmd := &cobra.Command{
Use: "qodana",
Short: "Run Qodana CLI",
Long: platform.InfoString(platform.Version), // TODO : return to core
Long: platform.InfoString(platform.Version),
Version: platform.Version,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
logLevel, err := log.ParseLevel(viper.GetString("log-level"))
Expand Down
1 change: 0 additions & 1 deletion core/ide.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ func prepareLocalIdeSettings(opts *QodanaOptions) {
opts.LogDirPath(),
opts.ConfDirPath(),
)
platform.Config = platform.GetQodanaYamlOrDefault(opts.ProjectDir) // TODO: Burry it!
writeProperties(opts)

if platform.IsContainer() {
Expand Down
2 changes: 1 addition & 1 deletion core/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func getCustomPluginPaths() string {

// writeProperties writes the given key=value `props` to file `f` (sets the environment variable)
func writeProperties(opts *QodanaOptions) { // opts.confDirPath(Prod.Version) opts.vmOptionsPath(Prod.Version)
properties := GetProperties(opts, platform.Config.Properties, platform.Config.DotNet, getPluginIds(platform.Config.Plugins))
properties := GetProperties(opts, opts.QdConfig.Properties, opts.QdConfig.DotNet, getPluginIds(opts.QdConfig.Plugins))
err := os.WriteFile(opts.vmOptionsPath(), []byte(strings.Join(properties, "\n")), 0o644)
if err != nil {
log.Fatal(err)
Expand Down
6 changes: 3 additions & 3 deletions core/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ func RunAnalysis(ctx context.Context, options *QodanaOptions) int {
scenario := options.determineRunScenario(startHash != "")
// this way of running needs to do bootstrap twice on different commits and will do it internally
if scenario != runScenarioScoped && options.Ide != "" {
platform.Bootstrap(platform.Config.Bootstrap, options.ProjectDir)
installPlugins(platform.Config.Plugins)
platform.Bootstrap(options.QdConfig.Bootstrap, options.ProjectDir)
installPlugins(options.QdConfig.Plugins)
}
switch scenario {
case runScenarioFullHistory:
Expand Down Expand Up @@ -327,7 +327,7 @@ func runScopeScript(ctx context.Context, options *QodanaOptions, startHash strin
configAtHash, e := platform.GetQodanaYaml(options.ProjectDir)
if e != nil {
log.Warnf("Could not read qodana yaml at %s: %v. Using last known config", hash, e)
configAtHash = platform.Config
configAtHash = options.QdConfig
}
platform.Bootstrap(configAtHash.Bootstrap, options.ProjectDir)
installPlugins(configAtHash.Plugins)
Expand Down
23 changes: 12 additions & 11 deletions platform/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type QodanaOptions struct {
AnalysisTimeoutMs int
AnalysisTimeoutExitCode int
JvmDebugPort int
QdConfig QodanaYaml
}

func (o *QodanaOptions) LogOptions() {
Expand Down Expand Up @@ -130,13 +131,13 @@ func (o *QodanaOptions) GetToken() string {
}

func (o *QodanaOptions) FetchAnalyzerSettings() {
qodanaYamlPath := FindQodanaYaml(o.ProjectDir)
if o.ConfigName != "" {
qodanaYamlPath = o.ConfigName
}
o.QdConfig = *LoadQodanaYaml(o.ProjectDir, qodanaYamlPath)
if o.Linter == "" && o.Ide == "" {
qodanaYamlPath := FindQodanaYaml(o.ProjectDir)
if o.ConfigName != "" {
qodanaYamlPath = o.ConfigName
}
qodanaYaml := LoadQodanaYaml(o.ProjectDir, qodanaYamlPath)
if qodanaYaml.Linter == "" && qodanaYaml.Ide == "" {
if o.QdConfig.Linter == "" && o.QdConfig.Ide == "" {
WarningMessage(
"No valid `linter:` or `ide:` field found in %s. Have you run %s? Running that for you...",
PrimaryBold(qodanaYamlPath),
Expand All @@ -150,17 +151,17 @@ func (o *QodanaOptions) FetchAnalyzerSettings() {
}
EmptyMessage()
} else {
if qodanaYaml.Linter != "" && qodanaYaml.Ide != "" {
if o.QdConfig.Linter != "" && o.QdConfig.Ide != "" {
ErrorMessage("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,
o.QdConfig.Linter,
o.QdConfig.Ide,
qodanaYamlPath)
os.Exit(1)
}
o.Linter = qodanaYaml.Linter
o.Linter = o.QdConfig.Linter
}
if o.Ide == "" {
o.Ide = qodanaYaml.Ide
o.Ide = o.QdConfig.Ide
}
}
o.ResultsDir = o.resultsDirPath()
Expand Down
2 changes: 0 additions & 2 deletions platform/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import (
"strings"
)

var Config QodanaYaml // TODO : burry the value somewhere

// GetQodanaYamlPath returns the path to qodana.yaml or qodana.yml
func GetQodanaYamlPath(project string) (string, error) {
qodanaYamlPath := filepath.Join(project, "qodana.yaml")
Expand Down

0 comments on commit dc25f94

Please sign in to comment.