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

🐛 fail early w/o --rules on non-Java apps #308

Merged
merged 1 commit into from
Aug 6, 2024
Merged
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
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 @@ -1269,7 +1278,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 @@ -1382,13 +1390,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
Loading