Skip to content

Commit

Permalink
🐛 Fix --property option
Browse files Browse the repository at this point in the history
  • Loading branch information
tiulpin committed Apr 10, 2022
1 parent 9e6094f commit 798bd14
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
9 changes: 6 additions & 3 deletions cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var testOptions = &core.QodanaOptions{
SaveReport: true,
ShowReport: true,
Port: 8888,
Property: "foo=bar",
Property: []string{"foo.baz=bar", "foo.bar=baz"},
Script: "default",
FailThreshold: "0",
Changes: true,
Expand Down Expand Up @@ -162,14 +162,14 @@ func TestScanFlags(t *testing.T) {
"--baseline",
"qodana.sarif.json",
"--baseline-include-absent",
"--property",
"foo=bar",
"--fail-threshold",
"0",
"--changes",
"--send-report",
"--analysis-id",
"id",
"--property=foo.baz=bar",
"--property=foo.bar=baz",
}, " ")
actual := strings.Join(core.GetCmdOptions(testOptions), " ")
if expected != actual {
Expand All @@ -178,6 +178,7 @@ func TestScanFlags(t *testing.T) {
}

func TestAllCommands(t *testing.T) {
//goland:noinspection GoBoolExpressions
if _, err := exec.LookPath("docker"); err != nil || (runtime.GOOS == "windows" && isGitHubAction()) {
t.Skip(err)
}
Expand Down Expand Up @@ -218,6 +219,8 @@ func TestAllCommands(t *testing.T) {
"--fail-threshold", "5",
"--print-problems",
"--clear-cache",
"--property",
"idea.log.config.file=info.xml",
})
err = command.Execute()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ But you can always override qodana.yaml options with the following command-line
flags.StringVar(&options.Script, "script", "default", "Override the run scenario")
flags.StringVar(&options.StubProfile, "stub-profile", "", "Absolute path to the fallback profile file. This option is applied in case the profile was not specified using any available options")

flags.StringVar(&options.Property, "property", "", "Set a JVM property to be used while running Qodana using the --property=property.name=value1,value2,...,valueN notation")
flags.StringArrayVar(&options.Property, "property", []string{}, "Set a JVM property to be used while running Qodana using the --property property.name=value1,value2,...,valueN notation")
flags.BoolVarP(&options.SaveReport, "save-report", "s", true, "Generate HTML report")
flags.BoolVar(&options.SendReport, "send-report", false, "Send the inspection report to Qodana Cloud, requires the '--token' option to be specified")

Expand Down
2 changes: 1 addition & 1 deletion core/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type QodanaOptions struct {
SaveReport bool
ShowReport bool
Port int
Property string
Property []string
Script string
FailThreshold string
Changes bool
Expand Down
9 changes: 5 additions & 4 deletions core/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ func ensureDockerInstalled() {
func checkDockerMemory() {
docker := getDockerClient()
goos := runtime.GOOS
if goos != "windows" && goos != "darwin" {
if //goland:noinspection GoBoolExpressions
goos != "windows" && goos != "darwin" {
return
}
info, err := docker.Info(context.Background())
Expand Down Expand Up @@ -188,9 +189,6 @@ func GetCmdOptions(opts *QodanaOptions) []string {
if opts.BaselineIncludeAbsent {
arguments = append(arguments, "--baseline-include-absent")
}
if opts.Property != "" {
arguments = append(arguments, "--property", opts.Property)
}
if opts.FailThreshold != "" {
arguments = append(arguments, "--fail-threshold", opts.FailThreshold)
}
Expand All @@ -203,6 +201,9 @@ func GetCmdOptions(opts *QodanaOptions) []string {
if opts.AnalysisId != "" {
arguments = append(arguments, "--analysis-id", opts.AnalysisId)
}
for _, property := range opts.Property {
arguments = append(arguments, "--property="+property)
}
return arguments
}

Expand Down

0 comments on commit 798bd14

Please sign in to comment.