Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump rubocop to 1.59.0 #1600

Merged
merged 1 commit into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Metrics/MethodLength:
Metrics/ModuleLength:
Enabled: true
Exclude:
- lib/shoulda/matchers/rails_shim.rb
- spec/**/*
Metrics/ParameterLists:
CountKeywordArgs: false
Expand Down
24 changes: 14 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,27 @@ GEM
fssm (0.2.10)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.6.3)
json (2.7.1)
language_server-protocol (3.17.0.3)
method_source (1.0.0)
minitest (5.16.3)
parallel (1.23.0)
parser (3.2.2.1)
parallel (1.24.0)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
racc (1.7.3)
rack (3.0.0)
rainbow (3.1.1)
rake (13.0.1)
redcarpet (3.5.0)
regexp_parser (2.8.0)
rexml (3.2.5)
regexp_parser (2.8.3)
rexml (3.2.6)
rouge (3.22.0)
rspec (3.12.0)
rspec-core (~> 3.12.0)
Expand All @@ -50,17 +53,18 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.52.0)
rubocop (1.59.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.0.0)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-packaging (0.5.2)
rubocop (>= 1.33, < 2.0)
Expand All @@ -72,7 +76,7 @@ GEM
thor (1.2.2)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
unicode-display_width (2.5.0)
warnings_logger (0.1.1)
yard (0.9.25)
zeus (0.15.14)
Expand Down
14 changes: 5 additions & 9 deletions lib/shoulda/matchers/active_record/association_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1299,10 +1299,7 @@ def class_name_correct?
end

def join_table_correct?
if (
macro != :has_and_belongs_to_many ||
join_table_matcher.matches?(@subject)
)
if macro != :has_and_belongs_to_many || join_table_matcher.matches?(@subject)
true
else
@missing = join_table_matcher.failure_message
Expand Down Expand Up @@ -1457,11 +1454,10 @@ def actual_foreign_key
end

def foreign_key_reflection
if (
[:has_one, :has_many].include?(macro) &&
reflection.options.include?(:inverse_of) &&
reflection.options[:inverse_of] != false
)
if [:has_one, :has_many].include?(macro) &&
reflection.options.include?(:inverse_of) &&
reflection.options[:inverse_of] != false

associated_class.reflect_on_association(
reflection.options[:inverse_of],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def description
private

def readonly_attributes
@_readonly_attributes ||= (@subject.class.readonly_attributes || [])
@_readonly_attributes ||= @subject.class.readonly_attributes || []
end

def class_name
Expand Down
8 changes: 2 additions & 6 deletions lib/shoulda/matchers/doublespeak/double_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ def register_proxy(method_name)
end

def activate
doubles_by_method_name.each do |_method_name, double|
double.activate
end
doubles_by_method_name.each_value(&:activate)
end

def deactivate
doubles_by_method_name.each do |_method_name, double|
double.deactivate
end
doubles_by_method_name.each_value(&:deactivate)
end

def calls_by_method_name
Expand Down
8 changes: 2 additions & 6 deletions lib/shoulda/matchers/doublespeak/world.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,11 @@ def doubles_activated?
private

def activate
double_collections_by_class.each do |_klass, double_collection|
double_collection.activate
end
double_collections_by_class.each_value(&:activate)
end

def deactivate
double_collections_by_class.each do |_klass, double_collection|
double_collection.deactivate
end
double_collections_by_class.each_value(&:deactivate)
end

def double_collections_by_class
Expand Down
14 changes: 6 additions & 8 deletions lib/shoulda/matchers/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@ module Util
MAXIMUM_LENGTH_OF_VALUE_TO_DISPLAY = 500

def self.deconstantize(path)
if (
defined?(ActiveSupport::Inflector) &&
ActiveSupport::Inflector.respond_to?(:deconstantize)
)
if defined?(ActiveSupport::Inflector) &&
ActiveSupport::Inflector.respond_to?(:deconstantize)

ActiveSupport::Inflector.deconstantize(path)
else
path.to_s[0...(path.to_s.rindex('::') || 0)]
end
end

def self.safe_constantize(camel_cased_word)
if (
defined?(ActiveSupport::Inflector) &&
ActiveSupport::Inflector.respond_to?(:safe_constantize)
)
if defined?(ActiveSupport::Inflector) &&
ActiveSupport::Inflector.respond_to?(:safe_constantize)

ActiveSupport::Inflector.safe_constantize(camel_cased_word)
else
begin
Expand Down
12 changes: 6 additions & 6 deletions spec/support/unit/matchers/match_against.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def does_not_match?(generate_matcher)
end

if matcher_fails_in_positive?
if (
if
negative_matcher.respond_to?(:does_not_match?) &&
!negative_matcher.does_not_match?(object)
)

@failure_message_when_negated = <<-MESSAGE
Expected the matcher to match in the negative, but it failed with this message:

Expand Down Expand Up @@ -116,10 +116,10 @@ def should_be_negated?

def matcher_fails_in_negative?
if does_not_match_in_negative?
if (
if
!expected_message ||
expected_message == negative_matcher.failure_message_when_negated.strip
)

true
else
diff_result = diff(
Expand Down Expand Up @@ -166,10 +166,10 @@ def does_not_match_in_negative?

def matcher_fails_in_positive?
if !positive_matcher.matches?(object)
if (
if
!expected_message ||
expected_message == positive_matcher.failure_message.strip
)

true
else
diff_result = diff(
Expand Down
4 changes: 2 additions & 2 deletions spec/support/unit/model_creation_strategies/active_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ def attribute(name)

name = name.to_sym

if (
if
attribute_names.include?(name) &&
attributes_module.instance_methods.include?(name)
)

attributes_module.module_eval do
remove_method(name)
remove_method("#{name}=")
Expand Down
4 changes: 2 additions & 2 deletions spec/support/unit/model_creators/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ def possibly_override_attribute_writer_method_for(model)
overrides[:changing_values_with],
)

if (
if
respond_to?(:write_attribute) && (
!self.class.respond_to?(:reflect_on_association) ||
!self.class.reflect_on_association(attribute_name)
)
)

write_attribute(attribute_name, new_value)
else
super(new_value)
Expand Down