Skip to content

Commit

Permalink
Address CR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacoby6000 committed Nov 15, 2018
1 parent ff24832 commit fb0198b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 7 additions & 6 deletions docs/rules/DisableSyntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,17 @@ DisableSyntax.regex = [
]
```

1. The first way has a simple object providing an `id`, `pattern`, and `message`.
1. The first way has an object providing an `id`, `pattern`, and `message`.
2. The second way is just the pattern. When this is used, the `id` is set equal
to the pattern, and a generic message is provided for you.
3. The third way allows you to specify what capture-group the problematic thing
is in, in case your regex is complicated.
3. The third way allows you to specify what capture-group the problematic piece
of code is in, in case your regex is complicated and also matches characters
not useful in an error message.

### Error Messages

Error messages have access to the capture groups of the regex. Simply use `{$n}`
where `n` is the index of the capture group you wish to appear in that part of
the message.
Error messages have access to the capture groups of the regex. To access the
capture groups of the regex, use `{$n}` where `n` is the index of the capture
group you wish to appear in that part of the message.

You can see this used in the 3rd example.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ case object DisableSyntaxBase {
def -(other: String): String = s"$value - $other"
}

5 // assert: DisableSyntax.magicNumbers
5 /* assert: DisableSyntax.magicNumbers
^
Numbers (5 in this instance) should always have a named parameter attached, or be assigned to a val.
*/

val fortyTwo = 42
val someDays = 75.days
Expand Down

0 comments on commit fb0198b

Please sign in to comment.