Skip to main content

Configuring code patterns

note

Organization admins can manage access to this feature

By default, Codacy analyzes your repositories using a subset of the supported analysis tools and code patterns. These defaults are based on current best practices and community feedback, and you can adapt them to your needs as follows:

Configuring tools and code patterns using the Codacy UI

To configure the tools and code patterns for a repository using the Codacy UI:

  1. Open your repository Code patterns page.

    Code patterns page

  2. Enable or disable the tools that Codacy will use to analyze the repository.

    Toggling tools

  3. Select a tool to enable or disable its code patterns. To make it easier to find relevant patterns, use the filters above the pattern list. You can filter by issue category, status, severity level, or display only recommended code patterns.

    To see an explanation of the issues that a pattern detects and how to fix them, click the respective dropdown arrow.

    tip
    • To enable a group of code patterns, use the filter to select the relevant group of patterns and click the checkbox in the header of the patterns list.

    • Codacy displays the tag New for one month next to the name of newly added code patterns.

    Configuring code patterns

  4. Optionally, to take the changes into account immediately, reanalyze the repository manually. Otherwise, Codacy will use the updated configuration when analyzing new commits and pull requests.

Discover code patterns across all tools

To discover code patterns across all tools, click Discover patterns at the top of the Tools list.

Use the input field to search for patterns by name or description. You can also filter by severity level, issue category, recommended or disabled patterns.

You can also expand your search to include patterns from all tools, even if the tool is not enabled for the repository.

Customizing applied coding standards

To apply or edit a repository's coding standards, click Customize in the Following ... section at the top of the Code patterns page.

Customize applied coding standards

Select the coding standards that you want to follow or stop following and click Apply.

Customize applied coding standards

Customizing patterns when following coding standards

Tools and patterns enabled by a coding standard are enforced and cannot be disabled. You can add extra tools and patterns, if these are not enabled by any applied coding standard.

Using tool configuration files

note

Codacy supports configuration files for several static analysis tools to help you streamline your setup.

To use a configuration file for a static analysis tool:

  1. Push the configuration file to the root of the default Codacy branch.

  2. Open the repository Code patterns page, select the tool of interest, and activate the toggle to use a configuration file.

    note
    • Codacy uses the version of the configuration file in the branch being analyzed. For example, if you open a pull request that includes changes to the configuration file, the analysis results take those changes into account.

    • If Codacy analyzes a branch that doesn't include the configuration file, Codacy reverts to using the code patterns configured for the tool before you selected the option Configuration file on the Code patterns page.

    • For performance reasons, when you update pattern settings using a configuration file, Codacy may display outdated messages for issues identified previously by those patterns.

    Using a configuration file

The table below lists the configuration file names that Codacy detects and supports for each tool:

Tool nameLanguagesFiles detectedOther info
AmebaCrystal.ameba.yml
BanditPythonbandit.yml, bandit.yaml, .bandit, bandit.toml, bandit.iniTo solve flagged valid Python "assert" statements, create a bandit.yml on the root of the repository containing: skips: ['B101']
BrakemanRubyconfig/brakeman.yml
CheckstyleJavacheckstyle.xmlSupports configuration file in directories other than root and can search up to 5 directories into the repository.
CodeNarcGroovy.codenarcrc
CredoElixir.credo.exs, config/.credo.exs
dartanalyzerDartanalysis_options.ymlCustomizing static analysis
detektKotlindefault-detekt-config.yml, detekt.ymlSupports configuration file in directories other than root and can search up to 5 directories into the repository.
ESLint v8JavaScript, TypeScript.eslintrc.js, .eslintrc.cjs, .eslintrc.yaml, .eslintrc.yml, .eslintrc.json
ESLint v9JavaScript, TypeScripteslint.config.js, eslint.config.mjs, eslint.config.cjs
HadolintDockerfile.hadolint.yaml
markdownlintMarkdown.markdownlint.yml, .markdownlint.yaml, .markdownlint.jsonc, .markdownlint.json
PHP_CodeSnifferPHPphpcs.xml, phpcs.xml.dist
PHP Mess DetectorPHPcodesize.xml, phpmd.xml, phpmd.xml.dist
PMDApex, Java, JavaScript, JSP, PL/SQL, XML, Velocity and Visualforceruleset.xml, apex-ruleset.xmlSupports configuration file in directories other than root and can search up to 5 directories into the repository.
ProspectorPython.prospector.yml, .prospector.yaml, prospector.yml, prospector.yaml, .landscape.yml, .landscape.yaml, landscape.yml, landscape.yaml
PylintPythonpylintrc, .pylintrcPlugins
remark-lintMarkdown.remarkrc, .remarkrc.json, .remarkrc.yaml, .remarkrc.yml, .remarkrc.js
ReviveGorevive.toml
RuboCopRuby.rubocop.yml, .rubocop-codacy.ymlSupports alternative configuration file .rubocop-codacy.yml for Codacy analysis, allowing exclusion of private gems. This prevents analysis issues caused by private gem references, ensuring proper validation by Codacy.
RuffPythonpyproject.toml, ruff.toml, .ruff.toml
ScalastyleScalascalastyle-config.xml, scalastyle_config.xml
SemgrepApex, C++, C#, Dockerfile, Elixir, GitHub Actions, Go, Java, JavaScript, Kotlin, PHP, Python, Ruby, Rust, Scala, Shell, Swift, Terraform, TypeScript.semgrep.yaml
SonarC#C#SonarLint.xml
SonarVBVisual BasicSonarLint.xml
SpectralAsyncAPI, OpenAPI.spectral.yaml, .spectral.yml, .spectral.json
SpotBugsJava, Scalafindbugs.xml, findbugs-includes.xml, findbugs-excludes.xml, spotbugs.xml, spotbugs-includes.xml, spotbugs-excludes.xmlSupports configuration file in directories other than root and can search up to 5 directories into the repository.
SQLFluffSQLsetup.cfg, tox.ini, pep8.ini, .sqlfluff, pyproject.tomlSupports configuration file in directories other than root
StylelintCSS, LESS, SASS.stylelintrc, stylelint.config.js, .stylelintrc.json, .stylelintrc.yaml, .stylelintrc.yml, .stylelintrc.jsSupports configuration file in directories other than root and can search up to 5 directories into the repository.
SwiftLintSwift.swiftlint.yml
TSQLLintTransact-SQL.tsqllintrc
note

Codacy doesn't support configuration files for the following tools:

  • Aligncheck
  • Checkov
  • Clang-Tidy
  • Codacy Scalameta Pro
  • CoffeeLint
  • Cppcheck
  • deadcode
  • Flawfinder
  • Gosec
  • Jackson Linter
  • Lizard
  • PSScriptAnalyzer
  • ShellCheck
  • SQLint
  • Staticcheck
  • Trivy
  • Unity Roslyn Analyzers

See also