rubocop 0.54.0 → 0.55.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -1
  3. data/config/default.yml +17 -2
  4. data/config/enabled.yml +13 -0
  5. data/lib/rubocop.rb +4 -0
  6. data/lib/rubocop/ast/node/mixin/binary_operator_node.rb +20 -0
  7. data/lib/rubocop/cli.rb +6 -2
  8. data/lib/rubocop/cop/commissioner.rb +21 -25
  9. data/lib/rubocop/cop/layout/end_of_line.rb +33 -0
  10. data/lib/rubocop/cop/layout/space_inside_parens.rb +64 -5
  11. data/lib/rubocop/cop/layout/trailing_whitespace.rb +20 -0
  12. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +80 -0
  13. data/lib/rubocop/cop/lint/shadowed_argument.rb +3 -0
  14. data/lib/rubocop/cop/lint/void.rb +20 -9
  15. data/lib/rubocop/cop/metrics/block_length.rb +17 -1
  16. data/lib/rubocop/cop/metrics/line_length.rb +2 -3
  17. data/lib/rubocop/cop/mixin/percent_literal.rb +9 -8
  18. data/lib/rubocop/cop/performance/end_with.rb +2 -1
  19. data/lib/rubocop/cop/performance/regexp_match.rb +43 -7
  20. data/lib/rubocop/cop/performance/start_with.rb +2 -1
  21. data/lib/rubocop/cop/performance/unneeded_sort.rb +130 -0
  22. data/lib/rubocop/cop/rails/http_status.rb +19 -16
  23. data/lib/rubocop/cop/rails/inverse_of.rb +29 -22
  24. data/lib/rubocop/cop/rails/read_write_attribute.rb +9 -2
  25. data/lib/rubocop/cop/style/array_join.rb +1 -1
  26. data/lib/rubocop/cop/style/class_vars.rb +5 -4
  27. data/lib/rubocop/cop/style/commented_keyword.rb +2 -3
  28. data/lib/rubocop/cop/style/empty_line_after_guard_clause.rb +39 -8
  29. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +22 -11
  30. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +5 -0
  31. data/lib/rubocop/cop/style/mutable_constant.rb +5 -0
  32. data/lib/rubocop/cop/style/negated_while.rb +18 -0
  33. data/lib/rubocop/cop/style/nested_ternary_operator.rb +11 -0
  34. data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
  35. data/lib/rubocop/cop/style/one_line_conditional.rb +17 -0
  36. data/lib/rubocop/cop/style/option_hash.rb +6 -0
  37. data/lib/rubocop/cop/style/single_line_block_params.rb +20 -0
  38. data/lib/rubocop/cop/style/special_global_vars.rb +52 -0
  39. data/lib/rubocop/cop/style/string_literals.rb +1 -1
  40. data/lib/rubocop/cop/style/unpack_first.rb +0 -2
  41. data/lib/rubocop/formatter/auto_gen_config_formatter.rb +16 -0
  42. data/lib/rubocop/formatter/formatter_set.rb +14 -13
  43. data/lib/rubocop/node_pattern.rb +2 -2
  44. data/lib/rubocop/options.rb +1 -0
  45. data/lib/rubocop/version.rb +1 -1
  46. metadata +13 -4
@@ -38,7 +38,7 @@ module RuboCop
38
38
  # If one part of that continued string contains interpolations,
39
39
  # then it will be parsed as a nested `dstr` node
40
40
  return unless consistent_multiline?
41
- return if node.loc.is_a?(Parser::Source::Map::Heredoc)
41
+ return if node.heredoc?
42
42
 
43
43
  children = node.children
44
44
  return unless all_string_literals?(children)
@@ -13,7 +13,6 @@ module RuboCop
13
13
  # 'foo'.unpack('h*')[0]
14
14
  # 'foo'.unpack('h*').slice(0)
15
15
  # 'foo'.unpack('h*').at(0)
16
- # 'foo'.unpack('h*').take(1)
17
16
  #
18
17
  # # good
19
18
  # 'foo'.unpack1('h*')
@@ -30,7 +29,6 @@ module RuboCop
30
29
  {
31
30
  (send $(send (...) :unpack $(...)) :first)
32
31
  (send $(send (...) :unpack $(...)) {:[] :slice :at} (int 0))
33
- (send $(send (...) :unpack $(...)) :take (int 1))
34
32
  }
35
33
  PATTERN
36
34
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Formatter
5
+ # Does not show individual offenses in the console.
6
+ class AutoGenConfigFormatter < ProgressFormatter
7
+ def finished(inspected_files)
8
+ output.puts
9
+
10
+ report_summary(inspected_files.size,
11
+ @total_offense_count,
12
+ @total_correction_count)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -9,19 +9,20 @@ module RuboCop
9
9
  # which invoke same method of each formatters.
10
10
  class FormatterSet < Array
11
11
  BUILTIN_FORMATTERS_FOR_KEYS = {
12
- 'progress' => ProgressFormatter,
13
- 'simple' => SimpleTextFormatter,
14
- 'clang' => ClangStyleFormatter,
15
- 'fuubar' => FuubarStyleFormatter,
16
- 'emacs' => EmacsStyleFormatter,
17
- 'json' => JSONFormatter,
18
- 'html' => HTMLFormatter,
19
- 'files' => FileListFormatter,
20
- 'offenses' => OffenseCountFormatter,
21
- 'disabled' => DisabledLinesFormatter,
22
- 'worst' => WorstOffendersFormatter,
23
- 'tap' => TapFormatter,
24
- 'quiet' => QuietFormatter
12
+ 'progress' => ProgressFormatter,
13
+ 'simple' => SimpleTextFormatter,
14
+ 'clang' => ClangStyleFormatter,
15
+ 'fuubar' => FuubarStyleFormatter,
16
+ 'emacs' => EmacsStyleFormatter,
17
+ 'json' => JSONFormatter,
18
+ 'html' => HTMLFormatter,
19
+ 'files' => FileListFormatter,
20
+ 'offenses' => OffenseCountFormatter,
21
+ 'disabled' => DisabledLinesFormatter,
22
+ 'worst' => WorstOffendersFormatter,
23
+ 'tap' => TapFormatter,
24
+ 'quiet' => QuietFormatter,
25
+ 'autogenconf' => AutoGenConfigFormatter
25
26
  }.freeze
26
27
 
27
28
  FORMATTER_APIS = %i[started finished].freeze
@@ -74,10 +74,10 @@ module RuboCop
74
74
  # You can nest arbitrarily deep:
75
75
  #
76
76
  # # matches node parsed from 'Const = Class.new' or 'Const = Module.new':
77
- # '(casgn nil const (send (const nil {:Class :Module}) :new)))'
77
+ # '(casgn nil? const (send (const nil? {:Class :Module}) :new)))'
78
78
  # # matches a node parsed from an 'if', with a '==' comparison,
79
79
  # # and no 'else' branch:
80
- # '(if (send _ :== _) _ nil)'
80
+ # '(if (send _ :== _) _ nil?)'
81
81
  #
82
82
  # Note that patterns like 'send' are implemented by calling `#send_type?` on
83
83
  # the node being matched, 'const' by `#const_type?`, 'int' by `#int_type?`,
@@ -353,6 +353,7 @@ module RuboCop
353
353
  ' [w]orst',
354
354
  ' [t]ap',
355
355
  ' [q]uiet',
356
+ ' [a]utogenconf',
356
357
  ' custom formatter class name'],
357
358
  out: ['Write output to a file instead of STDOUT.',
358
359
  'This option applies to the previously',
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.54.0'.freeze
6
+ STRING = '0.55.0'.freeze
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, running on ' \
9
9
  '%<ruby_engine>s %<ruby_version>s %<ruby_platform>s)'.freeze
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.54.0
4
+ version: 0.55.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: 2018-03-21 00:00:00.000000000 Z
13
+ date: 2018-04-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parallel
@@ -128,14 +128,20 @@ dependencies:
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: 1.6.9
132
+ - - "<"
133
+ - !ruby/object:Gem::Version
134
+ version: '2.0'
132
135
  type: :development
133
136
  prerelease: false
134
137
  version_requirements: !ruby/object:Gem::Requirement
135
138
  requirements:
136
139
  - - ">="
137
140
  - !ruby/object:Gem::Version
138
- version: '0'
141
+ version: 1.6.9
142
+ - - "<"
143
+ - !ruby/object:Gem::Version
144
+ version: '2.0'
139
145
  description: |2
140
146
  Automatic Ruby code style checking tool.
141
147
  Aims to enforce the community-driven Ruby Style Guide.
@@ -361,6 +367,7 @@ files:
361
367
  - lib/rubocop/cop/lint/rescue_type.rb
362
368
  - lib/rubocop/cop/lint/return_in_void_context.rb
363
369
  - lib/rubocop/cop/lint/safe_navigation_chain.rb
370
+ - lib/rubocop/cop/lint/safe_navigation_consistency.rb
364
371
  - lib/rubocop/cop/lint/script_permission.rb
365
372
  - lib/rubocop/cop/lint/shadowed_argument.rb
366
373
  - lib/rubocop/cop/lint/shadowed_exception.rb
@@ -493,6 +500,7 @@ files:
493
500
  - lib/rubocop/cop/performance/string_replacement.rb
494
501
  - lib/rubocop/cop/performance/times_map.rb
495
502
  - lib/rubocop/cop/performance/unfreeze_string.rb
503
+ - lib/rubocop/cop/performance/unneeded_sort.rb
496
504
  - lib/rubocop/cop/performance/uri_default_parser.rb
497
505
  - lib/rubocop/cop/rails/action_filter.rb
498
506
  - lib/rubocop/cop/rails/active_record_aliases.rb
@@ -713,6 +721,7 @@ files:
713
721
  - lib/rubocop/cop/variable_force/variable_table.rb
714
722
  - lib/rubocop/error.rb
715
723
  - lib/rubocop/file_finder.rb
724
+ - lib/rubocop/formatter/auto_gen_config_formatter.rb
716
725
  - lib/rubocop/formatter/base_formatter.rb
717
726
  - lib/rubocop/formatter/clang_style_formatter.rb
718
727
  - lib/rubocop/formatter/colorizable.rb