Skip to content

Commit b6d8c7b

Browse files
author
Maxim Krizhanovski
committed
Enable new cops
1 parent 8ffc33d commit b6d8c7b

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require:
66
AllCops:
77
DisplayCopNames: true
88
TargetRubyVersion: 2.4
9+
NewCops: enable
910
Exclude:
1011
- 'vendor/**/*'
1112
- 'spec/fixtures/**/*'

lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class AttributeDefinedStatically < Cop
3939

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

4444
attributes.each do |attribute|
4545
next unless offensive_receiver?(attribute.receiver, node)

lib/rubocop/cop/rspec/implicit_subject.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ def on_send(node)
4949

5050
def autocorrect(corrector, node)
5151
replacement = 'expect(subject)'
52-
if node.method_name == :should
52+
case node.method_name
53+
when :should
5354
replacement += '.to'
54-
elsif node.method_name == :should_not
55+
when :should_not
5556
replacement += '.not_to'
5657
end
5758

@@ -66,9 +67,10 @@ def valid_usage?(node)
6667
end
6768

6869
def allowed_by_style?(example)
69-
if style == :single_line_only
70+
case style
71+
when :single_line_only
7072
example.single_line?
71-
elsif style == :single_statement_only
73+
when :single_statement_only
7274
!example.body.begin_type?
7375
else
7476
false

spec/project/changelog_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
describe 'link to related issue on github' do
2727
let(:issues) do
2828
entries.map do |entry|
29-
entry.match(/\[(?<number>[#\d]+)\]\((?<url>[^\)]+)\)/)
29+
entry.match(/\[(?<number>[#\d]+)\]\((?<url>[^)]+)\)/)
3030
end.compact
3131
end
3232

@@ -58,7 +58,7 @@
5858
entries.map do |entry|
5959
entry
6060
.sub(/^\*\s*(?:\[.+?\):\s*)?/, '')
61-
.sub(/\s*\([^\)]+\)$/, '')
61+
.sub(/\s*\([^)]+\)$/, '')
6262
end
6363
end
6464

@@ -69,7 +69,7 @@
6969
end
7070

7171
it 'ends with a punctuation' do
72-
expect(bodies).to all(match(/[\.\!]$/))
72+
expect(bodies).to all(match(/[.!]$/))
7373
end
7474
end
7575
end

0 commit comments

Comments
 (0)