Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Default ignore files are always applied DOCS-663 #2063

Merged
merged 22 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
bc6c550
clean: Move less used option to the end
Mar 20, 2024
1e2b58a
Merge branch 'master' into DOCS-663-improve-configuration-file
claudiacarpinteiro Mar 20, 2024
84b8985
clean: Promote admonition information to a procedure step
Mar 20, 2024
3bfaa26
clean: Rearranged ignoring files content; add UI screenshot when conf…
Mar 22, 2024
fc163f1
clean: Increase section indentation
Mar 25, 2024
bb43df6
clean: Create outer section for tool configuration and move related a…
Mar 25, 2024
2d38f97
clean: Better clarify that tools can't be disabled using config file
Mar 25, 2024
784f26d
clean: Reinforce the addition of ignored files settings
Mar 25, 2024
3ac34ee
Merge branch 'master' into DOCS-663-improve-configuration-file
claudiacarpinteiro Mar 25, 2024
0490f0f
Merge branch 'master' into DOCS-663-improve-configuration-file
claudiacarpinteiro Mar 26, 2024
128c34f
clean: Reorder list items
Mar 26, 2024
0a7e42f
clean: Tweak for clarity
Mar 26, 2024
56e12da
Merge branch 'master' into DOCS-663-improve-configuration-file
claudiacarpinteiro Mar 27, 2024
aec43dc
clean: Turn step into a note
claudiacarpinteiro Mar 27, 2024
5b2ca5a
clean: Tweaks for clarity and typo
claudiacarpinteiro Mar 27, 2024
16ae22b
clean: Remove list bullet from single item
Mar 27, 2024
33b3959
clean: Adjust admonition to note
Mar 27, 2024
6b2f792
clean: Move image out of admonition
Mar 27, 2024
c020518
clean: Apply feedback, default ignored files are overridden
Mar 28, 2024
d1a390d
feat: Default ignored files can't be overridden anymore
Mar 28, 2024
dc08745
feat: Update list of default ignored files
Mar 28, 2024
3360d75
Merge branch 'master' into DOCS-663-improve-configuration-file
nicklem Apr 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading