Skip to content

codacy_cli_analyze does not honor usesConfigurationFile — regenerates flat config and reports false positives (ESLint) #84

Closed as not planned

Description

@echavez-techholding

Summary

When a tool is configured to "use the repository configuration file"
(usesConfigurationFile: true), the MCP's codacy_cli_analyze still
regenerates the Codacy pattern-catalog config and analyzes against it,
ignoring the repo's config file. This produces false positives.

Environment

  • OS: macOS
  • IDE: VS Code + Copilot (Agent mode)
  • Tool affected: ESLint 8.57.0
  • Repo config file: .eslintrc.json (on default branch, main)
  • Codacy UI: ESLint → "Use configuration file" is ENABLED
  • API confirms: codacy_list_repository_tools returns ESLint with
    "hasConfigurationFile": true, "usesConfigurationFile": true

Expected

The CLI should skip generating .codacy/tools-configs/eslint.config.mjs
and run ESLint against .eslintrc.json.

Actual

codacy_cli_analyze regenerates eslint.config.mjs from the pattern
catalog (with no-undef: ["error"], no Mocha/WebdriverIO globals) and
reports no-undef false positives for describe, it, before,
driver, etc. — errors that do not exist under the repo's .eslintrc.json.

Root cause

Running the CLI directly reproduces both behaviors:

  • WITHOUT init flags (how the MCP invokes it):
    codacy-cli analyze --tool eslint <file>
    → prints "ESLint configuration created based on Codacy settings"
    → regenerates eslint.config.mjs → reports no-undef false positives

  • WITH init flags:
    codacy-cli analyze --tool eslint --api-token $TOKEN --provider gh --organization <org> --repository <repo> <file>
    → prints "Skipping config generation for ESLint - configured to use
    repo's config file"
    → uses .eslintrc.json → 0 false positives

In src/cli/MacCodacyCli.ts, analyze() calls:
${cli} analyze ${file} --format sarif (with only { tool })
It does NOT forward --api-token / --provider / --organization / --repository, so codacy-cli analyze cannot fetch usesConfigurationFile
and falls back to regenerating the flat config.

Suggested fix

Have analyze() forward the same init params that initialize() already
builds (api-token, provider, organization, repository) to the
analyze command, so the CLI can honor usesConfigurationFile.

Note

init alone is not sufficient — analyze re-evaluates
usesConfigurationFile from its own flags and regenerates the config
when they're absent, even after a correct init.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions