File tree Expand file tree Collapse file tree 10 files changed +65
-20
lines changed
Expand file tree Collapse file tree 10 files changed +65
-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 1+ fixme
2+
13# RuboCop RSpec Rails
24
35[ ![ Join the chat at https://gitter.im/rubocop-rspec/Lobby ] ( https://badges.gitter.im/rubocop-rspec/Lobby.svg )] ( https://gitter.im/rubocop-rspec/Lobby )
@@ -33,31 +35,34 @@ ways to do this:
3335Put this into your ` .rubocop.yml ` .
3436
3537``` yaml
36- require : rubocop-rspec_rails
38+ plugins : rubocop-rspec_rails
3739` ` `
3840
3941Alternatively, use the following array notation when specifying multiple extensions.
4042
4143` ` ` yaml
42- require :
44+ plugins :
4345 - rubocop-rspec
4446 - rubocop-rspec_rails
4547` ` `
4648
4749Now you can run ` rubocop` and it will automatically load the RuboCop RSpec Rails
4850cops together with the standard cops.
4951
52+ > [!NOTE]
53+ > The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.
54+
5055# ## Command line
5156
5257` ` ` bash
53- rubocop --require rubocop-rspec_rails
58+ rubocop --plugin rubocop-rspec_rails
5459` ` `
5560
5661# ## Rake task
5762
5863` ` ` ruby
5964RuboCop::RakeTask.new do |task|
60- task.requires << 'rubocop-rspec_rails'
65+ task.plugins << 'rubocop-rspec_rails'
6166end
6267` ` `
6368
Original file line number Diff line number Diff line change 1+ fixme
2+
13= Usage
24
35You need to tell RuboCop to load the RSpec Rails extension.
@@ -8,33 +10,35 @@ There are three ways to do this:
810Put this into your `.rubocop.yml`:
911
1012----
11- require : rubocop-rspec_rails
13+ plugins : rubocop-rspec_rails
1214----
1315
1416or, if you are using several extensions:
1517
1618----
17- require :
19+ plugins :
1820 - rubocop-rspec
1921 - rubocop-rspec_rails
2022----
2123
2224Now you can run `rubocop` and it will automatically load the RuboCop RSpec Rails
2325cops together with the standard cops.
2426
27+ NOTE: The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.
28+
2529== Command line
2630
2731[source,bash]
2832----
29- $ rubocop --require rubocop-rspec_rails
33+ $ rubocop --plugin rubocop-rspec_rails
3034----
3135
3236== Rake task
3337
3438[source,ruby]
3539----
3640RuboCop::RakeTask.new do |task|
37- task.requires << 'rubocop-rspec_rails'
41+ task.plugins << 'rubocop-rspec_rails'
3842end
3943----
4044
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