rubocop 0.48.0 → 0.48.1
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 +1 -1
- data/config/default.yml +5 -0
- data/config/enabled.yml +2 -1
- data/lib/rubocop/ast/builder.rb +2 -2
- data/lib/rubocop/ast/node.rb +14 -14
- data/lib/rubocop/ast/node/send_node.rb +8 -3
- data/lib/rubocop/ast/traversal.rb +8 -8
- data/lib/rubocop/config.rb +3 -3
- data/lib/rubocop/config_loader.rb +2 -2
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +26 -13
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +1 -1
- data/lib/rubocop/cop/lint/inherit_exception.rb +2 -2
- data/lib/rubocop/cop/lint/literal_in_condition.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +26 -3
- data/lib/rubocop/cop/lint/unneeded_splat_expansion.rb +1 -1
- data/lib/rubocop/cop/lint/unreachable_code.rb +2 -2
- data/lib/rubocop/cop/lint/useless_comparison.rb +1 -1
- data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +1 -1
- data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
- data/lib/rubocop/cop/metrics/block_nesting.rb +2 -2
- data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +2 -2
- data/lib/rubocop/cop/metrics/parameter_lists.rb +1 -1
- data/lib/rubocop/cop/metrics/perceived_complexity.rb +2 -2
- data/lib/rubocop/cop/mixin/access_modifier_node.rb +1 -1
- data/lib/rubocop/cop/mixin/def_node.rb +1 -1
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/on_method_def.rb +1 -1
- data/lib/rubocop/cop/mixin/percent_literal.rb +45 -4
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
- data/lib/rubocop/cop/mixin/unused_argument.rb +1 -1
- data/lib/rubocop/cop/offense.rb +2 -2
- data/lib/rubocop/cop/performance/casecmp.rb +1 -1
- data/lib/rubocop/cop/performance/end_with.rb +1 -2
- data/lib/rubocop/cop/performance/redundant_match.rb +1 -1
- data/lib/rubocop/cop/performance/regexp_match.rb +2 -2
- data/lib/rubocop/cop/performance/start_with.rb +1 -2
- data/lib/rubocop/cop/rails/action_filter.rb +4 -4
- data/lib/rubocop/cop/rails/blank.rb +1 -0
- data/lib/rubocop/cop/rails/date.rb +3 -3
- data/lib/rubocop/cop/rails/delegate.rb +1 -1
- data/lib/rubocop/cop/rails/exit.rb +2 -2
- data/lib/rubocop/cop/rails/file_path.rb +5 -1
- data/lib/rubocop/cop/rails/find_by.rb +1 -1
- data/lib/rubocop/cop/rails/find_each.rb +2 -2
- data/lib/rubocop/cop/rails/http_positional_arguments.rb +3 -3
- data/lib/rubocop/cop/rails/relative_date_constant.rb +7 -3
- data/lib/rubocop/cop/rails/request_referer.rb +17 -2
- data/lib/rubocop/cop/rails/save_bang.rb +4 -4
- data/lib/rubocop/cop/rails/skips_model_validations.rb +2 -2
- data/lib/rubocop/cop/rails/time_zone.rb +6 -6
- data/lib/rubocop/cop/rails/validation.rb +2 -2
- data/lib/rubocop/cop/severity.rb +1 -1
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +34 -0
- data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
- data/lib/rubocop/cop/style/command_literal.rb +1 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +3 -3
- data/lib/rubocop/cop/style/constant_name.rb +1 -1
- data/lib/rubocop/cop/style/each_with_object.rb +1 -1
- data/lib/rubocop/cop/style/empty_line_after_magic_comment.rb +1 -1
- data/lib/rubocop/cop/style/file_name.rb +2 -2
- data/lib/rubocop/cop/style/global_vars.rb +2 -2
- data/lib/rubocop/cop/style/if_unless_modifier.rb +2 -2
- data/lib/rubocop/cop/style/indentation_width.rb +2 -2
- data/lib/rubocop/cop/style/inverse_methods.rb +1 -1
- data/lib/rubocop/cop/style/line_end_concatenation.rb +5 -5
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +15 -7
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/mixin_grouping.rb +2 -2
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +2 -2
- data/lib/rubocop/cop/style/next.rb +3 -3
- data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
- data/lib/rubocop/cop/style/one_line_conditional.rb +2 -2
- data/lib/rubocop/cop/style/op_method.rb +2 -2
- data/lib/rubocop/cop/style/parallel_assignment.rb +1 -1
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +5 -36
- data/lib/rubocop/cop/style/perl_backrefs.rb +1 -1
- data/lib/rubocop/cop/style/preferred_hash_methods.rb +2 -2
- data/lib/rubocop/cop/style/redundant_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/redundant_self.rb +4 -5
- data/lib/rubocop/cop/style/regexp_literal.rb +1 -1
- data/lib/rubocop/cop/style/self_assignment.rb +3 -3
- data/lib/rubocop/cop/style/space_around_keyword.rb +9 -9
- data/lib/rubocop/cop/style/space_around_operators.rb +1 -1
- data/lib/rubocop/cop/style/space_inside_brackets.rb +1 -1
- data/lib/rubocop/cop/style/space_inside_parens.rb +1 -1
- data/lib/rubocop/cop/style/special_global_vars.rb +10 -10
- data/lib/rubocop/cop/style/symbol_proc.rb +2 -2
- data/lib/rubocop/cop/style/ternary_parentheses.rb +3 -2
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/util.rb +7 -7
- data/lib/rubocop/cop/variable_force.rb +7 -7
- data/lib/rubocop/cop/variable_force/variable.rb +2 -2
- data/lib/rubocop/formatter/colorizable.rb +2 -2
- data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -1
- data/lib/rubocop/formatter/formatter_set.rb +1 -1
- data/lib/rubocop/options.rb +20 -11
- data/lib/rubocop/processed_source.rb +1 -1
- data/lib/rubocop/result_cache.rb +2 -2
- data/lib/rubocop/rspec/shared_examples.rb +1 -1
- data/lib/rubocop/runner.rb +1 -1
- data/lib/rubocop/target_finder.rb +6 -6
- data/lib/rubocop/version.rb +1 -1
- metadata +2 -2
@@ -22,7 +22,7 @@ module RuboCop
|
|
22
22
|
rainbow.wrap(string).color(*args)
|
23
23
|
end
|
24
24
|
|
25
|
-
%i
|
25
|
+
%i[
|
26
26
|
black
|
27
27
|
red
|
28
28
|
green
|
@@ -31,7 +31,7 @@ module RuboCop
|
|
31
31
|
magenta
|
32
32
|
cyan
|
33
33
|
white
|
34
|
-
|
34
|
+
].each do |color|
|
35
35
|
define_method(color) do |string|
|
36
36
|
colorize(string, color)
|
37
37
|
end
|
data/lib/rubocop/options.rb
CHANGED
@@ -6,7 +6,7 @@ require 'shellwords'
|
|
6
6
|
module RuboCop
|
7
7
|
# This class handles command line options.
|
8
8
|
class Options
|
9
|
-
EXITING_OPTIONS = %i
|
9
|
+
EXITING_OPTIONS = %i[version verbose_version show_cops].freeze
|
10
10
|
DEFAULT_MAXIMUM_EXCLUSION_ITEMS = 15
|
11
11
|
|
12
12
|
def initialize
|
@@ -23,8 +23,16 @@ module RuboCop
|
|
23
23
|
|
24
24
|
@validator.validate_compatibility
|
25
25
|
|
26
|
-
if @options[:stdin]
|
27
|
-
|
26
|
+
if @options[:stdin]
|
27
|
+
# The parser has put the file name given after --stdin into
|
28
|
+
# @options[:stdin]. The args array should be empty.
|
29
|
+
if args.any?
|
30
|
+
raise ArgumentError, '-s/--stdin requires exactly one path.'
|
31
|
+
end
|
32
|
+
# We want the STDIN contents in @options[:stdin] and the file name in
|
33
|
+
# args to simplify the rest of the processing.
|
34
|
+
args = [@options[:stdin]]
|
35
|
+
@options[:stdin] = $stdin.binmode.read
|
28
36
|
end
|
29
37
|
|
30
38
|
[@options, args]
|
@@ -58,6 +66,8 @@ module RuboCop
|
|
58
66
|
add_severity_option(opts)
|
59
67
|
add_flags_with_optional_args(opts)
|
60
68
|
add_boolean_flags(opts)
|
69
|
+
|
70
|
+
option(opts, '-s', '--stdin FILE')
|
61
71
|
end
|
62
72
|
end
|
63
73
|
|
@@ -142,11 +152,10 @@ module RuboCop
|
|
142
152
|
end
|
143
153
|
option(opts, '-a', '--auto-correct')
|
144
154
|
|
145
|
-
option(opts, '
|
155
|
+
option(opts, '--[no-]color') { |c| @options[:color] = c }
|
146
156
|
|
147
157
|
option(opts, '-v', '--version')
|
148
158
|
option(opts, '-V', '--verbose-version')
|
149
|
-
option(opts, '-s', '--stdin') { @options[:stdin] = $stdin.binmode.read }
|
150
159
|
end
|
151
160
|
|
152
161
|
def add_list_options(opts)
|
@@ -184,7 +193,7 @@ module RuboCop
|
|
184
193
|
names.each do |name|
|
185
194
|
next if Cop::Cop.registry.names.include?(name)
|
186
195
|
next if departments.include?(name)
|
187
|
-
next if %w
|
196
|
+
next if %w[Syntax Lint/Syntax].include?(name)
|
188
197
|
|
189
198
|
raise ArgumentError, "Unrecognized cop or department: #{name}."
|
190
199
|
end
|
@@ -215,16 +224,16 @@ module RuboCop
|
|
215
224
|
|
216
225
|
def only_includes_unneeded_disable?
|
217
226
|
@options.key?(:only) &&
|
218
|
-
(@options[:only] & %w
|
227
|
+
(@options[:only] & %w[Lint/UnneededDisable UnneededDisable]).any?
|
219
228
|
end
|
220
229
|
|
221
230
|
def except_syntax?
|
222
231
|
@options.key?(:except) &&
|
223
|
-
(@options[:except] & %w
|
232
|
+
(@options[:except] & %w[Lint/Syntax Syntax]).any?
|
224
233
|
end
|
225
234
|
|
226
235
|
def boolean_or_empty_cache?
|
227
|
-
!@options.key?(:cache) || %w
|
236
|
+
!@options.key?(:cache) || %w[true false].include?(@options[:cache])
|
228
237
|
end
|
229
238
|
|
230
239
|
def no_offense_counts_without_auto_gen_config?
|
@@ -314,8 +323,8 @@ module RuboCop
|
|
314
323
|
no_color: 'Force color output on or off.',
|
315
324
|
version: 'Display version.',
|
316
325
|
verbose_version: 'Display verbose version.',
|
317
|
-
stdin: ['Pipe source from STDIN
|
318
|
-
'This is useful for editor integration.']
|
326
|
+
stdin: ['Pipe source from STDIN, using FILE in offense',
|
327
|
+
'reports. This is useful for editor integration.']
|
319
328
|
}.freeze
|
320
329
|
end
|
321
330
|
end
|
@@ -70,7 +70,7 @@ module RuboCop
|
|
70
70
|
|
71
71
|
def valid_syntax?
|
72
72
|
return false if @parser_error
|
73
|
-
@diagnostics.none? { |d| %i
|
73
|
+
@diagnostics.none? { |d| %i[error fatal].include?(d.level) }
|
74
74
|
end
|
75
75
|
|
76
76
|
# Raw source checksum for tracking infinite loops.
|
data/lib/rubocop/result_cache.rb
CHANGED
@@ -8,8 +8,8 @@ require 'etc'
|
|
8
8
|
module RuboCop
|
9
9
|
# Provides functionality for caching rubocop runs.
|
10
10
|
class ResultCache
|
11
|
-
NON_CHANGING = %i
|
12
|
-
cache fail_fast stdin
|
11
|
+
NON_CHANGING = %i[color format formatters out debug fail_level
|
12
|
+
cache fail_fast stdin].freeze
|
13
13
|
|
14
14
|
# Remove old files so that the cache doesn't grow too big. When the
|
15
15
|
# threshold MaxFilesInCache has been exceeded, the oldest 50% of all the
|
@@ -22,7 +22,7 @@ shared_examples_for 'mimics MRI 2.1' do |grep_mri_warning|
|
|
22
22
|
offense_by_mri = offenses_by_mri[index]
|
23
23
|
# Exclude column attribute since MRI does not
|
24
24
|
# output column number.
|
25
|
-
%i
|
25
|
+
%i[severity line cop_name].each do |a|
|
26
26
|
expect(offense_by_cop.send(a)).to eq(offense_by_mri.send(a))
|
27
27
|
end
|
28
28
|
end
|
data/lib/rubocop/runner.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'set'
|
4
4
|
|
5
5
|
module RuboCop
|
6
|
-
RUBY_EXTENSIONS = %w
|
6
|
+
RUBY_EXTENSIONS = %w[.rb
|
7
7
|
.builder
|
8
8
|
.fcgi
|
9
9
|
.gemspec
|
@@ -21,15 +21,15 @@ module RuboCop
|
|
21
21
|
.ruby
|
22
22
|
.spec
|
23
23
|
.thor
|
24
|
-
.watchr
|
24
|
+
.watchr].freeze
|
25
25
|
|
26
|
-
RUBY_INTERPRETERS = %w
|
26
|
+
RUBY_INTERPRETERS = %w[ruby
|
27
27
|
macruby
|
28
28
|
rake
|
29
29
|
jruby
|
30
|
-
rbx
|
30
|
+
rbx].freeze
|
31
31
|
|
32
|
-
RUBY_FILENAMES = %w
|
32
|
+
RUBY_FILENAMES = %w[.irbrc
|
33
33
|
.pryrc
|
34
34
|
Appraisals
|
35
35
|
Berksfile
|
@@ -48,7 +48,7 @@ module RuboCop
|
|
48
48
|
Snapfile
|
49
49
|
Thorfile
|
50
50
|
Vagrantfile
|
51
|
-
buildfile
|
51
|
+
buildfile].freeze
|
52
52
|
|
53
53
|
# This class finds target files to inspect by scanning the directory tree
|
54
54
|
# and picking ruby files.
|
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.48.
|
4
|
+
version: 0.48.1
|
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: 2017-03
|
13
|
+
date: 2017-04-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rainbow
|