Skip to content

Commit 90f7e15

Browse files
authored
Merge pull request #24 from codacy/set-max-warnings-to-negative
Set max warnings to negative and support yml extension
2 parents 18f607d + 9aa8fa4 commit 90f7e15

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The `codacy-cli-v2` is a command-line tool for Codacy that supports analyzing co
2929

3030
### Important Concepts
3131

32-
- **`.codacy/.codacy.yaml`**: Configuration file to specify `node` and `eslint` versions for the CLI.
32+
- **`.codacy/codacy.yaml`**: Configuration file to specify `node` and `eslint` versions for the CLI.
3333
```yaml
3434
runtimes:
3535
@@ -66,29 +66,29 @@ alias codacy-cli-v2="bash <(curl -Ls https://raw.githubusercontent.com/codacy/co
6666
Before running the analysis, install the specified tools:
6767

6868
```bash
69-
codacy-cli-v2 install
69+
codacy-cli install
7070
```
7171

7272
### Run Analysis
7373

7474
To run ESLint and output the results to the terminal:
7575

7676
```bash
77-
codacy-cli-v2 analyze --tool eslint
77+
codacy-cli analyze --tool eslint
7878
```
7979

8080
To store the results as SARIF in a file:
8181

8282
```bash
83-
codacy-cli-v2 analyze -t eslint -o eslint.sarif
83+
codacy-cli analyze -t eslint -o eslint.sarif
8484
```
8585

8686
## Upload Results
8787

8888
To upload a SARIF file to Codacy:
8989

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

9494
### Example Repository

config/config.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,15 @@ func (c *ConfigType) initCodacyDirs() {
8383
if err != nil {
8484
log.Fatal(err)
8585
}
86-
c.projectConfigFile = filepath.Join(c.localCodacyDirectory, "codacy.yaml")
86+
87+
yamlPath := filepath.Join(c.localCodacyDirectory, "codacy.yaml")
88+
ymlPath := filepath.Join(c.localCodacyDirectory, "codacy.yml")
89+
90+
if _, err := os.Stat(ymlPath); err == nil {
91+
c.projectConfigFile = ymlPath
92+
} else {
93+
c.projectConfigFile = yamlPath
94+
}
8795
}
8896

8997
func Init() {

tools/eslintRunner.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ func RunEslint(repositoryToAnalyseDirectory string, eslintInstallationDirectory
1919
}
2020
if outputFile != "" {
2121
//When writing to file, we write is SARIF
22-
cmd.Args = append(cmd.Args, "-f", "@microsoft/eslint-formatter-sarif", "-o", outputFile)
22+
// Add --max-warnings -1 to include files with no issues in output
23+
cmd.Args = append(cmd.Args, "-f", "@microsoft/eslint-formatter-sarif", "--max-warnings", "-1", "-o", outputFile)
2324
}
2425
if len(pathsToCheck) > 0 {
2526
cmd.Args = append(cmd.Args, pathsToCheck...)

0 commit comments

Comments
 (0)