rubocop 0.41.2 → 0.42.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/README.md +2 -3
- data/config/default.yml +13 -0
- data/config/disabled.yml +5 -0
- data/config/enabled.yml +20 -0
- data/lib/rubocop.rb +4 -0
- data/lib/rubocop/ast_node.rb +4 -3
- data/lib/rubocop/config.rb +1 -1
- data/lib/rubocop/config_loader.rb +2 -7
- data/lib/rubocop/cop/cop.rb +3 -3
- data/lib/rubocop/cop/lint/block_alignment.rb +18 -16
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +34 -19
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +9 -1
- data/lib/rubocop/cop/lint/shadowed_exception.rb +23 -3
- data/lib/rubocop/cop/lint/unneeded_disable.rb +1 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +41 -4
- data/lib/rubocop/cop/mixin/array_hash_indentation.rb +1 -1
- data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +3 -5
- data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +4 -4
- data/lib/rubocop/cop/mixin/space_inside.rb +23 -8
- data/lib/rubocop/cop/mixin/statement_modifier.rb +1 -1
- data/lib/rubocop/cop/offense.rb +33 -10
- data/lib/rubocop/cop/performance/case_when_splat.rb +16 -14
- data/lib/rubocop/cop/performance/sample.rb +0 -1
- data/lib/rubocop/cop/rails/save_bang.rb +77 -0
- data/lib/rubocop/cop/rails/validation.rb +15 -15
- data/lib/rubocop/cop/style/access_modifier_indentation.rb +1 -1
- data/lib/rubocop/cop/style/align_hash.rb +1 -1
- data/lib/rubocop/cop/style/block_comments.rb +1 -3
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +19 -10
- data/lib/rubocop/cop/style/closing_parenthesis_indentation.rb +1 -1
- data/lib/rubocop/cop/style/comment_annotation.rb +14 -14
- data/lib/rubocop/cop/style/comment_indentation.rb +1 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +25 -26
- data/lib/rubocop/cop/style/dot_position.rb +24 -19
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +22 -8
- data/lib/rubocop/cop/style/each_with_object.rb +11 -1
- data/lib/rubocop/cop/style/else_alignment.rb +1 -1
- data/lib/rubocop/cop/style/empty_lines.rb +22 -11
- data/lib/rubocop/cop/style/empty_lines_around_access_modifier.rb +9 -6
- data/lib/rubocop/cop/style/empty_lines_around_block_body.rb +14 -14
- data/lib/rubocop/cop/style/empty_lines_around_class_body.rb +8 -5
- data/lib/rubocop/cop/style/empty_lines_around_method_body.rb +12 -8
- data/lib/rubocop/cop/style/empty_lines_around_module_body.rb +17 -4
- data/lib/rubocop/cop/style/empty_literal.rb +12 -7
- data/lib/rubocop/cop/style/for.rb +1 -1
- data/lib/rubocop/cop/style/indent_array.rb +1 -1
- data/lib/rubocop/cop/style/indent_hash.rb +1 -1
- data/lib/rubocop/cop/style/indentation_width.rb +1 -1
- data/lib/rubocop/cop/style/initial_indentation.rb +1 -1
- data/lib/rubocop/cop/style/lambda.rb +2 -3
- data/lib/rubocop/cop/style/method_call_parentheses.rb +6 -4
- data/lib/rubocop/cop/style/method_missing.rb +74 -0
- data/lib/rubocop/cop/style/multiline_method_call_indentation.rb +1 -1
- data/lib/rubocop/cop/style/multiline_operation_indentation.rb +1 -1
- data/lib/rubocop/cop/style/nested_modifier.rb +23 -13
- data/lib/rubocop/cop/style/next.rb +1 -1
- data/lib/rubocop/cop/style/numeric_predicate.rb +142 -0
- data/lib/rubocop/cop/style/op_method.rb +12 -4
- data/lib/rubocop/cop/style/parallel_assignment.rb +11 -3
- data/lib/rubocop/cop/style/rescue_ensure_alignment.rb +9 -6
- data/lib/rubocop/cop/style/single_line_block_params.rb +3 -2
- data/lib/rubocop/cop/style/space_inside_block_braces.rb +1 -1
- data/lib/rubocop/cop/style/space_inside_string_interpolation.rb +1 -1
- data/lib/rubocop/cop/style/symbol_array.rb +18 -10
- data/lib/rubocop/cop/style/ternary_parentheses.rb +94 -0
- data/lib/rubocop/cop/style/trailing_blank_lines.rb +1 -1
- data/lib/rubocop/cop/style/unneeded_percent_q.rb +12 -6
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cop/variable_force/assignment.rb +1 -1
- data/lib/rubocop/cop/variable_force/locatable.rb +1 -1
- data/lib/rubocop/formatter/disabled_config_formatter.rb +18 -7
- data/lib/rubocop/formatter/html_formatter.rb +25 -11
- data/lib/rubocop/formatter/text_util.rb +1 -1
- data/lib/rubocop/node_pattern.rb +2 -0
- data/lib/rubocop/processed_source.rb +3 -0
- data/lib/rubocop/rake_task.rb +1 -1
- data/lib/rubocop/rspec/shared_contexts.rb +4 -0
- data/lib/rubocop/runner.rb +18 -7
- data/lib/rubocop/string_util.rb +2 -5
- data/lib/rubocop/version.rb +1 -1
- metadata +7 -3
data/lib/rubocop/node_pattern.rb
CHANGED
@@ -134,6 +134,7 @@ module RuboCop
|
|
134
134
|
fail_due_to('unbalanced pattern') unless tokens.empty?
|
135
135
|
end
|
136
136
|
|
137
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
137
138
|
def compile_expr(tokens, cur_node, seq_head)
|
138
139
|
# read a single pattern-matching expression from the token stream,
|
139
140
|
# return Ruby code which performs the corresponding matching operation
|
@@ -160,6 +161,7 @@ module RuboCop
|
|
160
161
|
else fail_due_to("invalid token #{token.inspect}")
|
161
162
|
end
|
162
163
|
end
|
164
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
163
165
|
|
164
166
|
def compile_seq(tokens, cur_node, seq_head)
|
165
167
|
fail_due_to('empty parentheses') if tokens.first == ')'
|
data/lib/rubocop/rake_task.rb
CHANGED
data/lib/rubocop/runner.rb
CHANGED
@@ -79,21 +79,32 @@ module RuboCop
|
|
79
79
|
puts "Scanning #{file}" if @options[:debug]
|
80
80
|
file_started(file)
|
81
81
|
|
82
|
+
offenses = file_offenses(file)
|
83
|
+
formatter_set.file_finished(file, offenses)
|
84
|
+
offenses
|
85
|
+
rescue InfiniteCorrectionLoop => e
|
86
|
+
formatter_set.file_finished(file, e.offenses.compact.sort.freeze)
|
87
|
+
raise
|
88
|
+
end
|
89
|
+
|
90
|
+
def file_offenses(file)
|
91
|
+
file_offense_cache(file) do
|
92
|
+
source = get_processed_source(file)
|
93
|
+
source, offenses = do_inspection_loop(file, source)
|
94
|
+
add_unneeded_disables(file, offenses.compact.sort, source)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def file_offense_cache(file)
|
82
99
|
cache = ResultCache.new(file, @options, @config_store) if cached_run?
|
83
100
|
if cache && cache.valid?
|
84
101
|
offenses = cache.load
|
85
102
|
else
|
86
|
-
|
87
|
-
source, offenses = do_inspection_loop(file, source)
|
88
|
-
offenses = add_unneeded_disables(file, offenses.compact.sort, source)
|
103
|
+
offenses = yield
|
89
104
|
save_in_cache(cache, offenses)
|
90
105
|
end
|
91
106
|
|
92
|
-
formatter_set.file_finished(file, offenses)
|
93
107
|
offenses
|
94
|
-
rescue InfiniteCorrectionLoop => e
|
95
|
-
formatter_set.file_finished(file, e.offenses.compact.sort.freeze)
|
96
|
-
raise
|
97
108
|
end
|
98
109
|
|
99
110
|
def add_unneeded_disables(file, offenses, source)
|
data/lib/rubocop/string_util.rb
CHANGED
@@ -55,12 +55,9 @@ module RuboCop
|
|
55
55
|
common_chars_of_shorter = Array.new(shorter.size)
|
56
56
|
common_chars_of_longer = Array.new(longer.size)
|
57
57
|
|
58
|
-
# In Ruby 1.9 String#chars returns Enumerator rather than Array.
|
59
|
-
longer_chars = longer.each_char.to_a
|
60
|
-
|
61
58
|
shorter.each_char.with_index do |shorter_char, shorter_index|
|
62
59
|
matching_index_range(shorter_index).each do |longer_index|
|
63
|
-
longer_char =
|
60
|
+
longer_char = longer.chars[longer_index]
|
64
61
|
|
65
62
|
next unless shorter_char == longer_char
|
66
63
|
|
@@ -68,7 +65,7 @@ module RuboCop
|
|
68
65
|
common_chars_of_longer[longer_index] = longer_char
|
69
66
|
|
70
67
|
# Mark the matching character as already used
|
71
|
-
|
68
|
+
longer.chars[longer_index] = nil
|
72
69
|
|
73
70
|
break
|
74
71
|
end
|
data/lib/rubocop/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.42.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-07-
|
13
|
+
date: 2016-07-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rainbow
|
@@ -290,6 +290,7 @@ files:
|
|
290
290
|
- lib/rubocop/cop/rails/pluralization_grammar.rb
|
291
291
|
- lib/rubocop/cop/rails/read_write_attribute.rb
|
292
292
|
- lib/rubocop/cop/rails/request_referer.rb
|
293
|
+
- lib/rubocop/cop/rails/save_bang.rb
|
293
294
|
- lib/rubocop/cop/rails/scope_args.rb
|
294
295
|
- lib/rubocop/cop/rails/time_zone.rb
|
295
296
|
- lib/rubocop/cop/rails/uniq_before_pluck.rb
|
@@ -386,6 +387,7 @@ files:
|
|
386
387
|
- lib/rubocop/cop/style/method_call_parentheses.rb
|
387
388
|
- lib/rubocop/cop/style/method_called_on_do_end_block.rb
|
388
389
|
- lib/rubocop/cop/style/method_def_parentheses.rb
|
390
|
+
- lib/rubocop/cop/style/method_missing.rb
|
389
391
|
- lib/rubocop/cop/style/method_name.rb
|
390
392
|
- lib/rubocop/cop/style/missing_else.rb
|
391
393
|
- lib/rubocop/cop/style/module_function.rb
|
@@ -412,6 +414,7 @@ files:
|
|
412
414
|
- lib/rubocop/cop/style/not.rb
|
413
415
|
- lib/rubocop/cop/style/numeric_literal_prefix.rb
|
414
416
|
- lib/rubocop/cop/style/numeric_literals.rb
|
417
|
+
- lib/rubocop/cop/style/numeric_predicate.rb
|
415
418
|
- lib/rubocop/cop/style/one_line_conditional.rb
|
416
419
|
- lib/rubocop/cop/style/op_method.rb
|
417
420
|
- lib/rubocop/cop/style/option_hash.rb
|
@@ -472,6 +475,7 @@ files:
|
|
472
475
|
- lib/rubocop/cop/style/symbol_literal.rb
|
473
476
|
- lib/rubocop/cop/style/symbol_proc.rb
|
474
477
|
- lib/rubocop/cop/style/tab.rb
|
478
|
+
- lib/rubocop/cop/style/ternary_parentheses.rb
|
475
479
|
- lib/rubocop/cop/style/trailing_blank_lines.rb
|
476
480
|
- lib/rubocop/cop/style/trailing_comma_in_arguments.rb
|
477
481
|
- lib/rubocop/cop/style/trailing_comma_in_literal.rb
|
@@ -547,7 +551,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
547
551
|
requirements:
|
548
552
|
- - ">="
|
549
553
|
- !ruby/object:Gem::Version
|
550
|
-
version:
|
554
|
+
version: 2.0.0
|
551
555
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
552
556
|
requirements:
|
553
557
|
- - ">="
|