Skip to content

Commit

Permalink
Merge pull request rubocop#964 from rubocop-hq/enable-new-cops
Browse files Browse the repository at this point in the history
Enable new cops
  • Loading branch information
Darhazer committed Jul 12, 2020
2 parents e14a98c + b6d8c7b commit b948759
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require:
AllCops:
DisplayCopNames: true
TargetRubyVersion: 2.4
NewCops: enable
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AttributeDefinedStatically < Cop

def on_block(node)
attributes = factory_attributes(node) || []
attributes = [attributes] unless attributes.is_a?(Array)
attributes = [attributes] unless attributes.is_a?(Array) # rubocop:disable Style/ArrayCoercion, Lint/RedundantCopDisableDirective

attributes.each do |attribute|
next unless offensive_receiver?(attribute.receiver, node)
Expand Down
10 changes: 6 additions & 4 deletions lib/rubocop/cop/rspec/implicit_subject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ def on_send(node)

def autocorrect(corrector, node)
replacement = 'expect(subject)'
if node.method_name == :should
case node.method_name
when :should
replacement += '.to'
elsif node.method_name == :should_not
when :should_not
replacement += '.not_to'
end

Expand All @@ -66,9 +67,10 @@ def valid_usage?(node)
end

def allowed_by_style?(example)
if style == :single_line_only
case style
when :single_line_only
example.single_line?
elsif style == :single_statement_only
when :single_statement_only
!example.body.begin_type?
else
false
Expand Down
6 changes: 3 additions & 3 deletions spec/project/changelog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
describe 'link to related issue on github' do
let(:issues) do
entries.map do |entry|
entry.match(/\[(?<number>[#\d]+)\]\((?<url>[^\)]+)\)/)
entry.match(/\[(?<number>[#\d]+)\]\((?<url>[^)]+)\)/)
end.compact
end

Expand Down Expand Up @@ -58,7 +58,7 @@
entries.map do |entry|
entry
.sub(/^\*\s*(?:\[.+?\):\s*)?/, '')
.sub(/\s*\([^\)]+\)$/, '')
.sub(/\s*\([^)]+\)$/, '')
end
end

Expand All @@ -69,7 +69,7 @@
end

it 'ends with a punctuation' do
expect(bodies).to all(match(/[\.\!]$/))
expect(bodies).to all(match(/[.!]$/))
end
end
end
Expand Down

0 comments on commit b948759

Please sign in to comment.