Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ QD-9730 Switch to scoped script for incremental analysis. #427

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/ide.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ func GetIdeArgs(opts *QodanaOptions) []string {
if opts.DiffEnd != "" && opts.Script == "default" {
arguments = append(arguments, "--diff-end", opts.DiffEnd)
}
if opts.ForceDiffMode && opts.Script == "default" {
arguments = append(arguments, "--force-diff-analysis-mode")
if opts.ForceLocalChangesScript && opts.Script == "default" {
arguments = append(arguments, "--force-local-changes-script")
}

if opts.AnalysisId != "" {
Expand Down
20 changes: 7 additions & 13 deletions core/run_scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@

package core

import (
"github.com/JetBrains/qodana-cli/v2024/platform"
log "github.com/sirupsen/logrus"
"strings"
)
import "github.com/JetBrains/qodana-cli/v2024/platform"

const (
runScenarioDefault = "default"
Expand All @@ -32,19 +28,17 @@ const (
type RunScenario = string

func (o *QodanaOptions) determineRunScenario(hasStartHash bool) RunScenario {
isDotNet := Prod.Code == platform.QDNET || strings.Contains(o.Linter, "dotnet")

if o.ForceLocalChangesScript || o.Script == "local-changes" {
platform.WarningMessage("Using local-changes script is deprecated, please switch to other mechanisms of incremental analysis. Further information - https://www.jetbrains.com/help/qodana/analyze-pr.html")
}
switch {
case o.ForceDiffMode && !hasStartHash:
log.Fatal("Cannot run any diff script without --diff-start/--commit")
panic("Unreachable")
case o.FullHistory:
return runScenarioFullHistory
case !hasStartHash:
return runScenarioDefault
case o.ForceDiffMode || isDotNet:
return runScenarioScoped
default:
case o.ForceLocalChangesScript:
return runScenarioLocalChanges
default:
return runScenarioScoped
}
}
6 changes: 3 additions & 3 deletions core/run_scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,18 @@ func TestQodanaOptions_determineRunScenario(t *testing.T) {
hasStartHash: true,
productCode: platform.QDJVM,
},
want: runScenarioLocalChanges,
want: runScenarioScoped,
},
{
name: "forced script",
args: args{
qodanaOptions: &platform.QodanaOptions{
ForceDiffMode: true,
ForceLocalChangesScript: true,
},
hasStartHash: true,
productCode: platform.QDJVM,
},
want: runScenarioScoped,
want: runScenarioLocalChanges,
},
}
for _, tt := range tests {
Expand Down
6 changes: 3 additions & 3 deletions platform/argflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func ComputeFlags(cmd *cobra.Command, options *QodanaOptions) error {

flags.StringVar(&options.DiffStart, "diff-start", "", "Commit to start a diff run from. Only files changed between --diff-start and --diff-end will be analysed.")
flags.StringVar(&options.DiffEnd, "diff-end", "", "Commit to end a diff run on. Only files changed between --diff-start and --diff-end will be analysed.")
flags.BoolVar(&options.ForceDiffMode, "force-diff-analysis-mode", false, "Override the default run-scenario for diff runs to always use the restart-based approach")
flags.BoolVar(&options.ForceLocalChangesScript, "force-local-changes-script", false, "Override the default run-scenario for diff runs to always use the local-changes script")

flags.IntVar(&options.JvmDebugPort, "jvm-debug-port", -1, "Enable JVM remote debug under given port")

Expand All @@ -98,7 +98,7 @@ func ComputeFlags(cmd *cobra.Command, options *QodanaOptions) error {
cmd.MarkFlagsMutuallyExclusive("env", "ide")
}

cmd.MarkFlagsMutuallyExclusive("script", "force-diff-analysis-mode", "full-history")
cmd.MarkFlagsMutuallyExclusive("script", "force-local-changes-script", "full-history")
cmd.MarkFlagsMutuallyExclusive("commit", "script", "diff-start")
cmd.MarkFlagsMutuallyExclusive("profile-name", "profile-path")
cmd.MarkFlagsMutuallyExclusive("apply-fixes", "cleanup")
Expand All @@ -112,7 +112,7 @@ func ComputeFlags(cmd *cobra.Command, options *QodanaOptions) error {
return err
}
err = cmd.Flags().MarkHidden("jvm-debug-port")
err = cmd.Flags().MarkHidden("force-diff-analysis-mode")
err = cmd.Flags().MarkHidden("force-local-changes-script")
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion platform/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type QodanaOptions struct {
Commit string
DiffStart string
DiffEnd string
ForceDiffMode bool
ForceLocalChangesScript bool
AnalysisId string
Env []string
Volumes []string
Expand Down
Loading