Skip to content

Commit cdcad37

Browse files
authored
Merge branch 'master' into rubocop-default-enablement
2 parents 4274086 + bbe922b commit cdcad37

17 files changed

+167
-170
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: 24 additions & 14 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**
7+
Add `rubocop-github` to your Gemfile, along with its dependencies:
88

9-
``` ruby
10-
gem "rubocop-github"
11-
gem "rubocop-performance", require: false
12-
gem "rubocop-rails", require: false
13-
```
9+
```ruby
10+
gem "rubocop-github", require: false
11+
gem "rubocop-performance", require: false
12+
gem "rubocop-rails", require: false
13+
```
1414

15-
**.rubocop.yml**
15+
Inherit all of the stylistic rules and cops through an inheritance declaration in your `.rubocop.yml`:
1616

17-
``` yaml
18-
inherit_gem:
19-
rubocop-github:
20-
- config/default.yml
21-
- config/rails.yml
22-
```
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

@@ -39,4 +49,4 @@ bundle exec rake test
3949

4050
## The Cops
4151

42-
All cops are located under [`lib/rubocop/cop/github`](lib/rubocop/cop/github) and [`lib/rubocop/cop/github/accessibility`](lib/rubocop/cop/github/accessibility), and contain examples/documentation.
52+
All cops are located under [`lib/rubocop/cop/github`](lib/rubocop/cop/github).

STYLEGUIDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,8 @@ hsh = {
418418
[Keyword arguments](http://magazine.rubyist.net/?Ruby200SpecialEn-kwarg) are recommended but not required when a method's arguments may otherwise be opaque or non-obvious when called. Additionally, prefer them over the old "Hash as pseudo-named args" style from pre-2.0 ruby.
419419
<a name="keyword-arguments"></a><sup>[[link](#keyword-arguments)]</sup>
420420
421-
``` ruby
422-
423421
So instead of this:
422+
424423
``` ruby
425424
def remove_member(user, skip_membership_check=false)
426425
# ...
@@ -430,7 +429,8 @@ end
430429
remove_member(user, true)
431430
```
432431
433-
Do this, which is much clearer.
432+
Do this, which is much clearer:
433+
434434
``` ruby
435435
def remove_member(user, skip_membership_check: false)
436436
# ...
@@ -893,4 +893,4 @@ result = hash.map { |_, v| v + 1 }
893893

894894
Refactoring is even better. It's worth looking hard at any code that explicitly checks types.
895895

896-
[rubocop-guide]: https://github.com/rubocop-hq/ruby-style-guide
896+
[rubocop-guide]: https://github.com/rubocop-hq/ruby-style-guide

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
Bundler/DuplicatedGem:

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'

guides/image-has-alt.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

guides/link-has-href.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

guides/no-positive-tabindex.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

guides/no-redundant-image-alt.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

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"

0 commit comments

Comments
 (0)