Skip to content

Commit

Permalink
🐛 fail early w/o --rules on non-Java apps (#308) (#311)
Browse files Browse the repository at this point in the history
Signed-off-by: David Zager <[email protected]>
Signed-off-by: Cherry Picker <[email protected]>
Co-authored-by: David Zager <[email protected]>
  • Loading branch information
konveyor-ci-bot[bot] and djzager authored Aug 6, 2024
1 parent 4230b9c commit 921d1d9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions cmd/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@ func NewAnalyzeCmd(log logr.Logger) *cobra.Command {
if len(foundProviders) == 1 && foundProviders[0] == dotnetFrameworkProvider {
return analyzeCmd.analyzeDotnetFramework(cmd.Context())
}

// default rulesets are only java rules
// may want to change this in the future
if len(foundProviders) > 0 && len(analyzeCmd.rules) == 0 {
if _, ok := analyzeCmd.providersMap[javaProvider]; !ok {
return fmt.Errorf("No providers found with default rules. Use --rules option")
}
}

xmlOutputDir, err := analyzeCmd.ConvertXML(cmd.Context())
if err != nil {
log.Error(err, "failed to convert xml rules")
Expand Down Expand Up @@ -1284,7 +1293,6 @@ func (a *analyzeCommand) RunAnalysisOverrideProviderSettings(ctx context.Context
fmt.Sprintf("--context-lines=%d", a.contextLines),
}

a.enableDefaultRulesets = false
if a.enableDefaultRulesets {
args = append(args,
fmt.Sprintf("--rules=%s/", RulesetPath))
Expand Down Expand Up @@ -1397,13 +1405,6 @@ func (a *analyzeCommand) RunAnalysis(ctx context.Context, xmlOutputDir string, v
fmt.Sprintf("--output-file=%s", AnalysisOutputMountPath),
fmt.Sprintf("--context-lines=%d", a.contextLines),
}
// default rulesets are only java rules
// may want to change this in the future
if !a.needsBuiltin {
if _, ok := a.providersMap[javaProvider]; !ok {
a.enableDefaultRulesets = false
}
}
if a.enableDefaultRulesets {
args = append(args,
fmt.Sprintf("--rules=%s/", RulesetPath))
Expand Down

0 comments on commit 921d1d9

Please sign in to comment.