Skip to content

Commit 61c40a2

Browse files
minor fixes
1 parent 9f29a8f commit 61c40a2

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

plugin.go

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,15 @@ func (p Plugin) Exec() error {
422422

423423
args := []string{}
424424

425+
// Additional conditions for args
426+
if len(p.Config.Verbose) >= 1 {
427+
args = append(args, "-X")
428+
}
429+
430+
if len(p.Config.Workspace) >= 1 {
431+
args = append(args, "-Dsonar.projectBaseDir="+p.Config.Workspace)
432+
}
433+
425434
if os.IsNotExist(err) && p.Config.UseSonarConfigFile {
426435
// If the configuration file does not exist, use the default parameters
427436
fmt.Println("Configuration file not found. Using default parameters.")
@@ -472,11 +481,6 @@ func (p Plugin) Exec() error {
472481
}
473482
}
474483

475-
// Additional conditions for args
476-
if len(p.Config.Verbose) >= 1 {
477-
args = append(args, "-X")
478-
}
479-
480484
if !p.Config.UsingProperties {
481485
args = append(args, "-Dsonar.scm.provider=git")
482486
}
@@ -492,9 +496,6 @@ func (p Plugin) Exec() error {
492496
os.Setenv("SONAR_SCANNER_OPTS", newOpts)
493497
}
494498

495-
if len(p.Config.Workspace) >= 1 {
496-
args = append(args, "-Dsonar.projectBaseDir="+p.Config.Workspace)
497-
}
498499
} else if err == nil {
499500
// Configuration file exists, let sonar-scanner use it without additional parameters
500501
fmt.Println("Configuration file found. Using sonar-project.properties.")
@@ -509,15 +510,11 @@ func (p Plugin) Exec() error {
509510
args = append(args, "-Dsonar.login="+p.Config.Token)
510511
}
511512

512-
if len(p.Config.Token) >= 1 && p.Config.UseSonarConfigFileOverride {
513-
fmt.Println("OVERRIDING sonar.login=" + p.Config.Token)
513+
if len(p.Config.Key) >= 1 && p.Config.UseSonarConfigFileOverride {
514+
fmt.Println("OVERRIDING sonar.projectKey=" + p.Config.Key)
514515
args = append(args, "-Dsonar.projectKey="+p.Config.Key)
515516
}
516517

517-
if len(p.Config.Workspace) >= 1 {
518-
args = append(args, "-Dsonar.projectBaseDir="+p.Config.Workspace)
519-
}
520-
521518
} else {
522519
// Error checking the file
523520
return fmt.Errorf("error checking configuration file: %v", err)

0 commit comments

Comments
 (0)