Skip to content

Commit 8a9e244

Browse files
authored
Merge pull request #81 from Root-App/jxa-update-rubocop
Update rubocop version
2 parents d10af59 + ae416a6 commit 8a9e244

30 files changed

Lines changed: 118 additions & 121 deletions

.rubocop.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
require:
1+
plugins:
22
- rubocop-rails
33
- rubocop-performance
44
- rubocop-rspec
5+
- rubocop-factory_bot
6+
require:
57
- ./lib/rubocop/cop/root_cops/avoid_ruby_prof.rb
68
- ./lib/rubocop/cop/root_cops/eq_be_eql.rb
79
- ./lib/rubocop/cop/root_cops/factories/factory_file_name.rb
@@ -93,6 +95,9 @@ Rails/FilePath:
9395
RSpec:
9496
Enabled: true
9597

98+
RSpec/BeEq:
99+
Enabled: false
100+
96101
RSpec/ContextWording:
97102
Enabled: false
98103

@@ -193,7 +198,7 @@ RootCops/MustInherit:
193198
RootCops/MustInclude:
194199
Enabled: false
195200

196-
RSpec/FactoryBot/CreateList:
201+
FactoryBot/CreateList:
197202
Enabled: false
198203

199204
Lint/ConstantDefinitionInBlock:

Gemfile.lock

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
PATH
22
remote: .
33
specs:
4-
root-ruby-style (0.0.17)
4+
root-ruby-style (0.0.18)
55
activesupport (>= 5.0, < 8)
6-
rubocop (> 1.60)
7-
rubocop-performance (= 1.5.2)
8-
rubocop-rails (~> 2.12.0)
9-
rubocop-rspec (~> 1.38.1)
6+
rubocop (~> 1.75)
7+
rubocop-factory_bot (~> 2.27.1)
8+
rubocop-performance (~> 1.25.0)
9+
rubocop-rails (~> 2.31.0)
10+
rubocop-rspec (~> 3.6.0)
1011

1112
GEM
1213
remote: https://rubygems.org/
@@ -27,11 +28,11 @@ GEM
2728
base64 (0.2.0)
2829
benchmark (0.4.0)
2930
bigdecimal (3.1.9)
30-
byebug (11.1.3)
31+
byebug (12.0.0)
3132
coderay (1.1.3)
3233
concurrent-ruby (1.3.5)
33-
connection_pool (2.5.0)
34-
diff-lcs (1.5.1)
34+
connection_pool (2.5.1)
35+
diff-lcs (1.6.1)
3536
drb (2.2.1)
3637
i18n (1.14.7)
3738
concurrent-ruby (~> 1.0)
@@ -41,26 +42,26 @@ GEM
4142
logger (1.7.0)
4243
method_source (1.1.0)
4344
minitest (5.25.5)
44-
parallel (1.26.3)
45-
parser (3.3.7.4)
45+
parallel (1.27.0)
46+
parser (3.3.8.0)
4647
ast (~> 2.4.1)
4748
racc
4849
prism (1.4.0)
49-
pry (0.14.2)
50+
pry (0.15.2)
5051
coderay (~> 1.1)
5152
method_source (~> 1.0)
52-
pry-byebug (3.10.1)
53-
byebug (~> 11.0)
54-
pry (>= 0.13, < 0.15)
53+
pry-byebug (3.11.0)
54+
byebug (~> 12.0)
55+
pry (>= 0.13, < 0.16)
5556
racc (1.8.1)
56-
rack (3.1.12)
57+
rack (3.1.13)
5758
rainbow (3.1.1)
5859
regexp_parser (2.10.0)
5960
rspec (3.13.0)
6061
rspec-core (~> 3.13.0)
6162
rspec-expectations (~> 3.13.0)
6263
rspec-mocks (~> 3.13.0)
63-
rspec-core (3.13.2)
64+
rspec-core (3.13.3)
6465
rspec-support (~> 3.13.0)
6566
rspec-expectations (3.13.3)
6667
diff-lcs (>= 1.2.0, < 2.0)
@@ -80,17 +81,25 @@ GEM
8081
rubocop-ast (>= 1.44.0, < 2.0)
8182
ruby-progressbar (~> 1.7)
8283
unicode-display_width (>= 2.4.0, < 4.0)
83-
rubocop-ast (1.44.0)
84+
rubocop-ast (1.44.1)
8485
parser (>= 3.3.7.2)
8586
prism (~> 1.4)
86-
rubocop-performance (1.5.2)
87-
rubocop (>= 0.71.0)
88-
rubocop-rails (2.12.4)
87+
rubocop-factory_bot (2.27.1)
88+
lint_roller (~> 1.1)
89+
rubocop (~> 1.72, >= 1.72.1)
90+
rubocop-performance (1.25.0)
91+
lint_roller (~> 1.1)
92+
rubocop (>= 1.75.0, < 2.0)
93+
rubocop-ast (>= 1.38.0, < 2.0)
94+
rubocop-rails (2.31.0)
8995
activesupport (>= 4.2.0)
96+
lint_roller (~> 1.1)
9097
rack (>= 1.1)
91-
rubocop (>= 1.7.0, < 2.0)
92-
rubocop-rspec (1.38.1)
93-
rubocop (>= 0.68.1)
98+
rubocop (>= 1.75.0, < 2.0)
99+
rubocop-ast (>= 1.38.0, < 2.0)
100+
rubocop-rspec (3.6.0)
101+
lint_roller (~> 1.1)
102+
rubocop (~> 1.72, >= 1.72.1)
94103
ruby-progressbar (1.13.0)
95104
securerandom (0.4.1)
96105
tzinfo (2.0.6)
@@ -106,7 +115,7 @@ PLATFORMS
106115
DEPENDENCIES
107116
pry-byebug
108117
root-ruby-style!
109-
rspec (~> 3.8)
118+
rspec (~> 3.13)
110119

111120
BUNDLED WITH
112-
2.2.22
121+
2.6.8

lib/rubocop/cop/root_cops/avoid_ruby_prof.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
module RuboCop
44
module Cop
55
module RootCops
6-
class AvoidRubyProf < Cop
6+
class AvoidRubyProf < RuboCop::Cop::Base
77
ERROR = ":ruby_prof is for local use only and should not be committed."
88
FILE_NAME_MATCHER = /_spec\.rb\z/
99

1010
def_node_matcher :spec_block?, <<~PATTERN
1111
(send nil? {:describe :context :it} ...)
1212
PATTERN
1313

14-
def investigate(processed_source)
14+
def on_new_investigation
1515
@in_spec_file = processed_source.file_path =~ FILE_NAME_MATCHER
1616
end
1717

1818
def on_sym(node)
1919
return unless @in_spec_file && node.value == :ruby_prof && spec_block?(node.parent)
2020

21-
add_offense(node, location: :expression, message: ERROR)
21+
add_offense(node.loc.expression, message: ERROR)
2222
end
2323
end
2424
end

lib/rubocop/cop/root_cops/envvar_assignment.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module RuboCop
22
module Cop
33
module RootCops
4-
class EnvvarAssignment < Cop
4+
class EnvvarAssignment < RuboCop::Cop::Base
55
MSG = "Do not assign an ENVVAR to a constant. Assigning an ENVVAR to a constant has unexpected behavior when used with set_environment_variable. Instead, return the ENVVAR from a method".freeze
66

77
def_node_search :envvar_assignment?, "(send (const _ :ENVVARS) :[] (:str _))"
88

9-
def investigate(processed_source)
9+
def on_new_investigation
1010
file_path = processed_source.file_path
1111
@is_initializer_file = file_path.include?("/initializers/")
1212
end
@@ -17,7 +17,7 @@ def on_casgn(node)
1717
return if value.nil?
1818
return if @is_initializer_file
1919

20-
add_offense(node, location: :expression, message: MSG) if envvar_assignment?(value)
20+
add_offense(node.loc.expression, message: MSG) if envvar_assignment?(value)
2121
end
2222

2323
def on_or_asgn(node)
@@ -26,7 +26,7 @@ def on_or_asgn(node)
2626
return unless lhs&.casgn_type?
2727
return if @is_initializer_file
2828

29-
add_offense(node, location: :expression, message: MSG) if envvar_assignment?(value)
29+
add_offense(node.loc.expression, message: MSG) if envvar_assignment?(value)
3030
end
3131
end
3232
end

lib/rubocop/cop/root_cops/eq_be_eql.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module RootCops
2-
class EqBeEql < ::RuboCop::Cop::Cop
2+
class EqBeEql < ::RuboCop::Cop::Base
33
MSG = "Prefer `eq` over `be` and `eql` when checking booleans, numbers, symbols, strings and nil".freeze
44

55
def_node_matcher :be_or_eql, <<-PATTERN
@@ -19,11 +19,11 @@ class EqBeEql < ::RuboCop::Cop::Cop
1919

2020
def on_send(node)
2121
be_or_eql(node) do |offending_node|
22-
add_offense(offending_node, location: :selector)
22+
add_offense(offending_node.loc.selector)
2323
end
2424

2525
be_true_false_nil(node) do |offending_node|
26-
add_offense(offending_node, location: :selector)
26+
add_offense(offending_node.loc.selector)
2727
end
2828
end
2929
end

lib/rubocop/cop/root_cops/factories/factory_file_name.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ module RuboCop
55
module Cop
66
module RootCops
77
module Factories
8-
class FactoryFileName < Cop
9-
def investigate(processed_source)
8+
class FactoryFileName < RuboCop::Cop::Base
9+
def on_new_investigation
1010
file_path = processed_source.buffer.name
1111
@base_file_name = File.basename(file_path, ".rb")
1212
@base_file_name_last_word = @base_file_name.split("_").last
@@ -18,8 +18,7 @@ def on_send(node)
1818

1919
if receiver_name == :FactoryBot && method_name == :define && Helpers::Factories.file_name_has_error?(@base_file_name)
2020
add_offense(
21-
node,
22-
location: :expression,
21+
node.loc.expression,
2322
severity: :fatal,
2423
message: "Factory file name should be plural (#{@base_file_name.pluralize})."
2524
)

lib/rubocop/cop/root_cops/factories/factory_name.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ module RuboCop
55
module Cop
66
module RootCops
77
module Factories
8-
class FactoryName < Cop
8+
class FactoryName < RuboCop::Cop::Base
99
SYSTEM_IN_PATH = %r{systems/([^/]+)/}
1010

11-
def investigate(processed_source)
11+
def on_new_investigation
1212
file_path = processed_source.buffer.name
1313
system_name_match = file_path.match(SYSTEM_IN_PATH)
1414

@@ -36,16 +36,14 @@ def on_send(node)
3636
if factory_name_array.size > 1
3737
if factory_name_array[0] != @base_file_name
3838
add_offense(
39-
node,
40-
location: :expression,
39+
node.loc.expression,
4140
message: "Factory name uses incorrect prefix, should be '#{@base_file_name}__#{factory_name_array[1]}'."
4241
)
4342
end
4443

4544
elsif (factory_name_body != @base_file_name_body) || (factory_name_last_word.pluralize != @base_file_name_last_word)
4645
add_offense(
47-
node,
48-
location: :expression,
46+
node.loc.expression,
4947
message: "Factory should be in own file or be named the singular form of the file name. OR group closely related factories in the same file and prefix their names with '#{@base_file_name}__'."
5048
)
5149
end

lib/rubocop/cop/root_cops/job_has_queue.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module RuboCop
22
module Cop
33
module RootCops
4-
class JobHasQueue < Cop
4+
class JobHasQueue < RuboCop::Cop::Base
55
MESSAGE = "Configure the job to run in a specific queue using queue_as, sharded_queue_as or a whitelisted mixin.".freeze
66
MIXIN_ALLOW_LIST = %i[LookupQueueConcern NewBusinessQuoteCreationQueueConcern PricingBackfillQueueConcern RatesQueueConcern MonitoringConcern].freeze
77
QUEUEING_OPTIONS = %i[queue_as sharded_queue_as].freeze
@@ -12,7 +12,7 @@ def on_class(node)
1212

1313
send_descendants = node.descendants.select(&:send_type?)
1414
unless send_descendants.any? { |d| QUEUEING_OPTIONS.include?(d.to_a[1]) || _whitelisted_mixin?(d) }
15-
add_offense(node, location: :expression, message: MESSAGE)
15+
add_offense(node.loc.expression, message: MESSAGE)
1616
end
1717
end
1818

lib/rubocop/cop/root_cops/must_include.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ module RootCops
2020
# include ClaimsJobConcern
2121
# end
2222

23-
class MustInclude < Cop
23+
class MustInclude < RuboCop::Cop::Base
2424
# entirely so i can stub this in the tests
2525
def self.expand_path(filename)
2626
File.expand_path(filename)
2727
end
2828

29-
def investigate(processed_source)
29+
def on_new_investigation
3030
@source_file_path = self.class.expand_path(processed_source.buffer.name)
3131
@module_to_include = module_to_include_for_current_file
3232
@proper_module_is_included = false
3333
@class_node = nil
3434
end
3535

36-
def investigate_post_walk(_processed_source)
36+
def on_investigation_end
3737
if search_for_inclusion? && !@proper_module_is_included
38-
add_offense(@class_node, location: :expression, message: "Classes in this directory must include #{@module_to_include} module")
38+
add_offense(@class_node.loc.expression, message: "Classes in this directory must include #{@module_to_include} module")
3939
end
4040
end
4141

lib/rubocop/cop/root_cops/must_inherit.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ module RootCops
2525
# - ResqueJob
2626
# - ShoryukenJob
2727

28-
class MustInherit < Cop
28+
class MustInherit < RuboCop::Cop::Base
2929
# entirely so i can stub this in the tests
3030
def self.expand_path(filename)
3131
File.expand_path(filename)
3232
end
3333

34-
def investigate(processed_source)
34+
def on_new_investigation
3535
@source_file_path = self.class.expand_path(processed_source.buffer.name)
3636
end
3737

@@ -41,7 +41,7 @@ def on_class(node)
4141
class_name = node.identifier.const_name
4242
superclass_name = node.parent_class&.const_name
4343
unless class_name_match?(class_name, superclass_name, class_options)
44-
add_offense(node, location: :expression, message: "Classes in this directory must inherit from #{class_options_to_s(class_options)}")
44+
add_offense(node.loc.expression, message: "Classes in this directory must inherit from #{class_options_to_s(class_options)}")
4545
end
4646
end
4747

0 commit comments

Comments
 (0)