rbhint 0.85.1.rc1 → 0.85.1.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -2
  3. data/assets/output.html.erb +1 -1
  4. data/config/default.yml +13 -1
  5. data/lib/rbhint.rb +8 -0
  6. data/lib/rbhint/version.rb +1 -1
  7. data/lib/rubocop.rb +2 -0
  8. data/lib/rubocop/config.rb +1 -1
  9. data/lib/rubocop/config_loader_resolver.rb +1 -1
  10. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +1 -1
  11. data/lib/rubocop/cop/generator/configuration_injector.rb +1 -1
  12. data/lib/rubocop/cop/layout/assignment_indentation.rb +2 -2
  13. data/lib/rubocop/cop/layout/block_alignment.rb +1 -1
  14. data/lib/rubocop/cop/layout/block_end_newline.rb +1 -1
  15. data/lib/rubocop/cop/layout/case_indentation.rb +2 -2
  16. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +1 -1
  17. data/lib/rubocop/cop/layout/comment_indentation.rb +4 -4
  18. data/lib/rubocop/cop/layout/condition_position.rb +1 -1
  19. data/lib/rubocop/cop/layout/def_end_alignment.rb +1 -1
  20. data/lib/rubocop/cop/layout/dot_position.rb +1 -1
  21. data/lib/rubocop/cop/layout/else_alignment.rb +1 -1
  22. data/lib/rubocop/cop/layout/empty_comment.rb +2 -2
  23. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +1 -1
  24. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +2 -2
  25. data/lib/rubocop/cop/layout/empty_lines.rb +1 -1
  26. data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +1 -1
  27. data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +2 -0
  28. data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +1 -1
  29. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +1 -1
  30. data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +1 -1
  31. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +2 -2
  32. data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +1 -1
  33. data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +1 -1
  34. data/lib/rubocop/cop/layout/end_alignment.rb +1 -1
  35. data/lib/rubocop/cop/layout/end_of_line.rb +2 -2
  36. data/lib/rubocop/cop/layout/extra_spacing.rb +6 -6
  37. data/lib/rubocop/cop/layout/first_argument_indentation.rb +3 -3
  38. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +2 -2
  39. data/lib/rubocop/cop/layout/first_array_element_line_break.rb +2 -2
  40. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +2 -2
  41. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +1 -1
  42. data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +1 -1
  43. data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +1 -1
  44. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +2 -2
  45. data/lib/rubocop/cop/layout/hash_alignment.rb +1 -1
  46. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +1 -1
  47. data/lib/rubocop/cop/layout/heredoc_indentation.rb +3 -3
  48. data/lib/rubocop/cop/layout/indentation_consistency.rb +1 -1
  49. data/lib/rubocop/cop/layout/indentation_style.rb +1 -1
  50. data/lib/rubocop/cop/layout/indentation_width.rb +2 -2
  51. data/lib/rubocop/cop/layout/initial_indentation.rb +1 -1
  52. data/lib/rubocop/cop/layout/leading_comment_space.rb +1 -1
  53. data/lib/rubocop/cop/layout/leading_empty_lines.rb +1 -1
  54. data/lib/rubocop/cop/layout/line_length.rb +6 -6
  55. data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +1 -1
  56. data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +1 -1
  57. data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +1 -1
  58. data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -1
  59. data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +1 -1
  60. data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +1 -1
  61. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +1 -1
  62. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +1 -1
  63. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +1 -1
  64. data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +1 -1
  65. data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +1 -1
  66. data/lib/rubocop/cop/layout/parameter_alignment.rb +1 -1
  67. data/lib/rubocop/cop/layout/space_after_colon.rb +2 -2
  68. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +1 -1
  69. data/lib/rubocop/cop/layout/space_around_keyword.rb +2 -2
  70. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +6 -6
  71. data/lib/rubocop/cop/layout/space_around_operators.rb +2 -2
  72. data/lib/rubocop/cop/layout/space_before_block_braces.rb +14 -0
  73. data/lib/rubocop/cop/layout/space_before_comment.rb +1 -1
  74. data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +1 -1
  75. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +1 -1
  76. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +1 -1
  77. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +2 -2
  78. data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +1 -1
  79. data/lib/rubocop/cop/layout/trailing_empty_lines.rb +1 -1
  80. data/lib/rubocop/cop/layout/trailing_whitespace.rb +1 -1
  81. data/lib/rubocop/cop/lint/constant_resolution.rb +89 -0
  82. data/lib/rubocop/cop/lint/float_out_of_range.rb +1 -1
  83. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +6 -1
  84. data/lib/rubocop/cop/lint/percent_string_array.rb +1 -1
  85. data/lib/rubocop/cop/lint/percent_symbol_array.rb +1 -1
  86. data/lib/rubocop/cop/lint/raise_exception.rb +4 -4
  87. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +4 -2
  88. data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +1 -1
  89. data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
  90. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +35 -3
  91. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +1 -1
  92. data/lib/rubocop/cop/metrics/utils/iterating_block.rb +61 -0
  93. data/lib/rubocop/cop/mixin/configurable_naming.rb +1 -1
  94. data/lib/rubocop/cop/mixin/documentation_comment.rb +2 -2
  95. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -1
  96. data/lib/rubocop/cop/mixin/first_element_line_break.rb +1 -1
  97. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +1 -1
  98. data/lib/rubocop/cop/mixin/parentheses.rb +1 -2
  99. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +1 -1
  100. data/lib/rubocop/cop/mixin/range_help.rb +1 -1
  101. data/lib/rubocop/cop/mixin/regexp_literal_help.rb +27 -0
  102. data/lib/rubocop/cop/mixin/string_literals_help.rb +1 -1
  103. data/lib/rubocop/cop/mixin/surrounding_space.rb +3 -3
  104. data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
  105. data/lib/rubocop/cop/mixin/uncommunicative_name.rb +2 -2
  106. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +1 -1
  107. data/lib/rubocop/cop/naming/file_name.rb +1 -3
  108. data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +1 -1
  109. data/lib/rubocop/cop/style/bare_percent_literals.rb +1 -1
  110. data/lib/rubocop/cop/style/block_delimiters.rb +2 -4
  111. data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
  112. data/lib/rubocop/cop/style/command_literal.rb +1 -1
  113. data/lib/rubocop/cop/style/commented_keyword.rb +2 -2
  114. data/lib/rubocop/cop/style/conditional_assignment.rb +1 -1
  115. data/lib/rubocop/cop/style/copyright.rb +3 -3
  116. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +1 -1
  117. data/lib/rubocop/cop/style/documentation.rb +2 -2
  118. data/lib/rubocop/cop/style/empty_case_condition.rb +8 -6
  119. data/lib/rubocop/cop/style/encoding.rb +1 -1
  120. data/lib/rubocop/cop/style/exponential_notation.rb +2 -2
  121. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
  122. data/lib/rubocop/cop/style/identical_conditional_branches.rb +1 -1
  123. data/lib/rubocop/cop/style/if_inside_else.rb +1 -1
  124. data/lib/rubocop/cop/style/inverse_methods.rb +1 -1
  125. data/lib/rubocop/cop/style/ip_addresses.rb +1 -1
  126. data/lib/rubocop/cop/style/multiline_if_then.rb +1 -1
  127. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +17 -6
  128. data/lib/rubocop/cop/style/nested_ternary_operator.rb +27 -0
  129. data/lib/rubocop/cop/style/next.rb +2 -2
  130. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +2 -2
  131. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
  132. data/lib/rubocop/cop/style/redundant_parentheses.rb +1 -1
  133. data/lib/rubocop/cop/style/redundant_percent_q.rb +2 -2
  134. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +2 -2
  135. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +14 -23
  136. data/lib/rubocop/cop/style/redundant_self.rb +6 -9
  137. data/lib/rubocop/cop/style/sample.rb +1 -1
  138. data/lib/rubocop/cop/style/semicolon.rb +1 -1
  139. data/lib/rubocop/cop/style/struct_inheritance.rb +21 -0
  140. data/lib/rubocop/cop/style/symbol_array.rb +5 -5
  141. data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
  142. data/lib/rubocop/cop/style/word_array.rb +1 -1
  143. data/lib/rubocop/cop/util.rb +2 -2
  144. data/lib/rubocop/cop/utils/format_string.rb +1 -1
  145. data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -1
  146. data/lib/rubocop/formatter/formatter_set.rb +1 -1
  147. data/lib/rubocop/name_similarity.rb +6 -0
  148. data/lib/rubocop/path_util.rb +2 -2
  149. data/lib/rubocop/platform.rb +1 -1
  150. data/lib/rubocop/rspec/expect_offense.rb +12 -2
  151. data/lib/rubocop/target_finder.rb +1 -1
  152. data/lib/rubocop/target_ruby.rb +1 -1
  153. metadata +10 -2
@@ -74,7 +74,7 @@ module RuboCop
74
74
  end
75
75
 
76
76
  def timestamp
77
- @options[:no_auto_gen_timestamp] ? '' : "on #{Time.now} "
77
+ @options[:no_auto_gen_timestamp] ? '' : "on #{Time.now.utc} "
78
78
  end
79
79
 
80
80
  def output_offenses
@@ -82,7 +82,7 @@ module RuboCop
82
82
 
83
83
  def builtin_formatter_class(specified_key)
84
84
  matching_keys = BUILTIN_FORMATTERS_FOR_KEYS.keys.select do |key|
85
- key =~ /^\[#{specified_key}\]/ || specified_key == key.delete('[]')
85
+ /^\[#{specified_key}\]/.match?(key) || specified_key == key.delete('[]')
86
86
  end
87
87
 
88
88
  raise %(No formatter for "#{specified_key}") if matching_keys.empty?
@@ -12,6 +12,12 @@ module RuboCop
12
12
  end
13
13
 
14
14
  def find_similar_names(target_name, names)
15
+ # DidYouMean::SpellChecker is not available in all versions of Ruby, and
16
+ # even on versions where it *is* available (>= 2.3), it is not always
17
+ # required correctly. So we do a feature check first.
18
+ # See: https://github.com/rubocop-hq/rubocop/issues/7979
19
+ return [] unless defined?(DidYouMean::SpellChecker)
20
+
15
21
  names = names.dup
16
22
  names.delete(target_name)
17
23
 
@@ -40,7 +40,7 @@ module RuboCop
40
40
  hidden_file_in_not_hidden_dir?(pattern, path)
41
41
  when Regexp
42
42
  begin
43
- path =~ pattern
43
+ pattern.match?(path)
44
44
  rescue ArgumentError => e
45
45
  return false if e.message.start_with?('invalid byte sequence')
46
46
 
@@ -51,7 +51,7 @@ module RuboCop
51
51
 
52
52
  # Returns true for an absolute Unix or Windows path.
53
53
  def absolute?(path)
54
- path =~ %r{\A([A-Z]:)?/}i
54
+ %r{\A([A-Z]:)?/}i.match?(path)
55
55
  end
56
56
 
57
57
  def self.pwd
@@ -5,7 +5,7 @@ module RuboCop
5
5
  # on.
6
6
  module Platform
7
7
  def self.windows?
8
- RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/
8
+ /cygwin|mswin|mingw|bccwin|wince|emx/.match?(RbConfig::CONFIG['host_os'])
9
9
  end
10
10
  end
11
11
  end
@@ -72,19 +72,29 @@ module RuboCop
72
72
  #
73
73
  # expect_no_corrections
74
74
  #
75
- # If your code has variables of different lengths, you can use `%{foo}`
76
- # and `^{foo}` to format your template:
75
+ # If your code has variables of different lengths, you can use `%{foo}`,
76
+ # `^{foo}`, and `_{foo}` to format your template:
77
77
  #
78
78
  # %w[raise fail].each do |keyword|
79
79
  # expect_offense(<<~RUBY, keyword: keyword)
80
80
  # %{keyword}(RuntimeError, msg)
81
81
  # ^{keyword}^^^^^^^^^^^^^^^^^^^ Redundant `RuntimeError` argument can be removed.
82
82
  # RUBY
83
+ #
84
+ # %w[has_one has_many].each do |type|
85
+ # expect_offense(<<~RUBY, type: type)
86
+ # class Book
87
+ # %{type} :chapter, foreign_key: 'book_id'
88
+ # _{type} ^^^^^^^^^^^^^^^^^^^^^^ Specifying the default value is redundant.
89
+ # end
90
+ # RUBY
91
+ # end
83
92
  module ExpectOffense
84
93
  def format_offense(source, **replacements)
85
94
  replacements.each do |keyword, value|
86
95
  source = source.gsub("%{#{keyword}}", value)
87
96
  .gsub("^{#{keyword}}", '^' * value.size)
97
+ .gsub("_{#{keyword}}", ' ' * value.size)
88
98
  end
89
99
  source
90
100
  end
@@ -139,7 +139,7 @@ module RuboCop
139
139
  return false unless File.extname(file).empty? && File.exist?(file)
140
140
 
141
141
  first_line = File.open(file, &:readline)
142
- !(first_line =~ /#!.*(#{ruby_interpreters(file).join('|')})/).nil?
142
+ /#!.*(#{ruby_interpreters(file).join('|')})/.match?(first_line)
143
143
  rescue EOFError, ArgumentError => e
144
144
  warn("Unprocessable file #{file}: #{e.class}, #{e.message}") if debug?
145
145
 
@@ -7,7 +7,7 @@ module RuboCop
7
7
  DEFAULT_VERSION = KNOWN_RUBIES.first
8
8
 
9
9
  OBSOLETE_RUBIES = {
10
- 1.9 => '0.50', 2.0 => '0.50', 2.1 => '0.58', 2.2 => '0.69', 2.3 => '0.81'
10
+ 1.9 => '0.41', 2.0 => '0.50', 2.1 => '0.57', 2.2 => '0.68', 2.3 => '0.81'
11
11
  }.freeze
12
12
  private_constant :KNOWN_RUBIES, :OBSOLETE_RUBIES
13
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbhint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.85.1.rc1
4
+ version: 0.85.1.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zee Spencer
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2020-06-08 00:00:00.000000000 Z
14
+ date: 2020-06-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: parallel
@@ -96,6 +96,9 @@ dependencies:
96
96
  - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: 0.0.3
99
+ - - "<"
100
+ - !ruby/object:Gem::Version
101
+ version: '1.0'
99
102
  type: :runtime
100
103
  prerelease: false
101
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -103,6 +106,9 @@ dependencies:
103
106
  - - ">="
104
107
  - !ruby/object:Gem::Version
105
108
  version: 0.0.3
109
+ - - "<"
110
+ - !ruby/object:Gem::Version
111
+ version: '1.0'
106
112
  - !ruby/object:Gem::Dependency
107
113
  name: ruby-progressbar
108
114
  requirement: !ruby/object:Gem::Requirement
@@ -335,6 +341,7 @@ files:
335
341
  - lib/rubocop/cop/lint/big_decimal_new.rb
336
342
  - lib/rubocop/cop/lint/boolean_symbol.rb
337
343
  - lib/rubocop/cop/lint/circular_argument_reference.rb
344
+ - lib/rubocop/cop/lint/constant_resolution.rb
338
345
  - lib/rubocop/cop/lint/debugger.rb
339
346
  - lib/rubocop/cop/lint/deprecated_class_methods.rb
340
347
  - lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb
@@ -424,6 +431,7 @@ files:
424
431
  - lib/rubocop/cop/metrics/parameter_lists.rb
425
432
  - lib/rubocop/cop/metrics/perceived_complexity.rb
426
433
  - lib/rubocop/cop/metrics/utils/abc_size_calculator.rb
434
+ - lib/rubocop/cop/metrics/utils/iterating_block.rb
427
435
  - lib/rubocop/cop/migration/department_name.rb
428
436
  - lib/rubocop/cop/mixin/alignment.rb
429
437
  - lib/rubocop/cop/mixin/annotation_comment.rb