rubocop 1.60.2 → 1.61.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.

Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/assets/output.css.erb +159 -0
  4. data/assets/output.html.erb +1 -160
  5. data/config/default.yml +35 -12
  6. data/lib/rubocop/cli/command/lsp.rb +2 -2
  7. data/lib/rubocop/cli.rb +6 -1
  8. data/lib/rubocop/config_finder.rb +12 -2
  9. data/lib/rubocop/config_validator.rb +14 -5
  10. data/lib/rubocop/cop/autocorrect_logic.rb +6 -1
  11. data/lib/rubocop/cop/base.rb +12 -7
  12. data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +4 -8
  13. data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +5 -13
  14. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +2 -0
  15. data/lib/rubocop/cop/internal_affairs/method_name_end_with.rb +8 -6
  16. data/lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb +34 -0
  17. data/lib/rubocop/cop/internal_affairs.rb +1 -0
  18. data/lib/rubocop/cop/layout/end_alignment.rb +3 -1
  19. data/lib/rubocop/cop/layout/redundant_line_break.rb +3 -1
  20. data/lib/rubocop/cop/layout/space_before_block_braces.rb +19 -10
  21. data/lib/rubocop/cop/lint/empty_conditional_body.rb +1 -1
  22. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +14 -9
  23. data/lib/rubocop/cop/lint/rescue_type.rb +1 -3
  24. data/lib/rubocop/cop/lint/script_permission.rb +3 -3
  25. data/lib/rubocop/cop/lint/syntax.rb +1 -1
  26. data/lib/rubocop/cop/lint/void.rb +6 -1
  27. data/lib/rubocop/cop/naming/predicate_name.rb +2 -2
  28. data/lib/rubocop/cop/registry.rb +1 -1
  29. data/lib/rubocop/cop/style/arguments_forwarding.rb +29 -8
  30. data/lib/rubocop/cop/style/case_like_if.rb +1 -1
  31. data/lib/rubocop/cop/style/commented_keyword.rb +5 -2
  32. data/lib/rubocop/cop/style/conditional_assignment.rb +4 -5
  33. data/lib/rubocop/cop/style/hash_syntax.rb +6 -2
  34. data/lib/rubocop/cop/style/inverse_methods.rb +8 -8
  35. data/lib/rubocop/cop/style/invertible_unless_condition.rb +10 -5
  36. data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +5 -8
  37. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +1 -1
  38. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +4 -0
  39. data/lib/rubocop/cop/style/object_then.rb +5 -3
  40. data/lib/rubocop/cop/style/parallel_assignment.rb +1 -3
  41. data/lib/rubocop/cop/style/raise_args.rb +3 -0
  42. data/lib/rubocop/cop/style/redundant_argument.rb +2 -2
  43. data/lib/rubocop/cop/style/redundant_assignment.rb +10 -2
  44. data/lib/rubocop/cop/style/redundant_line_continuation.rb +16 -5
  45. data/lib/rubocop/cop/style/redundant_return.rb +6 -0
  46. data/lib/rubocop/cop/style/sample.rb +1 -3
  47. data/lib/rubocop/cops_documentation_generator.rb +4 -2
  48. data/lib/rubocop/formatter/html_formatter.rb +30 -10
  49. data/lib/rubocop/formatter/offense_count_formatter.rb +12 -2
  50. data/lib/rubocop/lsp/logger.rb +1 -1
  51. data/lib/rubocop/lsp/routes.rb +1 -1
  52. data/lib/rubocop/lsp/runtime.rb +1 -1
  53. data/lib/rubocop/lsp/server.rb +5 -2
  54. data/lib/rubocop/lsp/severity.rb +1 -1
  55. data/lib/rubocop/lsp.rb +29 -0
  56. data/lib/rubocop/options.rb +11 -0
  57. data/lib/rubocop/path_util.rb +6 -2
  58. data/lib/rubocop/rspec/shared_contexts.rb +10 -6
  59. data/lib/rubocop/rspec/support.rb +1 -1
  60. data/lib/rubocop/target_ruby.rb +79 -79
  61. data/lib/rubocop/version.rb +1 -1
  62. metadata +11 -8
@@ -48,6 +48,84 @@ module RuboCop
48
48
  end
49
49
  end
50
50
 
51
+ # The target ruby version may be found in a .gemspec file.
52
+ # @api private
53
+ class GemspecFile < Source
54
+ extend NodePattern::Macros
55
+
56
+ GEMSPEC_EXTENSION = '.gemspec'
57
+
58
+ # @!method required_ruby_version(node)
59
+ def_node_search :required_ruby_version, <<~PATTERN
60
+ (send _ :required_ruby_version= $_)
61
+ PATTERN
62
+
63
+ # @!method gem_requirement_versions(node)
64
+ def_node_matcher :gem_requirement_versions, <<~PATTERN
65
+ (send (const(const _ :Gem):Requirement) :new
66
+ {$str+ | (send $str :freeze)+ | (array $str+) | (array (send $str :freeze)+)}
67
+ )
68
+ PATTERN
69
+
70
+ def name
71
+ "`required_ruby_version` parameter (in #{gemspec_filename})"
72
+ end
73
+
74
+ private
75
+
76
+ def find_version
77
+ file = gemspec_filepath
78
+ return unless file && File.file?(file)
79
+
80
+ right_hand_side = version_from_gemspec_file(file)
81
+ return if right_hand_side.nil?
82
+
83
+ find_default_minimal_known_ruby(right_hand_side)
84
+ end
85
+
86
+ def gemspec_filename
87
+ @gemspec_filename ||= begin
88
+ basename = Pathname.new(@config.base_dir_for_path_parameters).basename.to_s
89
+ "#{basename}#{GEMSPEC_EXTENSION}"
90
+ end
91
+ end
92
+
93
+ def gemspec_filepath
94
+ @gemspec_filepath ||=
95
+ @config.find_file_upwards(gemspec_filename, @config.base_dir_for_path_parameters)
96
+ end
97
+
98
+ def version_from_gemspec_file(file)
99
+ processed_source = ProcessedSource.from_file(file, DEFAULT_VERSION)
100
+ required_ruby_version(processed_source.ast).first
101
+ end
102
+
103
+ def version_from_right_hand_side(right_hand_side)
104
+ gem_requirement_versions = gem_requirement_versions(right_hand_side)
105
+
106
+ if right_hand_side.array_type?
107
+ version_from_array(right_hand_side)
108
+ elsif gem_requirement_versions
109
+ gem_requirement_versions.map(&:value)
110
+ else
111
+ right_hand_side.value
112
+ end
113
+ end
114
+
115
+ def version_from_array(array)
116
+ array.children.map(&:value)
117
+ end
118
+
119
+ def find_default_minimal_known_ruby(right_hand_side)
120
+ version = version_from_right_hand_side(right_hand_side)
121
+ requirement = Gem::Requirement.new(version)
122
+
123
+ KNOWN_RUBIES.detect do |v|
124
+ v >= DEFAULT_VERSION && requirement.satisfied_by?(Gem::Version.new("#{v}.99"))
125
+ end
126
+ end
127
+ end
128
+
51
129
  # The target ruby version may be found in a .ruby-version file.
52
130
  # @api private
53
131
  class RubyVersionFile < Source
@@ -143,84 +221,6 @@ module RuboCop
143
221
  end
144
222
  end
145
223
 
146
- # The target ruby version may be found in a .gemspec file.
147
- # @api private
148
- class GemspecFile < Source
149
- extend NodePattern::Macros
150
-
151
- GEMSPEC_EXTENSION = '.gemspec'
152
-
153
- # @!method required_ruby_version(node)
154
- def_node_search :required_ruby_version, <<~PATTERN
155
- (send _ :required_ruby_version= $_)
156
- PATTERN
157
-
158
- # @!method gem_requirement_versions(node)
159
- def_node_matcher :gem_requirement_versions, <<~PATTERN
160
- (send (const(const _ :Gem):Requirement) :new
161
- {$str+ | (send $str :freeze)+ | (array $str+) | (array (send $str :freeze)+)}
162
- )
163
- PATTERN
164
-
165
- def name
166
- "`required_ruby_version` parameter (in #{gemspec_filename})"
167
- end
168
-
169
- private
170
-
171
- def find_version
172
- file = gemspec_filepath
173
- return unless file && File.file?(file)
174
-
175
- right_hand_side = version_from_gemspec_file(file)
176
- return if right_hand_side.nil?
177
-
178
- find_default_minimal_known_ruby(right_hand_side)
179
- end
180
-
181
- def gemspec_filename
182
- @gemspec_filename ||= begin
183
- basename = Pathname.new(@config.base_dir_for_path_parameters).basename.to_s
184
- "#{basename}#{GEMSPEC_EXTENSION}"
185
- end
186
- end
187
-
188
- def gemspec_filepath
189
- @gemspec_filepath ||=
190
- @config.find_file_upwards(gemspec_filename, @config.base_dir_for_path_parameters)
191
- end
192
-
193
- def version_from_gemspec_file(file)
194
- processed_source = ProcessedSource.from_file(file, DEFAULT_VERSION)
195
- required_ruby_version(processed_source.ast).first
196
- end
197
-
198
- def version_from_right_hand_side(right_hand_side)
199
- gem_requirement_versions = gem_requirement_versions(right_hand_side)
200
-
201
- if right_hand_side.array_type?
202
- version_from_array(right_hand_side)
203
- elsif gem_requirement_versions
204
- gem_requirement_versions.map(&:value)
205
- else
206
- right_hand_side.value
207
- end
208
- end
209
-
210
- def version_from_array(array)
211
- array.children.map(&:value)
212
- end
213
-
214
- def find_default_minimal_known_ruby(right_hand_side)
215
- version = version_from_right_hand_side(right_hand_side)
216
- requirement = Gem::Requirement.new(version)
217
-
218
- KNOWN_RUBIES.detect do |v|
219
- v >= DEFAULT_VERSION && requirement.satisfied_by?(Gem::Version.new("#{v}.99"))
220
- end
221
- end
222
- end
223
-
224
224
  # If all else fails, a default version will be picked.
225
225
  # @api private
226
226
  class Default < Source
@@ -241,10 +241,10 @@ module RuboCop
241
241
 
242
242
  SOURCES = [
243
243
  RuboCopConfig,
244
+ GemspecFile,
244
245
  RubyVersionFile,
245
246
  ToolVersionsFile,
246
247
  BundlerLockFile,
247
- GemspecFile,
248
248
  Default
249
249
  ].freeze
250
250
 
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.60.2'
6
+ STRING = '1.61.0'
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, ' \
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.60.2
4
+ version: 1.61.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
8
8
  - Jonas Arvidsson
9
9
  - Yuji Nakayama
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2024-01-24 00:00:00.000000000 Z
13
+ date: 2024-02-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -196,6 +196,7 @@ files:
196
196
  - LICENSE.txt
197
197
  - README.md
198
198
  - assets/logo.png
199
+ - assets/output.css.erb
199
200
  - assets/output.html.erb
200
201
  - config/default.yml
201
202
  - config/obsoletion.yml
@@ -302,6 +303,7 @@ files:
302
303
  - lib/rubocop/cop/internal_affairs/processed_source_buffer_name.rb
303
304
  - lib/rubocop/cop/internal_affairs/redundant_context_config_parameter.rb
304
305
  - lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb
306
+ - lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
305
307
  - lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb
306
308
  - lib/rubocop/cop/internal_affairs/redundant_location_argument.rb
307
309
  - lib/rubocop/cop/internal_affairs/redundant_message_argument.rb
@@ -978,6 +980,7 @@ files:
978
980
  - lib/rubocop/formatter/text_util.rb
979
981
  - lib/rubocop/formatter/worst_offenders_formatter.rb
980
982
  - lib/rubocop/lockfile.rb
983
+ - lib/rubocop/lsp.rb
981
984
  - lib/rubocop/lsp/logger.rb
982
985
  - lib/rubocop/lsp/routes.rb
983
986
  - lib/rubocop/lsp/runtime.rb
@@ -1028,12 +1031,12 @@ licenses:
1028
1031
  - MIT
1029
1032
  metadata:
1030
1033
  homepage_uri: https://rubocop.org/
1031
- changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.60.2
1034
+ changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.61.0
1032
1035
  source_code_uri: https://github.com/rubocop/rubocop/
1033
- documentation_uri: https://docs.rubocop.org/rubocop/1.60/
1036
+ documentation_uri: https://docs.rubocop.org/rubocop/1.61/
1034
1037
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
1035
1038
  rubygems_mfa_required: 'true'
1036
- post_install_message:
1039
+ post_install_message:
1037
1040
  rdoc_options: []
1038
1041
  require_paths:
1039
1042
  - lib
@@ -1048,8 +1051,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1048
1051
  - !ruby/object:Gem::Version
1049
1052
  version: '0'
1050
1053
  requirements: []
1051
- rubygems_version: 3.4.22
1052
- signing_key:
1054
+ rubygems_version: 3.3.7
1055
+ signing_key:
1053
1056
  specification_version: 4
1054
1057
  summary: Automatic Ruby code style checking tool.
1055
1058
  test_files: []