diff --git a/docs/chart/using-codacy/ignoring-files.md b/docs/chart/using-codacy/ignoring-files.md new file mode 100644 index 0000000000..e673075096 --- /dev/null +++ b/docs/chart/using-codacy/ignoring-files.md @@ -0,0 +1,61 @@ +--- +description: Ignore files and folders from the Codacy analysis on Codacy Self-hosted, and see the files that Codacy Self-hosted ignores by default. +--- + +# Ignoring files + +On Codacy Self-hosted, you ignore files and folders from the repository **Settings**. Ignore generated code, third-party libraries, and other files that aren't relevant to your project, so that Codacy reports issues only on the code your team maintains. + +To ignore files and folders: + +1. Open your repository **Settings**, tab **Ignored files**. + + The list shows the files and folders on your main branch. + +1. Select the files and folders that you want to ignore. + +1. Click **Save**. + +![The Ignored files tab on the repository Settings](images/ignored-files-settings.png) + +You can also ignore files using your own [tool configuration files](../../repositories-configure/configuring-code-patterns.md#using-your-own-tool-configuration-files), although this depends on the option being supported by each tool. + +If you need more flexibility in ignoring files, such as ignoring files that match a pattern, use a Codacy configuration file to [define a custom list of file paths to exclude](../../repositories-configure/codacy-configuration-file.md#syntax-for-ignoring-files). If your repository has a Codacy configuration file, the **Ignored files** settings on the Codacy UI don't apply. + +!!! note + {% include-markdown "../../assets/includes/coverage-ignore.md" %} + +## Default ignored files + +By default, Codacy Self-hosted ignores all the files that match the regular expressions below. To override these defaults, use a Codacy configuration file to [define a custom list of file paths to exclude](../../repositories-configure/codacy-configuration-file.md#syntax-for-ignoring-files). + +```text +.*[\.-]min\.css +.*[\.-]min\.js +.*node_modules/.* +.*bower_components +.*vendor/.* +.*third[_-]?[Pp]arty +.*docs?/.* +.*samples +.*releases?/.* +.*builds +.*dist/.* +.*external +.*libs/.* +.*d3\.js +.*angular(-resource|)?\.js +.*select2(-resource|)?\.js +.*-ace\.js +.*typeahead\.js +.*jquery-ui\.js +.*reveal\.js +.*three\.js +.*chart\.js +.*jquery\.js +.*underscore\.js +.*lodash\.js +.*bootstrap\.js +.*bootstrap\.css +.*font-awesome\.css +``` diff --git a/docs/chart/using-codacy/images/ignored-files-settings.png b/docs/chart/using-codacy/images/ignored-files-settings.png new file mode 100644 index 0000000000..f6fd3baa47 Binary files /dev/null and b/docs/chart/using-codacy/images/ignored-files-settings.png differ diff --git a/docs/chart/whats-available-on-codacy-self-hosted.md b/docs/chart/whats-available-on-codacy-self-hosted.md index 5ecdebcbb6..64b6555f2f 100644 --- a/docs/chart/whats-available-on-codacy-self-hosted.md +++ b/docs/chart/whats-available-on-codacy-self-hosted.md @@ -13,7 +13,7 @@ The rest of the documentation describes Codacy Cloud. Use this page to find out These pages apply to Codacy Self-hosted. Where a page needs your instance URL or a tool version, [Using Codacy tools with Codacy Self-hosted](using-codacy/using-codacy-tools-with-codacy-self-hosted.md) lists the changes: - **Repositories:** the [repository dashboard](../repositories/repository-dashboard.md), [Commits](../repositories/commits.md), [Files](../repositories/files.md), [Issues](../repositories/issues.md), [Coverage](../repositories/coverage.md), and [Pull requests](../repositories/pull-requests.md) -- **Repository configuration:** [code patterns](../repositories-configure/configuring-code-patterns.md), [ignored files](../repositories-configure/ignoring-files.md), [submodules](../repositories-configure/using-submodules.md) (with [these changes](using-codacy/using-codacy-tools-with-codacy-self-hosted.md#submodules)), and the [Codacy configuration file](../repositories-configure/codacy-configuration-file.md) +- **Repository configuration:** [code patterns](../repositories-configure/configuring-code-patterns.md), [submodules](../repositories-configure/using-submodules.md) (with [these changes](using-codacy/using-codacy-tools-with-codacy-self-hosted.md#submodules)), and the [Codacy configuration file](../repositories-configure/codacy-configuration-file.md) - **Coverage:** [Codacy Coverage Reporter](../coverage-reporter/index.md) (with [these changes](using-codacy/using-codacy-tools-with-codacy-self-hosted.md#coverage-reporter)) - **Local analysis:** [client-side tools](../repositories-configure/local-analysis/client-side-tools.md), with the Codacy Analysis CLI version for your Codacy Self-hosted version (see [these changes](using-codacy/using-codacy-tools-with-codacy-self-hosted.md#client-side-tools)) - **Organizations:** the [organization overview](../organizations/reporting/organization-overview.md), [managing repositories](../organizations/managing-repositories.md), [managing people](../organizations/managing-people.md), [coding standards](../organizations/using-coding-standards.md), and [roles and permissions](../organizations/roles-and-permissions-for-organizations.md) @@ -26,6 +26,7 @@ Some features work differently on Codacy Self-hosted: - **Branches:** [Managing branches](using-codacy/managing-branches.md) has its own page, including the option to enable new branches automatically. - **Quality settings:** quality gates and quality goals are on one page, [Adjusting quality settings](using-codacy/adjusting-quality-settings.md), instead of the separate pages for [quality gates](../repositories-configure/adjusting-quality-gates.md) and [quality goals](../repositories-configure/adjusting-quality-goals.md). - **File extensions:** instead of [Languages](../repositories-configure/languages.md), see [Configuring file extensions](using-codacy/configuring-file-extensions.md). +- **Ignored files:** you ignore files and folders from the repository Settings, not with ignore rules. See [Ignoring files](using-codacy/ignoring-files.md) instead of the [Codacy Cloud page](../repositories-configure/ignoring-files.md). - **Integrations:** [Jira](using-codacy/jira-integration.md), [Slack](using-codacy/slack-integration.md), and [webhooks](using-codacy/webhook-notifications.md) are set up for each repository, not for the organization. - **File size limit:** you can [change the 150 KB limit](configuration/file-size-limit.md). - **Security:** each repository has a [Security Monitor](using-codacy/security-monitor.md). Codacy Self-hosted doesn't include [Security and risk management](../security/index.md). diff --git a/docs/repositories-configure/codacy-configuration-file.md b/docs/repositories-configure/codacy-configuration-file.md index ccf262666f..290ae95e4d 100644 --- a/docs/repositories-configure/codacy-configuration-file.md +++ b/docs/repositories-configure/codacy-configuration-file.md @@ -22,7 +22,7 @@ Codacy supports configuring certain advanced features through a configuration fi ## Using a Codacy configuration file !!! 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. + - If your repository has a Codacy configuration file, the [ignore rules](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. - Codacy always uses the configuration file **in the default branch**. New settings added to the Codacy configuration file by a pull request are also considered for the pull request analysis, but the existing configuration in the default branch takes precedence. For example, if a pull request removes an ignored path from the Codacy configuration file, any matching files will stay ignored until that pull request is merged into the default branch. @@ -35,7 +35,7 @@ To use a Codacy configuration file: 1. Add your settings to the configuration file based on the example template below. - 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. + If you defined any [ignore rules](ignoring-files.md) for the repository, make sure you [add those paths](#syntax-for-ignoring-files) to the Codacy configuration file. ```yaml --- @@ -82,7 +82,7 @@ To use a Codacy configuration file: ## 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. +The Codacy configuration file gives you more flexibility in [ignoring or excluding files](ignoring-files.md) from the Codacy analysis. To decide between a configuration file and ignore rules on the Codacy UI, see [choosing between ignore rules and a Codacy configuration file](ignoring-files.md#ignore-rules-or-configuration-file). !!! note {% include-markdown "../assets/includes/coverage-ignore.md" %} diff --git a/docs/repositories-configure/ignoring-files.md b/docs/repositories-configure/ignoring-files.md index a15ca8da29..4eedacb900 100644 --- a/docs/repositories-configure/ignoring-files.md +++ b/docs/repositories-configure/ignoring-files.md @@ -1,36 +1,126 @@ --- -description: Ignore or exclude files from the Codacy analysis and see the list of files that Codacy already ignores by default. +description: Ignore files, folders, and patterns from the Codacy analysis with ignore rules, choose between ignore rules and a Codacy configuration file, and see the files that Codacy ignores by default. --- # Ignoring files {% include-markdown "../assets/includes/admin-access-control-info.md" %} -In some situations, you may want to ignore or exclude files from the Codacy analysis. +Ignore generated code, third-party libraries, and other files that aren't relevant to your project, so that Codacy reports issues only on the code your team maintains. To ignore files, add **ignore rules** to your repository: each rule is a file, a folder, or a pattern that Codacy skips during analysis. -To exclude files from your repository analysis open your repository **Files**, page. From there, you can select a file and exclude it by clicking on the Ignore file button. +Ignore rules apply to every branch of the repository, starting from the next analysis. Issues and security findings in the ignored files close as fixed. + +## Adding ignore rules + +To add ignore rules to a repository: + +1. Open your repository **Files** page and select the **Ignore rules** tab. + +1. Click **Add ignore rule**. + +1. Under **Paths**, enter the file, folder, or pattern to ignore. See [how to write a path](#path-syntax). + + To add more than one rule at a time, click **Add another path**. You can add up to 10 paths at a time. + +1. Optionally, expand **Advanced options** to: + + - **Tools:** Select the tools that skip these paths. By default, a rule applies to **All tools**. See [ignoring files for specific tools](#specific-tools). + - **Reason:** Describe why you're ignoring these paths, for example `Generated code`. The reason appears under the path on the list of ignore rules, so your team knows why the rule exists. + +1. Click **Add ignore rule**. + + +![The Ignore rules tab on the Files page](images/ignored-files.png) + +You can also ignore a single file from the **Files** page: select the file and click **Ignore file**. ![Ignoring a file](images/ignoring-a-file.png) -To view the current excluded files, select the **Ignored** tab on the same page. +## Writing a path {: id="path-syntax"} -![Ignored files](images/ignored-files.png) +Paths are relative to the root of your repository and use `/` to separate folders. They use the same glob syntax as [`exclude_paths` in a Codacy configuration file](codacy-configuration-file.md#syntax-for-ignoring-files): -!!! note - - See below the files that Codacy [ignores by default](#default-ignored-files). +| Path | Ignored files | +| --------------- | --------------------------------------------------------- | +| `docs/**` | The folder `docs` and everything in it, including nested folders | +| `docs/*` | Only the files directly in the folder `docs` | +| `*.min.js` | All files ending in `.min.js`, in any folder | +| `docs/index.md` | The file `docs/index.md` | + +To ignore a folder, end the path with `/**`, not with `/`. Codacy doesn't accept: +- Paths that start with `!`. Add rules only for the paths that you want to ignore. To analyze files that a Codacy default ignores, see [default ignored files](#default-ignored-files). +- Paths that use `\` to separate folders. +- Paths that match every file in the repository, such as `**`. + +!!! note - 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" %} - - - When excluding files from **Duplication** analysis, you must state the **entire path** to the files. Unlike quality analysis, wildcards will not work, resulting in files not being excluded. -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). + - When excluding files from **Duplication** analysis, you must state the **entire path** to the files. Unlike quality analysis, wildcards will not work, resulting in files not being excluded. + +## Ignoring files for specific tools {: id="specific-tools"} + +By default, an ignore rule applies to all tools. To ignore a path only for some tools, select those tools under **Advanced options** › **Tools** when you add or edit the rule. The tools that you don't select still analyze the files. + +For example, ignore `tests/**` only for the tools that report issues you don't fix in test code, and keep analyzing your tests for security issues with the other tools. + +The **Tools** column on the list of ignore rules shows which tools each rule applies to. + +## Reviewing your ignore rules + +The **Ignore rules** tab lists every rule that applies to the repository: + +- **Path:** The file, folder, or pattern, with the reason under it. +- **Tools:** **All tools**, or the tools that the rule applies to. +- **Matching files:** How many files the rule ignores, counted on the last analysis of the default branch. A new rule shows **Not analyzed yet** until the next analysis. When you select a branch other than the default branch, this column is hidden. +- **Source:** Who added the rule: + - **User:** A member of your organization, with the date and the author's name under it. + - **Auto-configuration:** [Auto-configure](configuring-code-patterns.md#auto-configuring-your-repository), when it configured the repository. + - **Codacy default:** One of the paths that [Codacy ignores by default](#default-ignored-files). The list shows only the defaults that match files in your repository. + +Use **Search paths** and the **Source**, **Type**, and **Tools** filters to find a rule. + +A rule with 0 matching files ignores nothing in the current code. Check the path for a typo, or delete the rule if the files no longer exist. + +## Editing and deleting ignore rules + +To edit an ignore rule, click the **⋯** menu on the rule's row and select **Edit**. You can change the path, the tools, and the reason, and then click **Save changes**. If you change the path, Codacy replaces the rule with a new one, with you as the author and today's date. + +To delete an ignore rule, click the **⋯** menu on the rule's row, select **Delete**, and confirm with **Delete rule**. From the next analysis, Codacy analyzes the files again and reports their issues. + +You can't edit or delete Codacy defaults. To analyze files that a Codacy default ignores, see [default ignored files](#default-ignored-files). + +## Choosing between ignore rules and a Codacy configuration file {: id="ignore-rules-or-configuration-file"} + +You can also ignore files with `exclude_paths` in a [Codacy configuration file](codacy-configuration-file.md#ignore-files). Use one or the other: **if your repository has a Codacy configuration file, Codacy ignores the files that the configuration file defines, and the ignore rules on the Codacy UI don't apply.** + +| | Ignore rules | Codacy configuration file | +|---|---|---| +| Where you manage them | On the Codacy UI, with no commit | In a `.codacy.yml` or `.codacy.yaml` file in your repository | +| Branches | Apply to every branch | Codacy uses the file on the default branch | +| Change history | Each rule shows its author and date | Versioned and reviewed with your code | +| Analyze files that a Codacy default ignores | No | Yes, with [`include_paths`](codacy-configuration-file.md#include-files) | +| Other settings | Ignore rules only | Also configures tools, languages, and duplication and complexity exclusions | + +Use ignore rules if you want to ignore files without changing your repository, or if the people who manage Codacy don't commit to the repository. + +Use a Codacy configuration file if you want your exclusions reviewed in pull requests alongside the code, if you need to analyze files that a Codacy default ignores, or if you already use the file for other settings. + +When a repository has a Codacy configuration file, the **Ignore rules** tab shows the banner **Ignores are managed by your configuration file** and the list is read-only. To change what Codacy ignores, edit the configuration file on your default branch. To move to ignore rules, delete the configuration file from your default branch and then add its `exclude_paths` as ignore rules. + + +![The Ignore rules tab when the repository has a Codacy configuration file](images/ignored-files-configuration-file.png) + +## Limits + +Each repository can have up to: -!!! 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. +- **5,000 file and folder rules.** +- **A limited number of patterns.** Plain folders, such as `docs/**`, and lists of file extensions, such as `**/*.{ts,tsx}`, don't count toward this limit. A pattern with several alternatives can count more than once. -![Ignored files](images/ignored-files-configuration-file.png) +When a repository reaches a limit, Codacy doesn't add the new rule and shows a message that names the limit. To add more rules, delete the rules that you no longer need, starting with the ones with 0 matching files, or replace several rules with one folder rule. For example, one rule `src/generated/**` replaces a rule for each file in that folder. ## Default ignored files diff --git a/docs/repositories/files.md b/docs/repositories/files.md index cd0e03fb24..01229a1d8c 100644 --- a/docs/repositories/files.md +++ b/docs/repositories/files.md @@ -71,7 +71,7 @@ The Files page only displays files in your repository that were analyzed by Coda - **The file might be ignored** - The Files page has an **Ignored files** tab that displays [ignored files](../repositories-configure/ignoring-files.md) that aren't meant to be analyzed. Note that there are [files that are always ignored by Codacy regardless](../repositories-configure/ignoring-files.md#default-ignored-files). + The Files page has an **Ignore rules** tab that lists the [ignore rules](../repositories-configure/ignoring-files.md) for the repository and how many files each one matches. Note that there are [files that are always ignored by Codacy regardless](../repositories-configure/ignoring-files.md#default-ignored-files). - **The file has an extension that is not on the list of supported extensions** diff --git a/docs/repositories/issues.md b/docs/repositories/issues.md index 3de8cd1814..5763b36218 100644 --- a/docs/repositories/issues.md +++ b/docs/repositories/issues.md @@ -87,7 +87,7 @@ Use the options in the menu of each issue to: - **Ignore the file** where the issue was detected. - Codacy will no longer analyze that file on your repository, so be sure that you're no longer interested in identifying any type of issues on that file. To remove an ignored file use the **Ignored** tab on your repository's Files page. See [Ignoring files](../repositories-configure/ignoring-files.md). + Codacy will no longer analyze that file on your repository, so be sure that you're no longer interested in identifying any type of issues on that file. To analyze the file again, delete its rule on the **Ignore rules** tab of your repository's Files page. See [Ignoring files](../repositories-configure/ignoring-files.md). diff --git a/mkdocs.yml b/mkdocs.yml index d35e0d2a84..afe76a1029 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -725,6 +725,7 @@ nav: - chart/using-codacy/managing-branches.md - chart/using-codacy/adjusting-quality-settings.md - chart/using-codacy/configuring-file-extensions.md + - chart/using-codacy/ignoring-files.md - chart/using-codacy/security-monitor.md - Repository integrations: - chart/using-codacy/jira-integration.md