Skip to content

Commit

Permalink
Document Globs/Excluded
Browse files Browse the repository at this point in the history
veelenga committed Mar 22, 2020
1 parent 2303bd8 commit 9a6c4e5
Showing 2 changed files with 43 additions and 5 deletions.
46 changes: 42 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -24,8 +24,9 @@
* [Docker](#docker)
* [From sources](#from-sources)
- [Configuration](#configuration)
* [Only/Except](#onlyexcept)
* [Explanation](#explanation)
* [Sources](#sources)
* [Rules](#rules)
* [Explain issues](#explain-issues)
* [Inline disabling](#inline-disabling)
- [Editors & integrations](#editors--integrations)
- [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`.

### 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
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
```

### 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
and the reasoning by it being reported.
2 changes: 1 addition & 1 deletion src/ameba/config.cr
Original file line number Diff line number Diff line change
@@ -177,7 +177,7 @@ class Ameba::Config

private def load_array_section(config, section_name, default = [] of String)
case value = config[section_name]?
when .nil? then default
when .nil? then default
when .as_s? then [value.to_s]
when .as_a? then value.as_a.map(&.as_s)
else

0 comments on commit 9a6c4e5

Please sign in to comment.