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.

Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +5 -0
  4. data/config/enabled.yml +2 -1
  5. data/lib/rubocop/ast/builder.rb +2 -2
  6. data/lib/rubocop/ast/node.rb +14 -14
  7. data/lib/rubocop/ast/node/send_node.rb +8 -3
  8. data/lib/rubocop/ast/traversal.rb +8 -8
  9. data/lib/rubocop/config.rb +3 -3
  10. data/lib/rubocop/config_loader.rb +2 -2
  11. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +26 -13
  12. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +1 -1
  13. data/lib/rubocop/cop/lint/inherit_exception.rb +2 -2
  14. data/lib/rubocop/cop/lint/literal_in_condition.rb +1 -1
  15. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
  16. data/lib/rubocop/cop/lint/nested_method_definition.rb +26 -3
  17. data/lib/rubocop/cop/lint/unneeded_splat_expansion.rb +1 -1
  18. data/lib/rubocop/cop/lint/unreachable_code.rb +2 -2
  19. data/lib/rubocop/cop/lint/useless_comparison.rb +1 -1
  20. data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
  21. data/lib/rubocop/cop/lint/void.rb +1 -1
  22. data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
  23. data/lib/rubocop/cop/metrics/block_nesting.rb +2 -2
  24. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +2 -2
  25. data/lib/rubocop/cop/metrics/parameter_lists.rb +1 -1
  26. data/lib/rubocop/cop/metrics/perceived_complexity.rb +2 -2
  27. data/lib/rubocop/cop/mixin/access_modifier_node.rb +1 -1
  28. data/lib/rubocop/cop/mixin/def_node.rb +1 -1
  29. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -1
  30. data/lib/rubocop/cop/mixin/on_method_def.rb +1 -1
  31. data/lib/rubocop/cop/mixin/percent_literal.rb +45 -4
  32. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
  33. data/lib/rubocop/cop/mixin/unused_argument.rb +1 -1
  34. data/lib/rubocop/cop/offense.rb +2 -2
  35. data/lib/rubocop/cop/performance/casecmp.rb +1 -1
  36. data/lib/rubocop/cop/performance/end_with.rb +1 -2
  37. data/lib/rubocop/cop/performance/redundant_match.rb +1 -1
  38. data/lib/rubocop/cop/performance/regexp_match.rb +2 -2
  39. data/lib/rubocop/cop/performance/start_with.rb +1 -2
  40. data/lib/rubocop/cop/rails/action_filter.rb +4 -4
  41. data/lib/rubocop/cop/rails/blank.rb +1 -0
  42. data/lib/rubocop/cop/rails/date.rb +3 -3
  43. data/lib/rubocop/cop/rails/delegate.rb +1 -1
  44. data/lib/rubocop/cop/rails/exit.rb +2 -2
  45. data/lib/rubocop/cop/rails/file_path.rb +5 -1
  46. data/lib/rubocop/cop/rails/find_by.rb +1 -1
  47. data/lib/rubocop/cop/rails/find_each.rb +2 -2
  48. data/lib/rubocop/cop/rails/http_positional_arguments.rb +3 -3
  49. data/lib/rubocop/cop/rails/relative_date_constant.rb +7 -3
  50. data/lib/rubocop/cop/rails/request_referer.rb +17 -2
  51. data/lib/rubocop/cop/rails/save_bang.rb +4 -4
  52. data/lib/rubocop/cop/rails/skips_model_validations.rb +2 -2
  53. data/lib/rubocop/cop/rails/time_zone.rb +6 -6
  54. data/lib/rubocop/cop/rails/validation.rb +2 -2
  55. data/lib/rubocop/cop/severity.rb +1 -1
  56. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +34 -0
  57. data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
  58. data/lib/rubocop/cop/style/command_literal.rb +1 -1
  59. data/lib/rubocop/cop/style/conditional_assignment.rb +3 -3
  60. data/lib/rubocop/cop/style/constant_name.rb +1 -1
  61. data/lib/rubocop/cop/style/each_with_object.rb +1 -1
  62. data/lib/rubocop/cop/style/empty_line_after_magic_comment.rb +1 -1
  63. data/lib/rubocop/cop/style/file_name.rb +2 -2
  64. data/lib/rubocop/cop/style/global_vars.rb +2 -2
  65. data/lib/rubocop/cop/style/if_unless_modifier.rb +2 -2
  66. data/lib/rubocop/cop/style/indentation_width.rb +2 -2
  67. data/lib/rubocop/cop/style/inverse_methods.rb +1 -1
  68. data/lib/rubocop/cop/style/line_end_concatenation.rb +5 -5
  69. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +15 -7
  70. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +1 -1
  71. data/lib/rubocop/cop/style/mixin_grouping.rb +2 -2
  72. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +2 -2
  73. data/lib/rubocop/cop/style/next.rb +3 -3
  74. data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
  75. data/lib/rubocop/cop/style/one_line_conditional.rb +2 -2
  76. data/lib/rubocop/cop/style/op_method.rb +2 -2
  77. data/lib/rubocop/cop/style/parallel_assignment.rb +1 -1
  78. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +5 -36
  79. data/lib/rubocop/cop/style/perl_backrefs.rb +1 -1
  80. data/lib/rubocop/cop/style/preferred_hash_methods.rb +2 -2
  81. data/lib/rubocop/cop/style/redundant_parentheses.rb +1 -1
  82. data/lib/rubocop/cop/style/redundant_self.rb +4 -5
  83. data/lib/rubocop/cop/style/regexp_literal.rb +1 -1
  84. data/lib/rubocop/cop/style/self_assignment.rb +3 -3
  85. data/lib/rubocop/cop/style/space_around_keyword.rb +9 -9
  86. data/lib/rubocop/cop/style/space_around_operators.rb +1 -1
  87. data/lib/rubocop/cop/style/space_inside_brackets.rb +1 -1
  88. data/lib/rubocop/cop/style/space_inside_parens.rb +1 -1
  89. data/lib/rubocop/cop/style/special_global_vars.rb +10 -10
  90. data/lib/rubocop/cop/style/symbol_proc.rb +2 -2
  91. data/lib/rubocop/cop/style/ternary_parentheses.rb +3 -2
  92. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  93. data/lib/rubocop/cop/util.rb +7 -7
  94. data/lib/rubocop/cop/variable_force.rb +7 -7
  95. data/lib/rubocop/cop/variable_force/variable.rb +2 -2
  96. data/lib/rubocop/formatter/colorizable.rb +2 -2
  97. data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -1
  98. data/lib/rubocop/formatter/formatter_set.rb +1 -1
  99. data/lib/rubocop/options.rb +20 -11
  100. data/lib/rubocop/processed_source.rb +1 -1
  101. data/lib/rubocop/result_cache.rb +2 -2
  102. data/lib/rubocop/rspec/shared_examples.rb +1 -1
  103. data/lib/rubocop/runner.rb +1 -1
  104. data/lib/rubocop/target_finder.rb +6 -6
  105. data/lib/rubocop/version.rb +1 -1
  106. 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
- ).each do |color|
34
+ ].each do |color|
35
35
  define_method(color) do |string|
36
36
  colorize(string, color)
37
37
  end
@@ -102,7 +102,7 @@ module RuboCop
102
102
 
103
103
  def cop_config_params(default_cfg, cfg)
104
104
  default_cfg.keys -
105
- %w(Description StyleGuide Reference Enabled Exclude) -
105
+ %w[Description StyleGuide Reference Enabled Exclude] -
106
106
  cfg.keys
107
107
  end
108
108
 
@@ -22,7 +22,7 @@ module RuboCop
22
22
  'worst' => WorstOffendersFormatter
23
23
  }.freeze
24
24
 
25
- FORMATTER_APIS = %i(started finished).freeze
25
+ FORMATTER_APIS = %i[started finished].freeze
26
26
 
27
27
  FORMATTER_APIS.each do |method_name|
28
28
  define_method(method_name) do |*args|
@@ -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(version verbose_version show_cops).freeze
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] && !args.one?
27
- raise ArgumentError, '-s/--stdin requires exactly one path.'
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, '-n', '--[no-]color') { |c| @options[:color] = c }
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(Syntax Lint/Syntax).include?(name)
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(Lint/UnneededDisable UnneededDisable)).any?
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(Lint/Syntax Syntax)).any?
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(true false).include?(@options[:cache])
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(error fatal).include?(d.level) }
73
+ @diagnostics.none? { |d| %i[error fatal].include?(d.level) }
74
74
  end
75
75
 
76
76
  # Raw source checksum for tracking infinite loops.
@@ -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(color format formatters out debug fail_level
12
- cache fail_fast stdin).freeze
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(severity line cop_name).each do |a|
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
@@ -261,7 +261,7 @@ module RuboCop
261
261
  @mobilized_cop_classes[config.object_id] ||= begin
262
262
  cop_classes = Cop::Cop.all
263
263
 
264
- %i(only except).each do |opt|
264
+ %i[only except].each do |opt|
265
265
  OptionsValidator.validate_cop_list(@options[opt])
266
266
  end
267
267
 
@@ -3,7 +3,7 @@
3
3
  require 'set'
4
4
 
5
5
  module RuboCop
6
- RUBY_EXTENSIONS = %w(.rb
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).freeze
24
+ .watchr].freeze
25
25
 
26
- RUBY_INTERPRETERS = %w(ruby
26
+ RUBY_INTERPRETERS = %w[ruby
27
27
  macruby
28
28
  rake
29
29
  jruby
30
- rbx).freeze
30
+ rbx].freeze
31
31
 
32
- RUBY_FILENAMES = %w(.irbrc
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).freeze
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.
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.48.0'.freeze
6
+ STRING = '0.48.1'.freeze
7
7
 
8
8
  MSG = '%s (using Parser %s, running on %s %s %s)'.freeze
9
9
 
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.0
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-26 00:00:00.000000000 Z
13
+ date: 2017-04-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rainbow