Skip to content

Commit

Permalink
Loosen Metrics/MethodLength to 15
Browse files Browse the repository at this point in the history
The default is 10, which seems to be just a bit too low for our code.
  • Loading branch information
bquorning committed Feb 11, 2025
1 parent c8b14c1 commit 2edbf15
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Metrics/BlockLength:
- Rakefile
- '**/*.rake'

Metrics/MethodLength:
Max: 15

Naming/FileName:
Exclude:
- lib/rubocop-rspec.rb
Expand Down
2 changes: 0 additions & 2 deletions lib/rubocop/cop/rspec/change_by_zero.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def on_send(node)

private

# rubocop:disable Metrics/MethodLength
def register_offense(node, change_node)
if compound_expectations?(node)
add_offense(node,
Expand All @@ -115,7 +114,6 @@ def register_offense(node, change_node)
end
end
end
# rubocop:enable Metrics/MethodLength

def compound_expectations?(node)
node.parent.send_type? &&
Expand Down
2 changes: 0 additions & 2 deletions lib/rubocop/cop/rspec/example_wording.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class ExampleWording < Base
} ...) ...)
PATTERN

# rubocop:disable Metrics/MethodLength
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
it_description(node) do |description_node, message|
if message.match?(SHOULD_PREFIX)
Expand All @@ -82,7 +81,6 @@ def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
end
end
end
# rubocop:enable Metrics/MethodLength

private

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/expect_actual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ExpectActual < Base
)
PATTERN

def on_send(node) # rubocop:disable Metrics/MethodLength
def on_send(node)
expect_literal(node) do |actual, send_node, matcher, expected|
next if SKIPPED_MATCHERS.include?(matcher)

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/implicit_expect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ImplicitExpect < Base

ENFORCED_REPLACEMENTS = alternatives.merge(alternatives.invert).freeze

def on_send(node) # rubocop:disable Metrics/MethodLength
def on_send(node)
return unless (source_range = offending_expect(node))

expectation_source = source_range.source
Expand Down
4 changes: 0 additions & 4 deletions lib/rubocop/cop/rspec/implicit_subject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def on_send(node)

private

# rubocop:disable Metrics/MethodLength
def autocorrect(corrector, node)
case node.method_name
when :expect
Expand All @@ -114,7 +113,6 @@ def autocorrect(corrector, node)
# :nocov:
end
end
# rubocop:enable Metrics/MethodLength

def message(_node)
case style
Expand All @@ -125,7 +123,6 @@ def message(_node)
end
end

# rubocop:disable Metrics/MethodLength
def invalid?(node)
case style
when :require_implicit
Expand All @@ -142,7 +139,6 @@ def invalid?(node)
# :nocov:
end
end
# rubocop:enable Metrics/MethodLength

def implicit_subject_in_non_its?(node)
implicit_subject?(node) && !its?(node)
Expand Down
6 changes: 0 additions & 6 deletions lib/rubocop/cop/rspec/predicate_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def message_inflected(predicate)
matcher_name: to_predicate_matcher(predicate.method_name))
end

# rubocop:disable Metrics/MethodLength
def to_predicate_matcher(name)
case name = name.to_s
when 'is_a?'
Expand All @@ -86,7 +85,6 @@ def to_predicate_matcher(name)
"be_#{name[0..-2]}"
end
end
# rubocop:enable Metrics/MethodLength

def remove_predicate(corrector, predicate)
range = predicate.loc.dot.with(
Expand All @@ -110,7 +108,6 @@ def rewrite_matcher(corrector, predicate, matcher)
)
end

# rubocop:disable Metrics/MethodLength
def true?(to_symbol, matcher)
result = case matcher.method_name
when :be, :eq, :eql, :equal
Expand All @@ -126,7 +123,6 @@ def true?(to_symbol, matcher)
end
to_symbol == :to ? result : !result
end
# rubocop:enable Metrics/MethodLength
end

# A helper for `explicit` style
Expand Down Expand Up @@ -245,7 +241,6 @@ def move_predicate(corrector, actual, matcher, block_child)
corrector.insert_after(actual, ".#{predicate}" + args + block)
end

# rubocop:disable Metrics/MethodLength
def to_predicate_method(matcher)
case matcher = matcher.to_s
when 'be_a', 'be_an', 'be_a_kind_of', 'a_kind_of', 'be_kind_of'
Expand All @@ -262,7 +257,6 @@ def to_predicate_method(matcher)
"#{matcher[/\Abe_(.+)/, 1]}?"
end
end
# rubocop:enable Metrics/MethodLength

def replacement_matcher(node)
case [cop_config['Strict'], node.method?(:to)]
Expand Down
2 changes: 0 additions & 2 deletions lib/rubocop/rspec/wording.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def initialize(text, ignore:, replace:)
@replacements = replace
end

# rubocop:disable Metrics/MethodLength
def rewrite
case text
when SHOULDNT_BE_PREFIX
Expand All @@ -32,7 +31,6 @@ def rewrite
remove_should_and_pluralize
end
end
# rubocop:enable Metrics/MethodLength

private

Expand Down

0 comments on commit 2edbf15

Please sign in to comment.