@@ -20,6 +20,7 @@ var outputFormat string
2020var sarifPath string
2121var commitUuid string
2222var projectToken string
23+ var pmdRulesetFile string
2324
2425type Sarif struct {
2526 Runs []struct {
@@ -95,6 +96,7 @@ func init() {
9596 analyzeCmd .Flags ().StringVarP (& toolToAnalyze , "tool" , "t" , "" , "Which tool to run analysis with" )
9697 analyzeCmd .Flags ().StringVar (& outputFormat , "format" , "" , "Output format (use 'sarif' for SARIF format)" )
9798 analyzeCmd .Flags ().BoolVar (& autoFix , "fix" , false , "Apply auto fix to your issues when available" )
99+ analyzeCmd .Flags ().StringVar (& pmdRulesetFile , "rulesets" , "" , "Path to PMD ruleset file" )
98100 rootCmd .AddCommand (analyzeCmd )
99101}
100102
@@ -203,6 +205,16 @@ func runTrivyAnalysis(workDirectory string, pathsToCheck []string, outputFile st
203205 }
204206}
205207
208+ func runPmdAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) {
209+ pmd := config .Config .Tools ()["pmd" ]
210+ pmdBinary := pmd .Binaries ["pmd" ]
211+
212+ err := tools .RunPmd (workDirectory , pmdBinary , pathsToCheck , outputFile , outputFormat , pmdRulesetFile )
213+ if err != nil {
214+ log .Fatalf ("Error running PMD: %v" , err )
215+ }
216+ }
217+
206218func runPylintAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) {
207219 pylint := config .Config .Tools ()["pylint" ]
208220
@@ -235,6 +247,8 @@ var analyzeCmd = &cobra.Command{
235247 runEslintAnalysis (workDirectory , args , autoFix , outputFile , outputFormat )
236248 case "trivy" :
237249 runTrivyAnalysis (workDirectory , args , outputFile , outputFormat )
250+ case "pmd" :
251+ runPmdAnalysis (workDirectory , args , outputFile , outputFormat )
238252 case "pylint" :
239253 runPylintAnalysis (workDirectory , args , outputFile , outputFormat )
240254 case "" :
0 commit comments