Skip to content

Commit c49a2ef

Browse files
committed
Separate Ruby (rubocop-github) from Rails (rubocop-github-rails) cops and rules to disambiguate rule inheritance from custom cops
1 parent 81240dc commit c49a2ef

File tree

12 files changed

+165
-62
lines changed

12 files changed

+165
-62
lines changed

.rubocop.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
inherit_from: ./config/default.yml
1+
inherit_from:
2+
- ./config/default.yml
23

34
Naming/FileName:
45
Enabled: true
56
Exclude:
67
- "rubocop-github.gemspec"
8+
- "lib/rubocop-github.rb"
9+
- "lib/rubocop-github-rails.rb"

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ GEM
3131
crass (~> 1.0.2)
3232
nokogiri (>= 1.5.9)
3333
minitest (5.16.1)
34+
nokogiri (1.13.6-arm64-darwin)
35+
racc (~> 1.4)
3436
nokogiri (1.13.6-x86_64-darwin)
3537
racc (~> 1.4)
3638
parallel (1.22.1)
@@ -71,6 +73,7 @@ GEM
7173
unicode-display_width (2.2.0)
7274

7375
PLATFORMS
76+
arm64-darwin-21
7477
x86_64-darwin-19
7578
x86_64-darwin-20
7679

README.md

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,32 @@ This repository provides recommended RuboCop configuration and additional Cops f
44

55
## Usage
66

7-
**Gemfile**
8-
9-
``` ruby
10-
gem "rubocop-github"
11-
gem "rubocop-performance", require: false
12-
gem "rubocop-rails", require: false
13-
```
14-
15-
**.rubocop.yml**
16-
17-
``` yaml
18-
inherit_gem:
19-
rubocop-github:
20-
- config/default.yml
21-
- config/rails.yml
22-
```
7+
Add `rubocop-github` to your Gemfile, along with its dependencies:
8+
9+
```ruby
10+
gem "rubocop-github", require: false
11+
gem "rubocop-performance", require: false
12+
gem "rubocop-rails", require: false
13+
```
14+
15+
Inherit all of the stylistic rules and cops through an inheritance declaration in your `.rubocop.yml`:
16+
17+
```yaml
18+
# .rubocop.yml
19+
inherit_from:
20+
rubocop-github:
21+
- config/default.yml # generic Ruby rules and cops
22+
- config/rails.yml # Rails-specific rules and cops
23+
```
24+
25+
Alternatively, only require the additional custom cops in your `.rubocop.yml` without inheriting/enabling the other stylistic rules:
26+
27+
```yaml
28+
# .rubocop.yml
29+
require:
30+
- rubocop-github # generic Ruby cops only
31+
- rubocop-github-rails # Rails-specific cops only
32+
```
2333

2434
💭 Looking for `config/accessibility.yml` and the `GitHub/Accessibility` configs? They have been moved to [a new gem](https://github.com/github/rubocop-rails-accessibility).
2535

config/default.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require:
2-
- rubocop/cop/github
2+
- rubocop-github
33
- rubocop-performance
44

55
AllCops:

config/default_cops.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GitHub/InsecureHashAlgorithm:
2+
Description: 'Encourage usage of secure hash algorithms'
3+
Enabled: pending

config/rails.yml

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require:
2+
- rubocop-github-rails
23
- rubocop-rails
34

45
Rails/OutputSafety:
@@ -22,63 +23,30 @@ GitHub/RailsApplicationRecord:
2223

2324
GitHub/RailsControllerRenderActionSymbol:
2425
Enabled: true
25-
Include:
26-
- 'app/controllers/**/*.rb'
2726

2827
GitHub/RailsControllerRenderLiteral:
2928
Enabled: true
30-
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md
31-
Include:
32-
- 'app/controllers/**/*.rb'
3329

3430
GitHub/RailsControllerRenderPathsExist:
3531
Enabled: true
36-
ViewPath:
37-
- 'app/views'
38-
Include:
39-
- 'app/controllers/**/*.rb'
4032

4133
GitHub/RailsControllerRenderShorthand:
4234
Enabled: true
43-
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-shorthand.md
44-
Include:
45-
- 'app/controllers/**/*.rb'
4635

4736
GitHub/RailsRenderInline:
4837
Enabled: true
49-
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-inline.md
50-
Include:
51-
- 'app/controllers/**/*.rb'
52-
- 'app/helpers/**/*.rb'
53-
- 'app/view_models/**/*.rb'
54-
- 'app/views/**/*.erb'
5538

5639
GitHub/RailsRenderObjectCollection:
5740
Enabled: false
5841

5942
GitHub/RailsViewRenderLiteral:
6043
Enabled: true
61-
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md
62-
Include:
63-
- 'app/helpers/**/*.rb'
64-
- 'app/view_models/**/*.rb'
65-
- 'app/views/**/*.erb'
6644

6745
GitHub/RailsViewRenderPathsExist:
6846
Enabled: true
69-
ViewPath:
70-
- 'app/views'
71-
Include:
72-
- 'app/helpers/**/*.rb'
73-
- 'app/view_models/**/*.rb'
74-
- 'app/views/**/*.erb'
7547

7648
GitHub/RailsViewRenderShorthand:
7749
Enabled: true
78-
Include:
79-
- 'app/helpers/**/*.rb'
80-
- 'app/view_models/**/*.rb'
81-
- 'app/views/**/*.erb'
8250

8351
# Exclude Rails ERB files from incompatible cops
8452

config/rails_cops.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
GitHub/RailsApplicationRecord:
2+
Enabled: pending
3+
4+
GitHub/RailsControllerRenderActionSymbol:
5+
Enabled: pending
6+
Include:
7+
- 'app/controllers/**/*.rb'
8+
9+
GitHub/RailsControllerRenderLiteral:
10+
Enabled: pending
11+
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md
12+
Include:
13+
- 'app/controllers/**/*.rb'
14+
15+
GitHub/RailsControllerRenderPathsExist:
16+
Enabled: pending
17+
ViewPath:
18+
- 'app/views'
19+
Include:
20+
- 'app/controllers/**/*.rb'
21+
22+
GitHub/RailsControllerRenderShorthand:
23+
Enabled: pending
24+
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-shorthand.md
25+
Include:
26+
- 'app/controllers/**/*.rb'
27+
28+
GitHub/RailsRenderInline:
29+
Enabled: pending
30+
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-inline.md
31+
Include:
32+
- 'app/controllers/**/*.rb'
33+
- 'app/helpers/**/*.rb'
34+
- 'app/view_models/**/*.rb'
35+
- 'app/views/**/*.erb'
36+
37+
GitHub/RailsRenderObjectCollection:
38+
Enabled: pending
39+
40+
GitHub/RailsViewRenderLiteral:
41+
Enabled: pending
42+
StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md
43+
Include:
44+
- 'app/helpers/**/*.rb'
45+
- 'app/view_models/**/*.rb'
46+
- 'app/views/**/*.erb'
47+
48+
GitHub/RailsViewRenderPathsExist:
49+
Enabled: pending
50+
ViewPath:
51+
- 'app/views'
52+
Include:
53+
- 'app/helpers/**/*.rb'
54+
- 'app/view_models/**/*.rb'
55+
- 'app/views/**/*.erb'
56+
57+
GitHub/RailsViewRenderShorthand:
58+
Enabled: pending
59+
Include:
60+
- 'app/helpers/**/*.rb'
61+
- 'app/view_models/**/*.rb'
62+
- 'app/views/**/*.erb'

lib/rubocop-github-rails.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
require "rubocop"
4+
require "rubocop/github"
5+
require "rubocop/github/inject"
6+
7+
RuboCop::GitHub::Inject.rails_defaults!
8+
9+
require "rubocop/cop/github/rails_application_record"
10+
require "rubocop/cop/github/rails_controller_render_action_symbol"
11+
require "rubocop/cop/github/rails_controller_render_literal"
12+
require "rubocop/cop/github/rails_controller_render_paths_exist"
13+
require "rubocop/cop/github/rails_controller_render_shorthand"
14+
require "rubocop/cop/github/rails_render_inline"
15+
require "rubocop/cop/github/rails_render_object_collection"
16+
require "rubocop/cop/github/rails_view_render_literal"
17+
require "rubocop/cop/github/rails_view_render_paths_exist"
18+
require "rubocop/cop/github/rails_view_render_shorthand"

lib/rubocop-github.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
require "rubocop"
4+
require "rubocop/github"
5+
require "rubocop/github/inject"
6+
7+
RuboCop::GitHub::Inject.default_defaults!
8+
9+
require "rubocop/cop/github/insecure_hash_algorithm"

lib/rubocop/cop/github.rb

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
# frozen_string_literal: true
22

3-
require "rubocop/cop/github/insecure_hash_algorithm"
4-
require "rubocop/cop/github/rails_application_record"
5-
require "rubocop/cop/github/rails_controller_render_action_symbol"
6-
require "rubocop/cop/github/rails_controller_render_literal"
7-
require "rubocop/cop/github/rails_controller_render_paths_exist"
8-
require "rubocop/cop/github/rails_controller_render_shorthand"
9-
require "rubocop/cop/github/rails_render_inline"
10-
require "rubocop/cop/github/rails_render_object_collection"
11-
require "rubocop/cop/github/rails_view_render_literal"
12-
require "rubocop/cop/github/rails_view_render_paths_exist"
13-
require "rubocop/cop/github/rails_view_render_shorthand"
3+
require "rubocop-github"
4+
require "rubocop-rails"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy