Skip to content

Commit

Permalink
feat: Default ignore files are always applied DOCS-663 (#2063)
Browse files Browse the repository at this point in the history
* clean: Move less used option to the end

* clean: Promote admonition information to a procedure step

* clean: Rearranged ignoring files content; add UI screenshot when conf file exists

* clean: Increase section indentation

* clean: Create outer section for tool configuration and move related admonition

* clean: Better clarify that tools can't be disabled using config file

* clean: Reinforce the addition of ignored files settings

* clean: Reorder list items

* clean: Tweak for clarity

* clean: Turn step into a note

Co-authored-by: Nicola Klemenc <[email protected]>

* clean: Tweaks for clarity and typo

Co-authored-by: Nicola Klemenc <[email protected]>

* clean: Remove list bullet from single item

* clean: Adjust admonition to note

* clean: Move image out of admonition

* clean: Apply feedback, default ignored files are overridden

* feat: Default ignored files can't be overridden anymore

* feat: Update list of default ignored files

---------

Co-authored-by: Nicola Klemenc <[email protected]>
  • Loading branch information
claudiacarpinteiro and nicklem authored Apr 2, 2024
1 parent fea5c34 commit b4e4a61
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 24 deletions.
43 changes: 28 additions & 15 deletions docs/repositories-configure/codacy-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@ description: Use the Codacy configuration file to configure advanced features on

Codacy supports configuring certain advanced features through a configuration file, such as:

- Ignoring files globally, for duplication, or a specific tool
- [Ignoring files](#ignore-files) globally, for duplication, or a specific tool

- Adjusting [tool-specific configurations](#tool-conf)

- Configuring a specific repository directory on which to start the analysis

- Adding custom file extensions to languages, keeping in mind that some tools might not work out of the box with those extensions

- Adjusting [tool-specific configurations](#tool-specific-configurations)
## Using a Codacy configuration file

!!! note
- If a Codacy configuration file exists in your repository, the [Ignored files settings](ignoring-files.md) defined on the Codacy UI don't apply and you must ignore files using the configuration file instead.
- To disable a tool you must use the [Code patterns page](configuring-code-patterns.md) instead.
- {% include-markdown "../assets/includes/coverage-ignore.md" %}
!!! important
If your repository has a Codacy configuration file, the [Ignored files settings](ignoring-files.md) defined on the Codacy UI don't apply and you must [ignore files using the configuration file](#syntax-for-ignoring-files) instead.

To use a Codacy configuration file:

1. Create a text file with the name `.codacy.yml` or `.codacy.yaml` on the root of your repository.

The file must start with a line containing a triple dash (`---`).

1. Add your settings to the configuration file based on the example template below.

!!! important
The configuration file must start with a line containing a triple dash (`---`).
If you defined any [Ignored files settings](ignoring-files.md) for the repository, make sure you [add those settings](#syntax-for-ignoring-files) to the Codacy configuration file.

```yaml
---
Expand Down Expand Up @@ -59,7 +60,14 @@ To use a Codacy configuration file:
codacy-analysis-cli validate-configuration --directory `pwd`
```

## Syntax for ignoring files
## Ignoring files using a Codacy configuration file {: id="ignore-files"}

The Codacy configuration file gives you more flexibility in [ignoring or excluding files](ignoring-files.md) from the Codacy analysis.

!!! note
{% include-markdown "../assets/includes/coverage-ignore.md" %}

### Syntax for ignoring files

To ignore files using a Codacy configuration file, you must define one or more patterns under `exclude_paths` using the [Java glob syntax](https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher%28java.lang.String%29):

Expand All @@ -81,7 +89,12 @@ exclude_paths:
- "**/*.resource"
```

## Which tools can be configured and which name should I use?
## Adjusting tool configurations {: id="tool-conf"}

!!! note
The Codacy configuration file lets you [configure tools](#tool-specific-configurations), but you can't enable or disable them. A tool can only be enabled or disabled on the [Code patterns page](configuring-code-patterns.md) by users with the [necessary permissions](../organizations/roles-and-permissions-for-organizations.md).

### Which tools can be configured and which name should I use?

<!--NOTE
When adding a new supported tool, make sure that you update the following pages:
Expand Down Expand Up @@ -146,13 +159,13 @@ The following names are **deprecated** and shouldn't be used, although they're s
- `pylint` - Use the name `pylintpython3` for **Pylint**.
- `tailor` - The tool **Tailor** [is deprecated](../release-notes/cloud/cloud-2023-10-25-csslint-jshint-fauxpas-tailor-tslint-deprecation.md). If you are using **SwiftLint** instead, use the name `swiftlint`.

## Tool-specific configurations
### Tool-specific configurations

By default, Codacy tries to detect which language is used on each source code file, and uses a set of default options for identifying duplicate blocks of code. However, some false positives may occur.

The tools below support specifying the language or language version used in the source code files that you're analyzing, or tuning the duplication detection.

### Cppcheck
#### Cppcheck

If you're using Cppcheck to analyze C or C++ source code files, add the following configuration to your Codacy configuration file to define the programming language you're using. The supported languages are `c` and `c++`:

Expand All @@ -163,7 +176,7 @@ engines:
language: c++
```

### PHP_CodeSniffer
#### PHP_CodeSniffer

If you're using the [PHP Compatibility](https://github.com/PHPCompatibility/PHPCompatibility) coding standard for PHP_CodeSniffer, add the following configuration to your Codacy configuration file to [define the PHP version](https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions) you're using:

Expand All @@ -174,7 +187,7 @@ engines:
php_version: 5.5
```

### Legacy Pylint 1.9.*
#### Legacy Pylint 1.9.*

If you're using the legacy Pylint 1.9.* to analyze Python source code files, add the following configuration to your Codacy configuration file to define the Python language version you're using. The supported versions are `2` and `3`:

Expand All @@ -188,7 +201,7 @@ engines:
!!! tip
If you're using Python 3.4.\* or later as your programming language, disable the tool **Pylint (legacy)** and enable the tool **Pylint** on your repository [Code patterns page](configuring-code-patterns.md) instead. For more information, see [What's New in Pylint 2.0](https://pylint.pycqa.org/en/latest/whatsnew/2/2.0/index.html).

### PMD CPD (Duplication)
#### PMD CPD (Duplication)

<!--NOTE
Reference for all options:
Expand Down
26 changes: 17 additions & 9 deletions docs/repositories-configure/ignoring-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,37 @@ To exclude files from your repository analysis open your repository **Settings**

![Ignored files](images/ignored-files.png)

You can also ignore files using your own [tool configuration files](configuring-code-patterns.md#using-your-own-tool-configuration-files), although this depends on the option being supported by each tool.
!!! note
- See below the files that Codacy [ignores by default](#default-ignored-files).

- You can also ignore files using your own [tool configuration files](configuring-code-patterns.md#using-your-own-tool-configuration-files), although this depends on the option being supported by each tool.

- {% include-markdown "../assets/includes/coverage-ignore.md" %}

If you need more flexibility in ignoring files, use a Codacy configuration file to [define a custom list of file paths to exclude](codacy-configuration-file.md#syntax-for-ignoring-files).

!!! note
{% include-markdown "../assets/includes/coverage-ignore.md" %}
!!! important
If your repository has a [Codacy configuration file](codacy-configuration-file.md), the **Ignored files** settings defined on the Codacy UI don't apply and you must [ignore files using the configuration file](codacy-configuration-file.md#ignore-files) instead.

![Ignored files](images/ignored-files-configuration-file.png)

## Default ignored files

By default, Codacy ignores all the files that match the regular expressions below. If you want to override these defaults, use a Codacy configuration file to [define a custom list of file paths to exclude](codacy-configuration-file.md#syntax-for-ignoring-files).
By default, Codacy ignores all the files that match the regular expressions below.

```text
.*[\.-]min\.css
.*[\.-]min\.js
.*node_modules/.*
.*bower_components
.*bower_components/.*
.*vendor/.*
.*third[_-]?[Pp]arty
.*third[_-]?[Pp]arty/.*
.*docs?/.*
.*samples
.*samples?/.*
.*releases?/.*
.*builds
.*builds?/.*
.*dist/.*
.*external
.*external/.*
.*libs/.*
.*d3\.js
.*angular(-resource|)?\.js
Expand All @@ -52,4 +59,5 @@ By default, Codacy ignores all the files that match the regular expressions belo
.*bootstrap\.js
.*bootstrap\.css
.*font-awesome\.css
.*\.[Dd]esigner\.cs
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b4e4a61

Please sign in to comment.