From de26f6151d26f1af9c08b23820273e4a6a6079ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9lio=20Rocha?= Date: Mon, 11 Nov 2024 10:25:25 +0000 Subject: [PATCH 1/2] set --max-warnings to -1 in eslint to force files all files being listed --- tools/eslintRunner.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/eslintRunner.go b/tools/eslintRunner.go index 48d42d0..e1806a5 100644 --- a/tools/eslintRunner.go +++ b/tools/eslintRunner.go @@ -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...) From 9aa8fa4de216540a37abc186650c18e03b678225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9lio=20Rocha?= Date: Tue, 26 Nov 2024 17:13:53 +0000 Subject: [PATCH 2/2] support yml extension on the config file --- README.md | 10 +++++----- config/config.go | 10 +++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c0dc7f5..3894b7a 100644 --- a/README.md +++ b/README.md @@ -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: - node@22.2.0 @@ -66,7 +66,7 @@ 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 @@ -74,13 +74,13 @@ codacy-cli-v2 install 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 @@ -88,7 +88,7 @@ codacy-cli-v2 analyze -t eslint -o eslint.sarif 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 diff --git a/config/config.go b/config/config.go index 0ccec64..09e1381 100644 --- a/config/config.go +++ b/config/config.go @@ -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() {