-
Notifications
You must be signed in to change notification settings - Fork 3
Pluto 1382 change tools configs location #59
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
Changes from all commits
09f2b7d
32902e5
08979c7
0c06807
3735b88
7c209a5
e0b95d2
6a1ed05
508e333
e0a09c4
ed8f3b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,5 @@ go.work.sum | |
.idea/ | ||
.vscode/ | ||
|
||
cli-v2 | ||
# Codacy CLI | ||
cli-v2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,55 @@ | ||
package tools | ||
|
||
import ( | ||
"codacy/cli-v2/config" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
// RunPmd executes PMD static code analyzer with the specified options | ||
// | ||
// Parameters: | ||
// - repositoryToAnalyseDirectory: The root directory of the repository to analyze | ||
// - pmdBinary: Path to the PMD executable | ||
// - pathsToCheck: List of specific paths to analyze, if empty analyzes whole repository | ||
// - outputFile: Path where analysis results should be written | ||
// - outputFormat: Format for the output (e.g. "sarif") | ||
// - rulesetFile: Path to custom ruleset XML file, if empty uses default ruleset | ||
// | ||
// Returns: | ||
// - error: nil if analysis succeeds or violations found, error otherwise | ||
func RunPmd(repositoryToAnalyseDirectory string, pmdBinary string, pathsToCheck []string, outputFile string, outputFormat string, rulesetFile string) error { | ||
cmdArgs := []string{"pmd"} | ||
cmd := exec.Command(pmdBinary, "pmd") | ||
Check failure on line 24 in tools/pmdRunner.go
|
||
|
||
// Add config file from tools-configs directory if not specified | ||
if rulesetFile == "" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that we pass always Meaning, instead of deciding this here, assuming that we were passing some kind of default, is to generate a file with the defaults as needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not always, in test I use a specific file and In this case it's ok. Generally, If in future we want to be able to pass smth like |
||
configFile := filepath.Join(config.Config.ToolsConfigDirectory(), "pmd-ruleset.xml") | ||
cmd.Args = append(cmd.Args, "-R", configFile) | ||
} else { | ||
cmd.Args = append(cmd.Args, "-R", rulesetFile) | ||
} | ||
|
||
// Add source directories (comma-separated list for PMD) | ||
if len(pathsToCheck) > 0 { | ||
dirArg := strings.Join(pathsToCheck, ",") | ||
cmdArgs = append(cmdArgs, "-d", dirArg) | ||
cmd.Args = append(cmd.Args, "-d", dirArg) | ||
} else { | ||
// Fall back to whole repo if no specific paths given | ||
cmdArgs = append(cmdArgs, "-d", repositoryToAnalyseDirectory) | ||
} | ||
|
||
// Add ruleset | ||
if rulesetFile != "" { | ||
cmdArgs = append(cmdArgs, "-R", rulesetFile) | ||
cmd.Args = append(cmd.Args, "-d", repositoryToAnalyseDirectory) | ||
} | ||
|
||
// Format | ||
if outputFormat != "" { | ||
cmdArgs = append(cmdArgs, "-f", outputFormat) | ||
cmd.Args = append(cmd.Args, "-f", outputFormat) | ||
} | ||
|
||
// Output file | ||
if outputFile != "" { | ||
cmdArgs = append(cmdArgs, "-r", outputFile) | ||
cmd.Args = append(cmd.Args, "-r", outputFile) | ||
} | ||
|
||
cmd := exec.Command(pmdBinary, cmdArgs...) | ||
|
||
cmd.Dir = repositoryToAnalyseDirectory | ||
cmd.Stderr = os.Stderr | ||
cmd.Stdout = os.Stdout | ||
|
Uh oh!
There was an error while loading. Please reload this page.