Document Globs/Excluded

This commit is contained in:
Vitalii Elenhaupt 2020-03-22 14:58:10 +02:00
parent 2303bd82ae
commit 9a6c4e52f4
No known key found for this signature in database
GPG key ID: CD0BF17825928BC0
2 changed files with 43 additions and 5 deletions

View file

@ -24,8 +24,9 @@
* [Docker](#docker) * [Docker](#docker)
* [From sources](#from-sources) * [From sources](#from-sources)
- [Configuration](#configuration) - [Configuration](#configuration)
* [Only/Except](#onlyexcept) * [Sources](#sources)
* [Explanation](#explanation) * [Rules](#rules)
* [Explain issues](#explain-issues)
* [Inline disabling](#inline-disabling) * [Inline disabling](#inline-disabling)
- [Editors & integrations](#editors--integrations) - [Editors & integrations](#editors--integrations)
- [Credits & inspirations](#credits--inspirations) - [Credits & inspirations](#credits--inspirations)
@ -150,7 +151,37 @@ It allows to configure rule properties, disable specific rules and exclude sourc
Generate new file by running `ameba --gen-config`. Generate new file by running `ameba --gen-config`.
### Only/Except ### Sources
**List of sources to run Ameba on can be configured globally via:**
- `Globs` section - an array of wildcards (or paths) to include to the
inspection. Defaults to `%w(**/*.cr !lib)`, meaning it includes all project
files with `*.cr` extension except those which exist in `lib` folder.
- `Excluded` section - an array of wildcards (or paths) to exclude from the
source list defined by `Globs`. Defaults to an empty array.
In this example we define default globs and exclude `src/compiler` folder:
``` yaml
Globs:
- **/*.cr
- !lib
Excluded:
- src/compiler
```
**Specific sources can be excluded at rule level**:
``` yaml
Style/RedundantBegin:
Excluded:
- src/server/processor.cr
- src/server/api.cr
```
### Rules
One or more rules, or a one or more group of rules can be included or excluded One or more rules, or a one or more group of rules can be included or excluded
via command line arguments: via command line arguments:
@ -162,7 +193,14 @@ $ ameba --except Lint/Syntax # runs all rules except Lint/Syntax
$ ameba --except Style,Lint # runs all rules except rules in Style and Lint groups $ ameba --except Style,Lint # runs all rules except rules in Style and Lint groups
``` ```
### Explanation Or through the configuration file:
``` yaml
Style/RedundantBegin:
Enabled: false
```
### Explain issues
Ameba allows you to dig deeper into an issue, by showing you details about the issue Ameba allows you to dig deeper into an issue, by showing you details about the issue
and the reasoning by it being reported. and the reasoning by it being reported.

View file

@ -177,7 +177,7 @@ class Ameba::Config
private def load_array_section(config, section_name, default = [] of String) private def load_array_section(config, section_name, default = [] of String)
case value = config[section_name]? case value = config[section_name]?
when .nil? then default when .nil? then default
when .as_s? then [value.to_s] when .as_s? then [value.to_s]
when .as_a? then value.as_a.map(&.as_s) when .as_a? then value.as_a.map(&.as_s)
else else