From 921d1d95d3acf545265dfb6a106100ea7eaecb0a Mon Sep 17 00:00:00 2001 From: "konveyor-ci-bot[bot]" <159171263+konveyor-ci-bot[bot]@users.noreply.github.com> Date: Tue, 6 Aug 2024 14:26:22 -0400 Subject: [PATCH] :bug: fail early w/o --rules on non-Java apps (#308) (#311) Signed-off-by: David Zager Signed-off-by: Cherry Picker Co-authored-by: David Zager --- cmd/analyze.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/analyze.go b/cmd/analyze.go index ac18728..e74bb0d 100644 --- a/cmd/analyze.go +++ b/cmd/analyze.go @@ -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") @@ -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)) @@ -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))