File tree Expand file tree Collapse file tree 10 files changed +61
-20
lines changed
Expand file tree Collapse file tree 10 files changed +61
-20
lines changed Original file line number Diff line number Diff line change 11inherit_from : .rubocop_todo.yml
22
3- require :
3+ plugins :
44 - rubocop-performance
55 - rubocop-rake
66 - rubocop-rspec
7- - rubocop/cop/ internal_affairs
7+ - rubocop- internal_affairs
88
99AllCops :
1010 DisplayCopNames : true
Original file line number Diff line number Diff line change 44
55- Handle unknown HTTP status codes for ` RSpecRails/HttpStatus ` cop. ([ @viralpraxis ] )
66- 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 ] )
78
89## 2.30.0 (2024-06-12)
910
Original file line number Diff line number Diff line change @@ -8,8 +8,8 @@ gem 'bump'
88gem 'rack'
99gem 'rake'
1010gem '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 '
1313gem 'simplecov' , '>= 0.19'
1414gem 'yard'
1515
Original file line number Diff line number Diff line change @@ -33,31 +33,34 @@ ways to do this:
3333Put this into your ` .rubocop.yml ` .
3434
3535``` yaml
36- require : rubocop-rspec_rails
36+ plugins : rubocop-rspec_rails
3737` ` `
3838
3939Alternatively, use the following array notation when specifying multiple extensions.
4040
4141` ` ` yaml
42- require :
42+ plugins :
4343 - rubocop-rspec
4444 - rubocop-rspec_rails
4545` ` `
4646
4747Now you can run ` rubocop` and it will automatically load the RuboCop RSpec Rails
4848cops together with the standard cops.
4949
50+ > [!NOTE]
51+ > The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.
52+
5053# ## Command line
5154
5255` ` ` bash
53- rubocop --require rubocop-rspec_rails
56+ rubocop --plugin rubocop-rspec_rails
5457` ` `
5558
5659# ## Rake task
5760
5861` ` ` ruby
5962RuboCop::RakeTask.new do |task|
60- task.requires << 'rubocop-rspec_rails'
63+ task.plugins << 'rubocop-rspec_rails'
6164end
6265` ` `
6366
Original file line number Diff line number Diff line change @@ -8,33 +8,35 @@ There are three ways to do this:
88Put this into your `.rubocop.yml`:
99
1010----
11- require : rubocop-rspec_rails
11+ plugins : rubocop-rspec_rails
1212----
1313
1414or, if you are using several extensions:
1515
1616----
17- require :
17+ plugins :
1818 - rubocop-rspec
1919 - rubocop-rspec_rails
2020----
2121
2222Now you can run `rubocop` and it will automatically load the RuboCop RSpec Rails
2323cops together with the standard cops.
2424
25+ NOTE: The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.
26+
2527== Command line
2628
2729[source,bash]
2830----
29- $ rubocop --require rubocop-rspec_rails
31+ $ rubocop --plugin rubocop-rspec_rails
3032----
3133
3234== Rake task
3335
3436[source,ruby]
3537----
3638RuboCop::RakeTask.new do |task|
37- task.requires << 'rubocop-rspec_rails'
39+ task.plugins << 'rubocop-rspec_rails'
3840end
3941----
4042
Original file line number Diff line number Diff line change 66require 'rubocop'
77require 'rubocop/rspec/language'
88
9+ require_relative 'rubocop/rspec_rails/plugin'
910require_relative 'rubocop/rspec_rails/version'
1011
1112require 'rubocop/cop/rspec/base'
1213require_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|
3131 spec . metadata = {
3232 'changelog_uri' => 'https://github.com/rubocop/rubocop-rspec_rails/blob/master/CHANGELOG.md' ,
3333 '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'
3536 }
3637
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'
3941end
Original file line number Diff line number Diff line change @@ -42,8 +42,6 @@ module SpecHelper
4242 # We should take their advice!
4343 config . raise_on_warning = true
4444
45- config . include ( ExpectOffense )
46-
4745 config . include_context 'with default RSpec/Language config' , :config
4846 config . include_context 'smoke test' , type : :cop_spec
4947end
Original file line number Diff line number Diff line change 1212
1313desc 'Generate docs of all cops departments'
1414task generate_cops_documentation : :yard_for_generate_documentation do
15+ RuboCop ::ConfigLoader . inject_defaults! ( "#{ __dir__ } /../config/default.yml" )
16+
1517 generator = CopsDocumentationGenerator . new (
1618 departments : %w[ RSpecRails ]
1719 )
You can’t perform that action at this time.
0 commit comments