rubocop 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubocop might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +3 -1
- data/CHANGELOG.md +44 -0
- data/CONTRIBUTING.md +40 -8
- data/Gemfile +6 -0
- data/README.md +65 -20
- data/Rakefile +0 -1
- data/config/default.yml +15 -3
- data/config/enabled.yml +143 -109
- data/lib/rubocop.rb +45 -26
- data/lib/rubocop/cli.rb +26 -27
- data/lib/rubocop/config.rb +0 -1
- data/lib/rubocop/config_loader.rb +16 -23
- data/lib/rubocop/cop/commissioner.rb +2 -7
- data/lib/rubocop/cop/cop.rb +24 -51
- data/lib/rubocop/cop/ignored_node.rb +31 -0
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +50 -0
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +36 -0
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +3 -11
- data/lib/rubocop/cop/lint/block_alignment.rb +6 -20
- data/lib/rubocop/cop/lint/condition_position.rb +52 -0
- data/lib/rubocop/cop/lint/else_layout.rb +57 -0
- data/lib/rubocop/cop/lint/end_alignment.rb +33 -8
- data/lib/rubocop/cop/lint/invalid_character_literal.rb +37 -0
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +2 -4
- data/lib/rubocop/cop/lint/syntax.rb +6 -12
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +25 -0
- data/lib/rubocop/cop/mixin/array_syntax.rb +20 -0
- data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +76 -0
- data/lib/rubocop/cop/mixin/check_assignment.rb +26 -0
- data/lib/rubocop/cop/{check_methods.rb → mixin/check_methods.rb} +0 -0
- data/lib/rubocop/cop/mixin/code_length.rb +33 -0
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +53 -0
- data/lib/rubocop/cop/mixin/configurable_max.rb +19 -0
- data/lib/rubocop/cop/mixin/configurable_naming.rb +45 -0
- data/lib/rubocop/cop/{style → mixin}/if_node.rb +0 -0
- data/lib/rubocop/cop/mixin/if_then_else.rb +23 -0
- data/lib/rubocop/cop/mixin/negative_conditional.rb +24 -0
- data/lib/rubocop/cop/mixin/parser_diagnostic.rb +34 -0
- data/lib/rubocop/cop/mixin/safe_assignment.rb +19 -0
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +32 -0
- data/lib/rubocop/cop/mixin/space_inside.rb +31 -0
- data/lib/rubocop/cop/mixin/statement_modifier.rb +59 -0
- data/lib/rubocop/cop/mixin/string_help.rb +32 -0
- data/lib/rubocop/cop/mixin/surrounding_space.rb +42 -0
- data/lib/rubocop/cop/rails/default_scope.rb +3 -1
- data/lib/rubocop/cop/style/accessor_method_name.rb +4 -12
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +16 -1
- data/lib/rubocop/cop/style/case_indentation.rb +33 -16
- data/lib/rubocop/cop/style/character_literal.rb +10 -0
- data/lib/rubocop/cop/style/dot_position.rb +23 -6
- data/lib/rubocop/cop/style/empty_lines_around_body.rb +5 -5
- data/lib/rubocop/cop/style/favor_unless_over_negated_if.rb +1 -32
- data/lib/rubocop/cop/style/favor_until_over_negated_while.rb +20 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +5 -1
- data/lib/rubocop/cop/style/if_unless_modifier.rb +34 -0
- data/lib/rubocop/cop/style/if_with_semicolon.rb +1 -1
- data/lib/rubocop/cop/style/indentation_consistency.rb +51 -0
- data/lib/rubocop/cop/style/indentation_width.rb +0 -26
- data/lib/rubocop/cop/style/lambda_call.rb +12 -5
- data/lib/rubocop/cop/style/method_def_parentheses.rb +29 -11
- data/lib/rubocop/cop/style/multiline_if_then.rb +4 -9
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +22 -0
- data/lib/rubocop/cop/style/{ternary_operator.rb → nested_ternary_operator.rb} +0 -15
- data/lib/rubocop/cop/style/numeric_literals.rb +30 -2
- data/lib/rubocop/cop/style/one_line_conditional.rb +2 -1
- data/lib/rubocop/cop/style/parameter_lists.rb +7 -3
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +9 -11
- data/lib/rubocop/cop/style/predicate_name.rb +4 -12
- data/lib/rubocop/cop/style/raise_args.rb +19 -11
- data/lib/rubocop/cop/style/regexp_literal.rb +19 -6
- data/lib/rubocop/cop/style/space_after_colon.rb +36 -0
- data/lib/rubocop/cop/style/space_after_comma.rb +16 -0
- data/lib/rubocop/cop/style/space_after_semicolon.rb +16 -0
- data/lib/rubocop/cop/style/space_around_block_braces.rb +38 -38
- data/lib/rubocop/cop/style/space_around_operators.rb +1 -2
- data/lib/rubocop/cop/style/space_inside_hash_literal_braces.rb +6 -2
- data/lib/rubocop/cop/style/string_literals.rb +5 -5
- data/lib/rubocop/cop/style/trailing_comma.rb +94 -0
- data/lib/rubocop/cop/style/unless_else.rb +2 -2
- data/lib/rubocop/cop/style/while_until_modifier.rb +32 -0
- data/lib/rubocop/cop/style/word_array.rb +9 -1
- data/lib/rubocop/cop/util.rb +14 -0
- data/lib/rubocop/cop/variable_inspector.rb +11 -6
- data/lib/rubocop/cop/variable_inspector/scope.rb +4 -3
- data/lib/rubocop/file_inspector.rb +22 -6
- data/lib/rubocop/formatter/clang_style_formatter.rb +1 -1
- data/lib/rubocop/formatter/colorizable.rb +37 -0
- data/lib/rubocop/formatter/disabled_config_formatter.rb +27 -6
- data/lib/rubocop/formatter/progress_formatter.rb +1 -1
- data/lib/rubocop/formatter/simple_text_formatter.rb +9 -5
- data/lib/rubocop/options.rb +19 -4
- data/lib/rubocop/target_finder.rb +4 -0
- data/lib/rubocop/version.rb +1 -1
- data/rubocop-todo.yml +10 -2
- data/rubocop.gemspec +3 -2
- data/spec/project_spec.rb +12 -7
- data/spec/rubocop/cli_spec.rb +262 -99
- data/spec/rubocop/config_loader_spec.rb +5 -5
- data/spec/rubocop/config_spec.rb +3 -3
- data/spec/rubocop/config_store_spec.rb +12 -11
- data/spec/rubocop/cop/commissioner_spec.rb +21 -5
- data/spec/rubocop/cop/cop_spec.rb +1 -1
- data/spec/rubocop/cop/lint/ambiguous_operator_spec.rb +113 -0
- data/spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb +35 -0
- data/spec/rubocop/cop/lint/block_alignment_spec.rb +2 -2
- data/spec/rubocop/cop/lint/condition_position_spec.rb +49 -0
- data/spec/rubocop/cop/lint/else_layout_spec.rb +65 -0
- data/spec/rubocop/cop/lint/end_alignment_spec.rb +41 -1
- data/spec/rubocop/cop/lint/invalid_character_literal_spec.rb +33 -0
- data/spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb +3 -3
- data/spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb +12 -12
- data/spec/rubocop/cop/lint/syntax_spec.rb +2 -2
- data/spec/rubocop/cop/lint/useless_assignment_spec.rb +72 -54
- data/spec/rubocop/cop/lint/useless_else_without_rescue_spec.rb +48 -0
- data/spec/rubocop/cop/offence_spec.rb +1 -1
- data/spec/rubocop/cop/rails/default_scope_spec.rb +6 -0
- data/spec/rubocop/cop/rails/output_spec.rb +2 -1
- data/spec/rubocop/cop/style/align_hash_spec.rb +9 -9
- data/spec/rubocop/cop/style/align_parameters_spec.rb +1 -1
- data/spec/rubocop/cop/style/braces_around_hash_parameters_spec.rb +5 -0
- data/spec/rubocop/cop/style/case_indentation_spec.rb +53 -2
- data/spec/rubocop/cop/style/class_and_module_camel_case_spec.rb +3 -3
- data/spec/rubocop/cop/style/documentation_spec.rb +0 -1
- data/spec/rubocop/cop/style/dot_position_spec.rb +18 -3
- data/spec/rubocop/cop/style/empty_line_between_defs_spec.rb +4 -4
- data/spec/rubocop/cop/style/empty_lines_around_body_spec.rb +13 -0
- data/spec/rubocop/cop/style/favor_unless_over_negated_if_spec.rb +1 -1
- data/spec/rubocop/cop/style/favor_until_over_negated_while_spec.rb +1 -1
- data/spec/rubocop/cop/style/hash_syntax_spec.rb +5 -0
- data/spec/rubocop/cop/style/{favor_modifier_spec.rb → if_unless_modifier_spec.rb} +4 -111
- data/spec/rubocop/cop/style/indentation_consistency_spec.rb +490 -0
- data/spec/rubocop/cop/style/indentation_width_spec.rb +19 -91
- data/spec/rubocop/cop/style/lambda_call_spec.rb +18 -0
- data/spec/rubocop/cop/style/method_called_on_do_end_block_spec.rb +2 -2
- data/spec/rubocop/cop/style/method_def_parentheses_spec.rb +35 -1
- data/spec/rubocop/cop/style/method_length_spec.rb +1 -0
- data/spec/rubocop/cop/style/method_name_spec.rb +27 -5
- data/spec/rubocop/cop/style/multiline_block_chain_spec.rb +4 -4
- data/spec/rubocop/cop/style/multiline_if_then_spec.rb +2 -2
- data/spec/rubocop/cop/style/multiline_ternary_operator_spec.rb +18 -0
- data/spec/rubocop/cop/style/{ternary_operator_spec.rb → nested_ternary_operator_spec.rb} +0 -15
- data/spec/rubocop/cop/style/numeric_literals_spec.rb +18 -1
- data/spec/rubocop/cop/style/one_line_conditional_spec.rb +2 -1
- data/spec/rubocop/cop/style/parameter_lists_spec.rb +1 -0
- data/spec/rubocop/cop/style/parentheses_around_condition_spec.rb +13 -4
- data/spec/rubocop/cop/style/raise_args_spec.rb +22 -0
- data/spec/rubocop/cop/style/redundant_self_spec.rb +4 -4
- data/spec/rubocop/cop/style/regexp_literal_spec.rb +4 -0
- data/spec/rubocop/cop/style/space_after_colon_spec.rb +12 -4
- data/spec/rubocop/cop/style/space_after_method_name_spec.rb +2 -2
- data/spec/rubocop/cop/style/space_around_block_braces_spec.rb +30 -1
- data/spec/rubocop/cop/style/{space_around_equals_in_default_parameter_spec.rb → space_around_equals_in_parameter_default_spec.rb} +0 -0
- data/spec/rubocop/cop/style/space_around_operators_spec.rb +2 -1
- data/spec/rubocop/cop/style/space_inside_hash_literal_braces_spec.rb +20 -3
- data/spec/rubocop/cop/style/string_literals_spec.rb +33 -0
- data/spec/rubocop/cop/style/trailing_comma_spec.rb +200 -0
- data/spec/rubocop/cop/style/variable_name_spec.rb +27 -3
- data/spec/rubocop/cop/style/while_until_modifier_spec.rb +75 -0
- data/spec/rubocop/cop/style/word_array_spec.rb +1 -0
- data/spec/rubocop/cop/team_spec.rb +1 -1
- data/spec/rubocop/cop/variable_inspector/scope_spec.rb +3 -4
- data/spec/rubocop/file_inspector_spec.rb +1 -1
- data/spec/rubocop/formatter/base_formatter_spec.rb +12 -11
- data/spec/rubocop/formatter/colorizable_spec.rb +107 -0
- data/spec/rubocop/formatter/disabled_config_formatter_spec.rb +2 -0
- data/spec/rubocop/formatter/formatter_set_spec.rb +1 -1
- data/spec/rubocop/formatter/json_formatter_spec.rb +4 -3
- data/spec/rubocop/formatter/progress_formatter_spec.rb +2 -2
- data/spec/rubocop/options_spec.rb +3 -1
- data/spec/rubocop/target_finder_spec.rb +13 -11
- data/spec/spec_helper.rb +5 -1
- data/spec/support/shared_examples.rb +2 -2
- data/spec/support/statement_modifier_helper.rb +41 -0
- metadata +88 -30
- data/lib/rubocop/cop/check_assignment.rb +0 -43
- data/lib/rubocop/cop/style/array_syntax.rb +0 -22
- data/lib/rubocop/cop/style/autocorrect_alignment.rb +0 -78
- data/lib/rubocop/cop/style/code_length.rb +0 -35
- data/lib/rubocop/cop/style/configurable_enforced_style.rb +0 -51
- data/lib/rubocop/cop/style/configurable_max.rb +0 -17
- data/lib/rubocop/cop/style/configurable_naming.rb +0 -41
- data/lib/rubocop/cop/style/favor_modifier.rb +0 -118
- data/lib/rubocop/cop/style/if_then_else.rb +0 -27
- data/lib/rubocop/cop/style/space_after_comma_etc.rb +0 -73
- data/lib/rubocop/cop/style/space_inside.rb +0 -33
- data/lib/rubocop/cop/style/string_help.rb +0 -30
- data/lib/rubocop/cop/style/surrounding_space.rb +0 -44
@@ -6,6 +6,9 @@ describe Rubocop::Cop::Lint::EndAlignment, :config do
|
|
6
6
|
subject(:cop) { described_class.new(config) }
|
7
7
|
let(:cop_config) { {} }
|
8
8
|
let(:cop_config) { { 'AlignWith' => 'keyword' } }
|
9
|
+
let(:opposite) do
|
10
|
+
cop_config['AlignWith'] == 'keyword' ? 'variable' : 'keyword'
|
11
|
+
end
|
9
12
|
|
10
13
|
shared_examples 'misaligned' do |alignment_base, arg, end_kw, name|
|
11
14
|
name ||= alignment_base
|
@@ -14,8 +17,9 @@ describe Rubocop::Cop::Lint::EndAlignment, :config do
|
|
14
17
|
end_kw])
|
15
18
|
expect(cop.offences.size).to eq(1)
|
16
19
|
expect(cop.messages.first)
|
17
|
-
.to match(/end at 2, \d is not aligned with #{alignment_base} at 1,/)
|
20
|
+
.to match(/end at 2, \d+ is not aligned with #{alignment_base} at 1,/)
|
18
21
|
expect(cop.highlights.first).to eq('end')
|
22
|
+
expect(cop.config_to_allow_offences).to eq('AlignWith' => opposite)
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
@@ -46,6 +50,26 @@ describe Rubocop::Cop::Lint::EndAlignment, :config do
|
|
46
50
|
include_examples 'aligned', 'while', 'test', 'end'
|
47
51
|
include_examples 'aligned', 'until', 'test', 'end'
|
48
52
|
|
53
|
+
context 'in ruby 2.1 or later' do
|
54
|
+
include_examples 'aligned', 'public def', 'test', 'end'
|
55
|
+
include_examples 'aligned', 'protected def', 'test', 'end'
|
56
|
+
include_examples 'aligned', 'private def', 'test', 'end'
|
57
|
+
include_examples 'aligned', 'module_function def', 'test', 'end'
|
58
|
+
|
59
|
+
include_examples('misaligned',
|
60
|
+
'public def', 'test',
|
61
|
+
' end')
|
62
|
+
include_examples('misaligned',
|
63
|
+
'protected def', 'test',
|
64
|
+
' end')
|
65
|
+
include_examples('misaligned',
|
66
|
+
'private def', 'test',
|
67
|
+
' end')
|
68
|
+
include_examples('misaligned',
|
69
|
+
'module_function def', 'test',
|
70
|
+
' end')
|
71
|
+
end
|
72
|
+
|
49
73
|
it 'can handle ternary if' do
|
50
74
|
inspect_source(cop, 'a = cond ? x : y')
|
51
75
|
expect(cop.offences).to be_empty
|
@@ -56,6 +80,20 @@ describe Rubocop::Cop::Lint::EndAlignment, :config do
|
|
56
80
|
expect(cop.offences).to be_empty
|
57
81
|
end
|
58
82
|
|
83
|
+
it 'registers an offence for correct + opposite' do
|
84
|
+
inspect_source(cop, ['x = if a',
|
85
|
+
' a1',
|
86
|
+
' end',
|
87
|
+
'y = if b',
|
88
|
+
' b1',
|
89
|
+
'end'])
|
90
|
+
expect(cop.offences.size).to eq(1)
|
91
|
+
expect(cop.messages.first)
|
92
|
+
.to eq('end at 6, 0 is not aligned with y = if at 4, 4')
|
93
|
+
expect(cop.highlights.first).to eq('end')
|
94
|
+
expect(cop.config_to_allow_offences).to eq('Enabled' => false)
|
95
|
+
end
|
96
|
+
|
59
97
|
context 'regarding assignment' do
|
60
98
|
context 'when AlignWith is keyword' do
|
61
99
|
include_examples 'misaligned', 'var = if', 'test', 'end'
|
@@ -86,8 +124,10 @@ describe Rubocop::Cop::Lint::EndAlignment, :config do
|
|
86
124
|
include_examples 'misaligned', 'var = until', 'test', ' end.join'
|
87
125
|
|
88
126
|
include_examples 'aligned', '@var = if', 'test', 'end'
|
127
|
+
include_examples 'aligned', '@@var = if', 'test', 'end'
|
89
128
|
include_examples 'aligned', '$var = if', 'test', 'end'
|
90
129
|
include_examples 'aligned', 'CNST = if', 'test', 'end'
|
130
|
+
include_examples 'aligned', 'a, b = if', 'test', 'end'
|
91
131
|
include_examples 'aligned', 'var ||= if', 'test', 'end'
|
92
132
|
include_examples 'aligned', 'var &&= if', 'test', 'end'
|
93
133
|
include_examples 'aligned', 'var += if', 'test', 'end'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Rubocop::Cop::Lint::InvalidCharacterLiteral do
|
6
|
+
subject(:cop) { described_class.new }
|
7
|
+
|
8
|
+
# Is there a way to emit this warning without syntax error?
|
9
|
+
#
|
10
|
+
# $ ruby -w
|
11
|
+
# p(? )
|
12
|
+
# -:1: warning: invalid character syntax; use ?\s
|
13
|
+
# -:1: syntax error, unexpected '?', expecting ')'
|
14
|
+
# p(? )
|
15
|
+
# ^
|
16
|
+
#
|
17
|
+
# https://github.com/ruby/ruby/blob/v2_1_0/parse.y#L7276
|
18
|
+
# https://github.com/whitequark/parser/blob/v2.1.2/lib/parser/lexer.rl#L1660
|
19
|
+
context 'with a non-escaped whitespace character literal ' do
|
20
|
+
let(:source) { 'p(? )' }
|
21
|
+
|
22
|
+
it 'registers an offence' do
|
23
|
+
pending 'Is there a way to emit this warning without syntax errors?'
|
24
|
+
|
25
|
+
inspect_source(cop, source)
|
26
|
+
|
27
|
+
expect(cop.offences.size).to eq(1)
|
28
|
+
expect(cop.offences.first.message)
|
29
|
+
.to eq('Invalid character literal; use ?\s')
|
30
|
+
expect(cop.highlights).to eq([' '])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -8,18 +8,18 @@ describe Rubocop::Cop::Lint::ParenthesesAsGroupedExpression do
|
|
8
8
|
it 'registers an offence for method call with space before the ' +
|
9
9
|
'parenthesis' do
|
10
10
|
inspect_source(cop, ['a.func (x)'])
|
11
|
-
expect(cop.offences).to
|
11
|
+
expect(cop.offences.size).to eq(1)
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'registers an offence for predicate method call with space ' +
|
15
15
|
'before the parenthesis' do
|
16
16
|
inspect_source(cop, ['is? (x)'])
|
17
|
-
expect(cop.offences).to
|
17
|
+
expect(cop.offences.size).to eq(1)
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'registers an offence for math expression' do
|
21
21
|
inspect_source(cop, ['puts (2 + 3) * 4'])
|
22
|
-
expect(cop.offences).to
|
22
|
+
expect(cop.offences.size).to eq(1)
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'accepts a method call without arguments' do
|
@@ -26,7 +26,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
26
26
|
expect(cop.offences.first.line).to eq(4)
|
27
27
|
end
|
28
28
|
|
29
|
-
include_examples 'mimics MRI 2.
|
29
|
+
include_examples 'mimics MRI 2.1'
|
30
30
|
end
|
31
31
|
|
32
32
|
context 'when a splat block argument has same name ' +
|
@@ -50,7 +50,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
50
50
|
expect(cop.offences.first.line).to eq(4)
|
51
51
|
end
|
52
52
|
|
53
|
-
include_examples 'mimics MRI 2.
|
53
|
+
include_examples 'mimics MRI 2.1'
|
54
54
|
end
|
55
55
|
|
56
56
|
context 'when a block block argument has same name ' +
|
@@ -76,7 +76,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
76
76
|
expect(cop.offences.first.line).to eq(4)
|
77
77
|
end
|
78
78
|
|
79
|
-
include_examples 'mimics MRI 2.
|
79
|
+
include_examples 'mimics MRI 2.1'
|
80
80
|
end
|
81
81
|
|
82
82
|
context 'when a block local variable has same name ' +
|
@@ -101,7 +101,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
101
101
|
expect(cop.offences.first.line).to eq(4)
|
102
102
|
end
|
103
103
|
|
104
|
-
include_examples 'mimics MRI 2.
|
104
|
+
include_examples 'mimics MRI 2.1', 'shadowing'
|
105
105
|
end
|
106
106
|
|
107
107
|
context 'when a block argument has different name ' +
|
@@ -118,7 +118,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
include_examples 'accepts'
|
121
|
-
include_examples 'mimics MRI 2.
|
121
|
+
include_examples 'mimics MRI 2.1'
|
122
122
|
end
|
123
123
|
|
124
124
|
context 'when an outer scope variable is reassigned in a block' do
|
@@ -135,7 +135,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
135
135
|
end
|
136
136
|
|
137
137
|
include_examples 'accepts'
|
138
|
-
include_examples 'mimics MRI 2.
|
138
|
+
include_examples 'mimics MRI 2.1'
|
139
139
|
end
|
140
140
|
|
141
141
|
context 'when an outer scope variable is referenced in a block' do
|
@@ -152,7 +152,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
152
152
|
end
|
153
153
|
|
154
154
|
include_examples 'accepts'
|
155
|
-
include_examples 'mimics MRI 2.
|
155
|
+
include_examples 'mimics MRI 2.1'
|
156
156
|
end
|
157
157
|
|
158
158
|
context 'when multiple block arguments have same name "_"' do
|
@@ -166,7 +166,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
166
166
|
end
|
167
167
|
|
168
168
|
include_examples 'accepts'
|
169
|
-
include_examples 'mimics MRI 2.
|
169
|
+
include_examples 'mimics MRI 2.1'
|
170
170
|
end
|
171
171
|
|
172
172
|
context 'when multiple block arguments have ' +
|
@@ -181,7 +181,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
181
181
|
end
|
182
182
|
|
183
183
|
include_examples 'accepts' unless RUBY_VERSION < '2.0'
|
184
|
-
include_examples 'mimics MRI 2.
|
184
|
+
include_examples 'mimics MRI 2.1'
|
185
185
|
end
|
186
186
|
|
187
187
|
context 'when a block argument has same name "_" ' +
|
@@ -198,7 +198,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
198
198
|
end
|
199
199
|
|
200
200
|
include_examples 'accepts'
|
201
|
-
include_examples 'mimics MRI 2.
|
201
|
+
include_examples 'mimics MRI 2.1'
|
202
202
|
end
|
203
203
|
|
204
204
|
context 'when a block argument has a same name starts with "_" ' +
|
@@ -215,7 +215,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
215
215
|
end
|
216
216
|
|
217
217
|
include_examples 'accepts'
|
218
|
-
include_examples 'mimics MRI 2.
|
218
|
+
include_examples 'mimics MRI 2.1'
|
219
219
|
end
|
220
220
|
|
221
221
|
context 'when a method argument has same name ' +
|
@@ -232,6 +232,6 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
|
|
232
232
|
end
|
233
233
|
|
234
234
|
include_examples 'accepts'
|
235
|
-
include_examples 'mimics MRI 2.
|
235
|
+
include_examples 'mimics MRI 2.1'
|
236
236
|
end
|
237
237
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Rubocop::Cop::Lint::Syntax do
|
6
|
-
describe '.
|
6
|
+
describe '.offence_from_diagnostic' do
|
7
7
|
subject(:offence) { described_class.offence_from_diagnostic(diagnostic) }
|
8
8
|
let(:diagnostic) { Parser::Diagnostic.new(level, reason, args, location) }
|
9
9
|
let(:level) { :warning }
|
@@ -27,7 +27,7 @@ describe Rubocop::Cop::Lint::Syntax do
|
|
27
27
|
expect(offence.location).to eq(location)
|
28
28
|
end
|
29
29
|
|
30
|
-
it 'sets
|
30
|
+
it 'sets Syntax as a cop name' do
|
31
31
|
expect(offence.cop_name).to eq('Syntax')
|
32
32
|
end
|
33
33
|
end
|
@@ -29,7 +29,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
29
29
|
expect(cop.highlights).to eq(['foo'])
|
30
30
|
end
|
31
31
|
|
32
|
-
include_examples 'mimics MRI 2.
|
32
|
+
include_examples 'mimics MRI 2.1'
|
33
33
|
end
|
34
34
|
|
35
35
|
context 'when a variable is assigned and unreferenced ' +
|
@@ -57,7 +57,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
57
57
|
expect(cop.highlights).to eq(['foo'])
|
58
58
|
end
|
59
59
|
|
60
|
-
include_examples 'mimics MRI 2.
|
60
|
+
include_examples 'mimics MRI 2.1'
|
61
61
|
end
|
62
62
|
|
63
63
|
context 'when a variable is assigned and unreferenced ' +
|
@@ -86,7 +86,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
86
86
|
expect(cop.highlights).to eq(['foo'])
|
87
87
|
end
|
88
88
|
|
89
|
-
include_examples 'mimics MRI 2.
|
89
|
+
include_examples 'mimics MRI 2.1'
|
90
90
|
end
|
91
91
|
|
92
92
|
context 'when a variable is assigned and unreferenced in a class' do
|
@@ -113,7 +113,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
113
113
|
expect(cop.highlights).to eq(['foo'])
|
114
114
|
end
|
115
115
|
|
116
|
-
include_examples 'mimics MRI 2.
|
116
|
+
include_examples 'mimics MRI 2.1'
|
117
117
|
end
|
118
118
|
|
119
119
|
context 'when a variable is assigned and unreferenced in a class ' +
|
@@ -142,7 +142,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
142
142
|
expect(cop.highlights).to eq(['foo'])
|
143
143
|
end
|
144
144
|
|
145
|
-
include_examples 'mimics MRI 2.
|
145
|
+
include_examples 'mimics MRI 2.1'
|
146
146
|
end
|
147
147
|
|
148
148
|
context 'when a variable is assigned and unreferenced ' +
|
@@ -171,7 +171,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
171
171
|
expect(cop.highlights).to eq(['foo'])
|
172
172
|
end
|
173
173
|
|
174
|
-
include_examples 'mimics MRI 2.
|
174
|
+
include_examples 'mimics MRI 2.1'
|
175
175
|
end
|
176
176
|
|
177
177
|
context 'when a variable is assigned and unreferenced in a module' do
|
@@ -198,7 +198,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
198
198
|
expect(cop.highlights).to eq(['foo'])
|
199
199
|
end
|
200
200
|
|
201
|
-
include_examples 'mimics MRI 2.
|
201
|
+
include_examples 'mimics MRI 2.1'
|
202
202
|
end
|
203
203
|
|
204
204
|
context 'when a variable is assigned and unreferenced in top level' do
|
@@ -219,7 +219,25 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
219
219
|
expect(cop.highlights).to eq(['foo'])
|
220
220
|
end
|
221
221
|
|
222
|
-
include_examples 'mimics MRI 2.
|
222
|
+
include_examples 'mimics MRI 2.1'
|
223
|
+
end
|
224
|
+
|
225
|
+
context 'when a variable is assigned with operator assignment ' +
|
226
|
+
'in top level' do
|
227
|
+
let(:source) do
|
228
|
+
[
|
229
|
+
'foo ||= 1'
|
230
|
+
]
|
231
|
+
end
|
232
|
+
|
233
|
+
it 'registers an offence' do
|
234
|
+
inspect_source(cop, source)
|
235
|
+
expect(cop.offences.size).to eq(1)
|
236
|
+
expect(cop.offences.first.message)
|
237
|
+
.to eq('Useless assignment to variable - foo. Use just operator ||.')
|
238
|
+
expect(cop.offences.first.line).to eq(1)
|
239
|
+
expect(cop.highlights).to eq(['foo'])
|
240
|
+
end
|
223
241
|
end
|
224
242
|
|
225
243
|
context 'when a variable is assigned multiple times ' +
|
@@ -316,7 +334,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
316
334
|
end
|
317
335
|
|
318
336
|
include_examples 'accepts'
|
319
|
-
include_examples 'mimics MRI 2.
|
337
|
+
include_examples 'mimics MRI 2.1'
|
320
338
|
end
|
321
339
|
|
322
340
|
context 'when a referenced variable is reassigned in a block' do
|
@@ -333,7 +351,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
333
351
|
end
|
334
352
|
|
335
353
|
include_examples 'accepts'
|
336
|
-
include_examples 'mimics MRI 2.
|
354
|
+
include_examples 'mimics MRI 2.1'
|
337
355
|
end
|
338
356
|
|
339
357
|
context 'when a block local variable is declared but not assigned' do
|
@@ -353,7 +371,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
353
371
|
expect(cop.highlights).to eq(['foo'])
|
354
372
|
end
|
355
373
|
|
356
|
-
include_examples 'mimics MRI 2.
|
374
|
+
include_examples 'mimics MRI 2.1'
|
357
375
|
end
|
358
376
|
|
359
377
|
context 'when a block local variable is assigned and unreferenced' do
|
@@ -395,7 +413,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
395
413
|
expect(cop.highlights).to eq(['foo'])
|
396
414
|
end
|
397
415
|
|
398
|
-
include_examples 'mimics MRI 2.
|
416
|
+
include_examples 'mimics MRI 2.1'
|
399
417
|
end
|
400
418
|
|
401
419
|
context 'when a variable is reassigned at the end of loop body ' +
|
@@ -417,7 +435,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
417
435
|
end
|
418
436
|
|
419
437
|
include_examples 'accepts'
|
420
|
-
include_examples 'mimics MRI 2.
|
438
|
+
include_examples 'mimics MRI 2.1'
|
421
439
|
end
|
422
440
|
|
423
441
|
context 'when a variable is reassigned at the end of loop body ' +
|
@@ -439,7 +457,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
439
457
|
end
|
440
458
|
|
441
459
|
include_examples 'accepts'
|
442
|
-
include_examples 'mimics MRI 2.
|
460
|
+
include_examples 'mimics MRI 2.1'
|
443
461
|
end
|
444
462
|
|
445
463
|
context "when a variable is reassigned in loop body but won't " +
|
@@ -540,7 +558,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
540
558
|
expect(cop.highlights).to eq(['foo'])
|
541
559
|
end
|
542
560
|
|
543
|
-
include_examples 'mimics MRI 2.
|
561
|
+
include_examples 'mimics MRI 2.1'
|
544
562
|
end
|
545
563
|
|
546
564
|
context 'when a unreferenced variable is reassigned in same branch ' +
|
@@ -585,7 +603,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
585
603
|
end
|
586
604
|
|
587
605
|
include_examples 'accepts'
|
588
|
-
include_examples 'mimics MRI 2.
|
606
|
+
include_examples 'mimics MRI 2.1'
|
589
607
|
end
|
590
608
|
|
591
609
|
context 'when a variable is assigned in each branch of if ' +
|
@@ -605,7 +623,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
605
623
|
end
|
606
624
|
|
607
625
|
include_examples 'accepts'
|
608
|
-
include_examples 'mimics MRI 2.
|
626
|
+
include_examples 'mimics MRI 2.1'
|
609
627
|
end
|
610
628
|
|
611
629
|
context 'when a variable is reassigned in single branch if ' +
|
@@ -671,7 +689,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
671
689
|
end
|
672
690
|
|
673
691
|
include_examples 'accepts'
|
674
|
-
include_examples 'mimics MRI 2.
|
692
|
+
include_examples 'mimics MRI 2.1'
|
675
693
|
end
|
676
694
|
|
677
695
|
context 'when a variable is assigned in branch of modifier if ' +
|
@@ -707,7 +725,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
707
725
|
end
|
708
726
|
|
709
727
|
include_examples 'accepts'
|
710
|
-
include_examples 'mimics MRI 2.
|
728
|
+
include_examples 'mimics MRI 2.1'
|
711
729
|
end
|
712
730
|
|
713
731
|
context 'when a unreferenced variable is reassigned ' +
|
@@ -745,7 +763,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
745
763
|
end
|
746
764
|
|
747
765
|
include_examples 'accepts'
|
748
|
-
include_examples 'mimics MRI 2.
|
766
|
+
include_examples 'mimics MRI 2.1'
|
749
767
|
end
|
750
768
|
|
751
769
|
context 'when a variable is reassigned ' +
|
@@ -761,7 +779,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
761
779
|
end
|
762
780
|
|
763
781
|
include_examples 'accepts'
|
764
|
-
include_examples 'mimics MRI 2.
|
782
|
+
include_examples 'mimics MRI 2.1'
|
765
783
|
end
|
766
784
|
|
767
785
|
context 'when a variable is reassigned ' +
|
@@ -777,7 +795,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
777
795
|
end
|
778
796
|
|
779
797
|
include_examples 'accepts'
|
780
|
-
include_examples 'mimics MRI 2.
|
798
|
+
include_examples 'mimics MRI 2.1'
|
781
799
|
end
|
782
800
|
|
783
801
|
context 'when a variable is reassigned ' +
|
@@ -793,7 +811,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
793
811
|
end
|
794
812
|
|
795
813
|
include_examples 'accepts'
|
796
|
-
include_examples 'mimics MRI 2.
|
814
|
+
include_examples 'mimics MRI 2.1'
|
797
815
|
end
|
798
816
|
|
799
817
|
context 'when a variable is reassigned with binary operator ' +
|
@@ -830,7 +848,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
830
848
|
end
|
831
849
|
|
832
850
|
include_examples 'accepts'
|
833
|
-
include_examples 'mimics MRI 2.
|
851
|
+
include_examples 'mimics MRI 2.1'
|
834
852
|
end
|
835
853
|
|
836
854
|
context 'when a variable is assigned with ||= ' +
|
@@ -900,7 +918,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
900
918
|
expect(cop.highlights).to eq(['bar'])
|
901
919
|
end
|
902
920
|
|
903
|
-
include_examples 'mimics MRI 2.
|
921
|
+
include_examples 'mimics MRI 2.1'
|
904
922
|
end
|
905
923
|
|
906
924
|
context 'when a variable is reassigned with multiple assignment ' +
|
@@ -916,7 +934,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
916
934
|
end
|
917
935
|
|
918
936
|
include_examples 'accepts'
|
919
|
-
include_examples 'mimics MRI 2.
|
937
|
+
include_examples 'mimics MRI 2.1'
|
920
938
|
end
|
921
939
|
|
922
940
|
context 'when a variable is assigned in loop body ' +
|
@@ -931,7 +949,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
931
949
|
end
|
932
950
|
|
933
951
|
include_examples 'accepts'
|
934
|
-
include_examples 'mimics MRI 2.
|
952
|
+
include_examples 'mimics MRI 2.1'
|
935
953
|
end
|
936
954
|
|
937
955
|
context 'when a variable is assigned in loop body ' +
|
@@ -946,7 +964,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
946
964
|
end
|
947
965
|
|
948
966
|
include_examples 'accepts'
|
949
|
-
include_examples 'mimics MRI 2.
|
967
|
+
include_examples 'mimics MRI 2.1'
|
950
968
|
end
|
951
969
|
|
952
970
|
context 'when a variable is assigned ' +
|
@@ -971,7 +989,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
971
989
|
expect(cop.highlights).to eq(['foo'])
|
972
990
|
end
|
973
991
|
|
974
|
-
include_examples 'mimics MRI 2.
|
992
|
+
include_examples 'mimics MRI 2.1'
|
975
993
|
end
|
976
994
|
|
977
995
|
context 'when a variable is assigned in main body of begin, rescue ' +
|
@@ -994,7 +1012,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
994
1012
|
end
|
995
1013
|
|
996
1014
|
include_examples 'accepts'
|
997
|
-
include_examples 'mimics MRI 2.
|
1015
|
+
include_examples 'mimics MRI 2.1'
|
998
1016
|
end
|
999
1017
|
|
1000
1018
|
context 'when a variable is reassigned multiple times ' +
|
@@ -1016,7 +1034,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1016
1034
|
end
|
1017
1035
|
|
1018
1036
|
include_examples 'accepts'
|
1019
|
-
include_examples 'mimics MRI 2.
|
1037
|
+
include_examples 'mimics MRI 2.1'
|
1020
1038
|
end
|
1021
1039
|
|
1022
1040
|
context 'when a variable is reassigned multiple times ' +
|
@@ -1036,7 +1054,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1036
1054
|
end
|
1037
1055
|
|
1038
1056
|
include_examples 'accepts'
|
1039
|
-
include_examples 'mimics MRI 2.
|
1057
|
+
include_examples 'mimics MRI 2.1'
|
1040
1058
|
end
|
1041
1059
|
|
1042
1060
|
context 'when a variable is reassigned multiple times ' +
|
@@ -1056,7 +1074,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1056
1074
|
end
|
1057
1075
|
|
1058
1076
|
include_examples 'accepts'
|
1059
|
-
include_examples 'mimics MRI 2.
|
1077
|
+
include_examples 'mimics MRI 2.1'
|
1060
1078
|
end
|
1061
1079
|
|
1062
1080
|
context 'when a variable is reassigned multiple times in rescue ' +
|
@@ -1159,7 +1177,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1159
1177
|
end
|
1160
1178
|
|
1161
1179
|
include_examples 'accepts'
|
1162
|
-
include_examples 'mimics MRI 2.
|
1180
|
+
include_examples 'mimics MRI 2.1'
|
1163
1181
|
end
|
1164
1182
|
|
1165
1183
|
context 'when a variable is assigned ' +
|
@@ -1207,7 +1225,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1207
1225
|
end
|
1208
1226
|
|
1209
1227
|
include_examples 'accepts'
|
1210
|
-
include_examples 'mimics MRI 2.
|
1228
|
+
include_examples 'mimics MRI 2.1'
|
1211
1229
|
end
|
1212
1230
|
|
1213
1231
|
context 'when a local variable is unreferenced ' +
|
@@ -1230,7 +1248,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1230
1248
|
expect(cop.highlights).to eq(['foo'])
|
1231
1249
|
end
|
1232
1250
|
|
1233
|
-
include_examples 'mimics MRI 2.
|
1251
|
+
include_examples 'mimics MRI 2.1'
|
1234
1252
|
end
|
1235
1253
|
|
1236
1254
|
context 'when a method argument is reassigned ' +
|
@@ -1257,7 +1275,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1257
1275
|
context 'when a named capture is unreferenced in top level' do
|
1258
1276
|
let(:source) do
|
1259
1277
|
[
|
1260
|
-
"/(?<foo>\w+)/ =~ 'FOO'"
|
1278
|
+
"/(?<foo>\w+)/ =~ 'FOO'"
|
1261
1279
|
]
|
1262
1280
|
end
|
1263
1281
|
|
@@ -1269,7 +1287,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1269
1287
|
expect(cop.offences.first.line).to eq(1)
|
1270
1288
|
end
|
1271
1289
|
|
1272
|
-
include_examples 'mimics MRI 2.
|
1290
|
+
include_examples 'mimics MRI 2.1'
|
1273
1291
|
end
|
1274
1292
|
|
1275
1293
|
context 'when a named capture is unreferenced ' +
|
@@ -1308,7 +1326,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1308
1326
|
end
|
1309
1327
|
|
1310
1328
|
include_examples 'accepts'
|
1311
|
-
include_examples 'mimics MRI 2.
|
1329
|
+
include_examples 'mimics MRI 2.1'
|
1312
1330
|
end
|
1313
1331
|
|
1314
1332
|
context 'when a variable is referenced ' +
|
@@ -1340,7 +1358,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1340
1358
|
end
|
1341
1359
|
|
1342
1360
|
include_examples 'accepts'
|
1343
|
-
include_examples 'mimics MRI 2.
|
1361
|
+
include_examples 'mimics MRI 2.1'
|
1344
1362
|
end
|
1345
1363
|
|
1346
1364
|
context 'when a variable is shadowed by a block argument ' +
|
@@ -1365,7 +1383,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1365
1383
|
expect(cop.highlights).to eq(['foo'])
|
1366
1384
|
end
|
1367
1385
|
|
1368
|
-
include_examples 'mimics MRI 2.
|
1386
|
+
include_examples 'mimics MRI 2.1', 'unused variable'
|
1369
1387
|
end
|
1370
1388
|
|
1371
1389
|
context 'when a variable is not used and the name starts with _' do
|
@@ -1380,7 +1398,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1380
1398
|
end
|
1381
1399
|
|
1382
1400
|
include_examples 'accepts'
|
1383
|
-
include_examples 'mimics MRI 2.
|
1401
|
+
include_examples 'mimics MRI 2.1'
|
1384
1402
|
end
|
1385
1403
|
|
1386
1404
|
context 'when a method argument is not used' do
|
@@ -1392,7 +1410,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1392
1410
|
end
|
1393
1411
|
|
1394
1412
|
include_examples 'accepts'
|
1395
|
-
include_examples 'mimics MRI 2.
|
1413
|
+
include_examples 'mimics MRI 2.1'
|
1396
1414
|
end
|
1397
1415
|
|
1398
1416
|
context 'when an optional method argument is not used' do
|
@@ -1404,7 +1422,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1404
1422
|
end
|
1405
1423
|
|
1406
1424
|
include_examples 'accepts'
|
1407
|
-
include_examples 'mimics MRI 2.
|
1425
|
+
include_examples 'mimics MRI 2.1'
|
1408
1426
|
end
|
1409
1427
|
|
1410
1428
|
context 'when a block method argument is not used' do
|
@@ -1416,7 +1434,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1416
1434
|
end
|
1417
1435
|
|
1418
1436
|
include_examples 'accepts'
|
1419
|
-
include_examples 'mimics MRI 2.
|
1437
|
+
include_examples 'mimics MRI 2.1'
|
1420
1438
|
end
|
1421
1439
|
|
1422
1440
|
context 'when a splat method argument is not used' do
|
@@ -1428,7 +1446,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1428
1446
|
end
|
1429
1447
|
|
1430
1448
|
include_examples 'accepts'
|
1431
|
-
include_examples 'mimics MRI 2.
|
1449
|
+
include_examples 'mimics MRI 2.1'
|
1432
1450
|
end
|
1433
1451
|
|
1434
1452
|
context 'when a optional keyword method argument is not used' do
|
@@ -1440,7 +1458,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1440
1458
|
end
|
1441
1459
|
|
1442
1460
|
include_examples 'accepts' unless RUBY_VERSION < '2.0'
|
1443
|
-
include_examples 'mimics MRI 2.
|
1461
|
+
include_examples 'mimics MRI 2.1'
|
1444
1462
|
end
|
1445
1463
|
|
1446
1464
|
context 'when a keyword splat method argument is used' do
|
@@ -1453,7 +1471,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1453
1471
|
end
|
1454
1472
|
|
1455
1473
|
include_examples 'accepts' unless RUBY_VERSION < '2.0'
|
1456
|
-
include_examples 'mimics MRI 2.
|
1474
|
+
include_examples 'mimics MRI 2.1'
|
1457
1475
|
end
|
1458
1476
|
|
1459
1477
|
context 'when a keyword splat method argument is not used' do
|
@@ -1465,7 +1483,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1465
1483
|
end
|
1466
1484
|
|
1467
1485
|
include_examples 'accepts' unless RUBY_VERSION < '2.0'
|
1468
|
-
include_examples 'mimics MRI 2.
|
1486
|
+
include_examples 'mimics MRI 2.1'
|
1469
1487
|
end
|
1470
1488
|
|
1471
1489
|
context 'when a block argument is not used' do
|
@@ -1477,7 +1495,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1477
1495
|
end
|
1478
1496
|
|
1479
1497
|
include_examples 'accepts'
|
1480
|
-
include_examples 'mimics MRI 2.
|
1498
|
+
include_examples 'mimics MRI 2.1'
|
1481
1499
|
end
|
1482
1500
|
|
1483
1501
|
context 'when there is only one AST node and it is unused variable' do
|
@@ -1496,7 +1514,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1496
1514
|
expect(cop.highlights).to eq(['foo'])
|
1497
1515
|
end
|
1498
1516
|
|
1499
|
-
include_examples 'mimics MRI 2.
|
1517
|
+
include_examples 'mimics MRI 2.1'
|
1500
1518
|
end
|
1501
1519
|
|
1502
1520
|
context 'when a variable is assigned ' +
|
@@ -1512,7 +1530,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1512
1530
|
end
|
1513
1531
|
|
1514
1532
|
include_examples 'accepts'
|
1515
|
-
include_examples 'mimics MRI 2.
|
1533
|
+
include_examples 'mimics MRI 2.1'
|
1516
1534
|
end
|
1517
1535
|
|
1518
1536
|
context 'and the variable is not used' do
|
@@ -1532,7 +1550,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1532
1550
|
expect(cop.highlights).to eq(['foo'])
|
1533
1551
|
end
|
1534
1552
|
|
1535
|
-
include_examples 'mimics MRI 2.
|
1553
|
+
include_examples 'mimics MRI 2.1'
|
1536
1554
|
end
|
1537
1555
|
end
|
1538
1556
|
|
@@ -1547,6 +1565,6 @@ describe Rubocop::Cop::Lint::UselessAssignment do
|
|
1547
1565
|
end
|
1548
1566
|
|
1549
1567
|
include_examples 'accepts'
|
1550
|
-
include_examples 'mimics MRI 2.
|
1568
|
+
include_examples 'mimics MRI 2.1'
|
1551
1569
|
end
|
1552
1570
|
end
|