File tree 10 files changed +61
-20
lines changed 10 files changed +61
-20
lines changed Original file line number Diff line number Diff line change 1
1
inherit_from : .rubocop_todo.yml
2
2
3
- require :
3
+ plugins :
4
4
- rubocop-performance
5
5
- rubocop-rake
6
6
- rubocop-rspec
7
- - rubocop/cop/ internal_affairs
7
+ - rubocop- internal_affairs
8
8
9
9
AllCops :
10
10
DisplayCopNames : true
Original file line number Diff line number Diff line change 4
4
5
5
- Handle unknown HTTP status codes for ` RSpecRails/HttpStatus ` cop. ([ @viralpraxis ] )
6
6
- Fix a false negative for ` RSpecRails/TravelAround ` cop when passed as a proc to a travel method. ([ @ydah ] )
7
+ - Make RuboCop RSpecRails work as a RuboCop plugin. ([ @bquorning ] )
7
8
8
9
## 2.30.0 (2024-06-12)
9
10
Original file line number Diff line number Diff line change @@ -8,8 +8,8 @@ gem 'bump'
8
8
gem 'rack'
9
9
gem 'rake'
10
10
gem 'rspec' , '~> 3.11'
11
- gem 'rubocop-performance' , '~> 1.7 '
12
- gem 'rubocop-rake' , '~> 0.6 '
11
+ gem 'rubocop-performance' , '~> 1.24 '
12
+ gem 'rubocop-rake' , '~> 0.7 '
13
13
gem 'simplecov' , '>= 0.19'
14
14
gem 'yard'
15
15
Original file line number Diff line number Diff line change @@ -33,31 +33,34 @@ ways to do this:
33
33
Put this into your ` .rubocop.yml ` .
34
34
35
35
``` yaml
36
- require : rubocop-rspec_rails
36
+ plugins : rubocop-rspec_rails
37
37
` ` `
38
38
39
39
Alternatively, use the following array notation when specifying multiple extensions.
40
40
41
41
` ` ` yaml
42
- require :
42
+ plugins :
43
43
- rubocop-rspec
44
44
- rubocop-rspec_rails
45
45
` ` `
46
46
47
47
Now you can run ` rubocop` and it will automatically load the RuboCop RSpec Rails
48
48
cops together with the standard cops.
49
49
50
+ > [!NOTE]
51
+ > The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.
52
+
50
53
# ## Command line
51
54
52
55
` ` ` bash
53
- rubocop --require rubocop-rspec_rails
56
+ rubocop --plugin rubocop-rspec_rails
54
57
` ` `
55
58
56
59
# ## Rake task
57
60
58
61
` ` ` ruby
59
62
RuboCop::RakeTask.new do |task|
60
- task.requires << 'rubocop-rspec_rails'
63
+ task.plugins << 'rubocop-rspec_rails'
61
64
end
62
65
` ` `
63
66
Original file line number Diff line number Diff line change @@ -8,33 +8,35 @@ There are three ways to do this:
8
8
Put this into your `.rubocop.yml`:
9
9
10
10
----
11
- require : rubocop-rspec_rails
11
+ plugins : rubocop-rspec_rails
12
12
----
13
13
14
14
or, if you are using several extensions:
15
15
16
16
----
17
- require :
17
+ plugins :
18
18
- rubocop-rspec
19
19
- rubocop-rspec_rails
20
20
----
21
21
22
22
Now you can run `rubocop` and it will automatically load the RuboCop RSpec Rails
23
23
cops together with the standard cops.
24
24
25
+ NOTE: The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.
26
+
25
27
== Command line
26
28
27
29
[source,bash]
28
30
----
29
- $ rubocop --require rubocop-rspec_rails
31
+ $ rubocop --plugin rubocop-rspec_rails
30
32
----
31
33
32
34
== Rake task
33
35
34
36
[source,ruby]
35
37
----
36
38
RuboCop::RakeTask.new do |task|
37
- task.requires << 'rubocop-rspec_rails'
39
+ task.plugins << 'rubocop-rspec_rails'
38
40
end
39
41
----
40
42
Original file line number Diff line number Diff line change 6
6
require 'rubocop'
7
7
require 'rubocop/rspec/language'
8
8
9
+ require_relative 'rubocop/rspec_rails/plugin'
9
10
require_relative 'rubocop/rspec_rails/version'
10
11
11
12
require 'rubocop/cop/rspec/base'
12
13
require_relative 'rubocop/cop/rspec_rails_cops'
13
-
14
- project_root = File . join ( __dir__ , '..' )
15
- RuboCop ::ConfigLoader . inject_defaults! ( project_root )
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require 'lint_roller'
4
+
5
+ module RuboCop
6
+ module RSpecRails
7
+ # A plugin that integrates RuboCop RSpecRails with RuboCop's plugin system.
8
+ class Plugin < LintRoller ::Plugin
9
+ # :nocov:
10
+ def about
11
+ LintRoller ::About . new (
12
+ name : 'rubocop-rspec_rails' ,
13
+ version : Version ::STRING ,
14
+ homepage : 'https://github.com/rubocop/rubocop-rspec_rails' ,
15
+ description : 'Code style checking for RSpec Rails files.'
16
+ )
17
+ end
18
+ # :nocov:
19
+
20
+ def supported? ( context )
21
+ context . engine == :rubocop
22
+ end
23
+
24
+ def rules ( _context )
25
+ project_root = Pathname . new ( __dir__ ) . join ( '../../..' )
26
+
27
+ LintRoller ::Rules . new (
28
+ type : :path ,
29
+ config_format : :rubocop ,
30
+ value : project_root . join ( 'config/default.yml' )
31
+ )
32
+ end
33
+ end
34
+ end
35
+ end
Original file line number Diff line number Diff line change @@ -31,9 +31,11 @@ Gem::Specification.new do |spec|
31
31
spec . metadata = {
32
32
'changelog_uri' => 'https://github.com/rubocop/rubocop-rspec_rails/blob/master/CHANGELOG.md' ,
33
33
'documentation_uri' => 'https://docs.rubocop.org/rubocop-rspec_rails/' ,
34
- 'rubygems_mfa_required' => 'true'
34
+ 'rubygems_mfa_required' => 'true' ,
35
+ 'default_lint_roller_plugin' => 'RuboCop::RSpecRails::Plugin'
35
36
}
36
37
37
- spec . add_runtime_dependency 'rubocop' , '~> 1.61'
38
- spec . add_runtime_dependency 'rubocop-rspec' , '~> 3' , '>= 3.0.1'
38
+ spec . add_dependency 'lint_roller' , '~> 1.1'
39
+ spec . add_dependency 'rubocop' , '~> 1.72' , '>= 1.72.1'
40
+ spec . add_runtime_dependency 'rubocop-rspec' , '~> 3.5'
39
41
end
Original file line number Diff line number Diff line change @@ -42,8 +42,6 @@ module SpecHelper
42
42
# We should take their advice!
43
43
config . raise_on_warning = true
44
44
45
- config . include ( ExpectOffense )
46
-
47
45
config . include_context 'with default RSpec/Language config' , :config
48
46
config . include_context 'smoke test' , type : :cop_spec
49
47
end
Original file line number Diff line number Diff line change 12
12
13
13
desc 'Generate docs of all cops departments'
14
14
task generate_cops_documentation : :yard_for_generate_documentation do
15
+ RuboCop ::ConfigLoader . inject_defaults! ( "#{ __dir__ } /../config/default.yml" )
16
+
15
17
generator = CopsDocumentationGenerator . new (
16
18
departments : %w[ RSpecRails ]
17
19
)
You can’t perform that action at this time.
0 commit comments