Skip to content

Commit

Permalink
Merge pull request #24 from codacy/set-max-warnings-to-negative
Browse files Browse the repository at this point in the history
Set max warnings to negative and support yml extension
  • Loading branch information
heliocodacy authored Dec 3, 2024
2 parents 18f607d + 9aa8fa4 commit 90f7e15
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The `codacy-cli-v2` is a command-line tool for Codacy that supports analyzing co

### Important Concepts

- **`.codacy/.codacy.yaml`**: Configuration file to specify `node` and `eslint` versions for the CLI.
- **`.codacy/codacy.yaml`**: Configuration file to specify `node` and `eslint` versions for the CLI.
```yaml
runtimes:
- [email protected]
Expand Down Expand Up @@ -66,29 +66,29 @@ alias codacy-cli-v2="bash <(curl -Ls https://raw.githubusercontent.com/codacy/co
Before running the analysis, install the specified tools:

```bash
codacy-cli-v2 install
codacy-cli install
```

### Run Analysis

To run ESLint and output the results to the terminal:

```bash
codacy-cli-v2 analyze --tool eslint
codacy-cli analyze --tool eslint
```

To store the results as SARIF in a file:

```bash
codacy-cli-v2 analyze -t eslint -o eslint.sarif
codacy-cli analyze -t eslint -o eslint.sarif
```

## Upload Results

To upload a SARIF file to Codacy:

```bash
codacy-cli-v2 upload -s path/to/your.sarif -c your-commit-uuid -t your-project-token
codacy-cli upload -s path/to/your.sarif -c your-commit-uuid -t your-project-token
```

### Example Repository
Expand Down
10 changes: 9 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,15 @@ func (c *ConfigType) initCodacyDirs() {
if err != nil {
log.Fatal(err)
}
c.projectConfigFile = filepath.Join(c.localCodacyDirectory, "codacy.yaml")

yamlPath := filepath.Join(c.localCodacyDirectory, "codacy.yaml")
ymlPath := filepath.Join(c.localCodacyDirectory, "codacy.yml")

if _, err := os.Stat(ymlPath); err == nil {
c.projectConfigFile = ymlPath
} else {
c.projectConfigFile = yamlPath
}
}

func Init() {
Expand Down
3 changes: 2 additions & 1 deletion tools/eslintRunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ func RunEslint(repositoryToAnalyseDirectory string, eslintInstallationDirectory
}
if outputFile != "" {
//When writing to file, we write is SARIF
cmd.Args = append(cmd.Args, "-f", "@microsoft/eslint-formatter-sarif", "-o", outputFile)
// Add --max-warnings -1 to include files with no issues in output
cmd.Args = append(cmd.Args, "-f", "@microsoft/eslint-formatter-sarif", "--max-warnings", "-1", "-o", outputFile)
}
if len(pathsToCheck) > 0 {
cmd.Args = append(cmd.Args, pathsToCheck...)
Expand Down

0 comments on commit 90f7e15

Please sign in to comment.