Skip to content

Commit 20bb2a2

Browse files
committed
Add RuboCop/Lint-CopDirectiveSyntax.md and RuboCop/Rails-StrongParametersExpect.md
1 parent f835093 commit 20bb2a2

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

RuboCop/Lint-CopDirectiveSyntax.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Pattern: Malformed cop directive syntax
2+
3+
Issue: -
4+
5+
## Description
6+
7+
Checks that `# rubocop:enable …​` and `# rubocop:disable …​` statements are strictly formatted.
8+
9+
A comment can be added to the directive by prefixing it with `--`.
10+
11+
## Examples
12+
13+
```ruby
14+
# bad
15+
# rubocop:disable Layout/LineLength Style/Encoding
16+
# ^ missing comma
17+
18+
# bad
19+
# rubocop:disable
20+
21+
# bad
22+
# rubocop:disable Layout/LineLength # rubocop:disable Style/Encoding
23+
24+
# bad
25+
# rubocop:wrongmode Layout/LineLength
26+
27+
# good
28+
# rubocop:disable Layout/LineLength
29+
30+
# good
31+
# rubocop:disable Layout/LineLength, Style/Encoding
32+
33+
# good
34+
# rubocop:disable all
35+
36+
# good
37+
# rubocop:disable Layout/LineLength -- This is a good comment.
38+
```
39+
40+
## Further Reading
41+
42+
* [RuboCop - Lint/CopDirectiveSyntax](https://docs.rubocop.org/rubocop/cops_lint.html#lintcopdirectivesyntax)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Pattern: Missing use of `ActionController::Parameters#expect`
2+
3+
Issue: -
4+
5+
## Description
6+
7+
Enforces the use of `ActionController::Parameters#expect` as a method for strong parameter handling.
8+
9+
## Examples
10+
11+
```ruby
12+
# bad
13+
params.require(:user).permit(:name, :age)
14+
params.permit(user: [:name, :age]).require(:user)
15+
16+
# good
17+
params.expect(user: [:name, :age])
18+
```
19+
20+
## Further Reading
21+
22+
* [RuboCop - Rails/StrongParametersExpect](https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsstrongparametersexpect)

0 commit comments

Comments
 (0)