Skip to content

Commit

Permalink
Set false to SafeMultiline for Performance/StartWith and `Perform…
Browse files Browse the repository at this point in the history
…ance/EndWith`

This PR sets false for `SafeMultiline` for `Performance/StartWith` and `Performance/EndWith`
to .rubocop.yml in this rubocop/rubocop repository.
It is because multiline regular expression matching that corresponds to `start_with?` and
`end_with?` are not used in the repository.
  • Loading branch information
koic authored and bbatsov committed Apr 15, 2021
1 parent c65c5bf commit ac29f76
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .rubocop.yml
Expand Up @@ -120,6 +120,12 @@ Performance/CollectionLiteralInLoop:
- 'Rakefile'
- 'spec/**/*.rb'

Performance/EndWith:
SafeMultiline: false

Performance/StartWith:
SafeMultiline: false

RSpec/StubbedMock:
Enabled: false

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/layout/end_of_line.rb
Expand Up @@ -65,7 +65,7 @@ def on_new_investigation

# If there is no LF on the last line, we don't care if there's no CR.
def unimportant_missing_cr?(index, last_line, line)
style == :crlf && index == last_line - 1 && !/\n$/.match?(line)
style == :crlf && index == last_line - 1 && !line.end_with?("\n")
end

def offense_message(line)
Expand Down
3 changes: 2 additions & 1 deletion lib/rubocop/cop/metrics/utils/abc_size_calculator.rb
Expand Up @@ -121,7 +121,8 @@ def simple_assignment?(node)
end

def capturing_variable?(name)
name && !/^_/.match?(name)
# TODO: Remove `Symbol#to_s` after supporting only Ruby >= 2.7.
name && !name.to_s.start_with?('_')
end

def branch?(node)
Expand Down
5 changes: 3 additions & 2 deletions lib/rubocop/cop/style/combinable_loops.rb
Expand Up @@ -75,8 +75,9 @@ def on_for(node)
private

def collection_looping_method?(node)
method_name = node.send_node.method_name
method_name.match?(/^each/) || method_name.match?(/_each$/)
# TODO: Remove `Symbol#to_s` after supporting only Ruby >= 2.7.
method_name = node.send_node.method_name.to_s
method_name.start_with?('each') || method_name.end_with?('_each')
end

def same_collection_looping?(node, sibling)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/style/redundant_self_assignment.rb
Expand Up @@ -66,8 +66,8 @@ def on_lvasgn(node)
alias on_gvasgn on_lvasgn

def on_send(node)
# TODO: replace with #end_with? after supporting only ruby >= 2.7
return unless node.method_name.match?(/=$/)
# TODO: Remove `Symbol#to_s` after supporting only Ruby >= 2.7.
return unless node.method_name.to_s.end_with?('=')
return unless redundant_assignment?(node)

message = format(MSG, method_name: node.first_argument.method_name)
Expand Down

0 comments on commit ac29f76

Please sign in to comment.