rubocop 1.72.1 → 1.73.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/config/default.yml +26 -11
  4. data/config/internal_affairs.yml +16 -0
  5. data/lib/rubocop/config_loader_resolver.rb +2 -2
  6. data/lib/rubocop/config_validator.rb +1 -1
  7. data/lib/rubocop/cop/internal_affairs/example_description.rb +4 -2
  8. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +4 -4
  9. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +26 -1
  10. data/lib/rubocop/cop/layout/line_length.rb +3 -3
  11. data/lib/rubocop/cop/lint/duplicate_methods.rb +0 -14
  12. data/lib/rubocop/cop/lint/empty_conditional_body.rb +10 -5
  13. data/lib/rubocop/cop/lint/float_comparison.rb +1 -6
  14. data/lib/rubocop/cop/lint/literal_as_condition.rb +99 -9
  15. data/lib/rubocop/cop/lint/mixed_case_range.rb +2 -2
  16. data/lib/rubocop/cop/lint/redundant_require_statement.rb +0 -21
  17. data/lib/rubocop/cop/lint/redundant_type_conversion.rb +23 -2
  18. data/lib/rubocop/cop/lint/useless_constant_scoping.rb +7 -1
  19. data/lib/rubocop/cop/lint/void.rb +6 -0
  20. data/lib/rubocop/cop/mixin/allowed_pattern.rb +4 -4
  21. data/lib/rubocop/cop/mixin/hash_subset.rb +19 -4
  22. data/lib/rubocop/cop/mixin/trailing_comma.rb +12 -0
  23. data/lib/rubocop/cop/naming/block_forwarding.rb +3 -3
  24. data/lib/rubocop/cop/naming/variable_name.rb +64 -6
  25. data/lib/rubocop/cop/style/accessor_grouping.rb +19 -5
  26. data/lib/rubocop/cop/style/arguments_forwarding.rb +3 -3
  27. data/lib/rubocop/cop/style/commented_keyword.rb +1 -1
  28. data/lib/rubocop/cop/style/endless_method.rb +163 -18
  29. data/lib/rubocop/cop/style/line_end_concatenation.rb +10 -4
  30. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +1 -1
  31. data/lib/rubocop/cop/style/redundant_condition.rb +46 -0
  32. data/lib/rubocop/cop/style/redundant_format.rb +39 -11
  33. data/lib/rubocop/cop/style/redundant_parentheses.rb +1 -3
  34. data/lib/rubocop/cop/style/redundant_self_assignment.rb +1 -1
  35. data/lib/rubocop/cop/style/single_line_methods.rb +3 -3
  36. data/lib/rubocop/cop/style/string_concatenation.rb +1 -1
  37. data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +47 -6
  38. data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +48 -6
  39. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  40. data/lib/rubocop/cops_documentation_generator.rb +12 -1
  41. data/lib/rubocop/plugin/configuration_integrator.rb +2 -0
  42. data/lib/rubocop/plugin/load_error.rb +1 -1
  43. data/lib/rubocop/plugin.rb +9 -2
  44. data/lib/rubocop/rspec/cop_helper.rb +2 -0
  45. data/lib/rubocop/rspec/shared_contexts.rb +15 -0
  46. data/lib/rubocop/rspec/support.rb +1 -0
  47. data/lib/rubocop/version.rb +1 -1
  48. data/lib/rubocop.rb +0 -1
  49. metadata +4 -5
  50. data/lib/rubocop/cop/utils/regexp_ranges.rb +0 -113
@@ -1,113 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module Utils
6
- # Helper to abstract complexity of building range pairs
7
- # with octal escape reconstruction (needed for regexp_parser < 2.7).
8
- class RegexpRanges
9
- attr_reader :root
10
-
11
- def initialize(root)
12
- @root = root
13
- @compound_token = []
14
- @pairs = []
15
- @populated = false
16
- end
17
-
18
- def compound_token
19
- populate_all unless @populated
20
-
21
- @compound_token
22
- end
23
-
24
- def pairs
25
- populate_all unless @populated
26
-
27
- @pairs
28
- end
29
-
30
- private
31
-
32
- def populate_all
33
- populate(@root)
34
-
35
- # If either bound is a compound the first one is an escape
36
- # and that's all we need to work with.
37
- # If there are any cops that wanted to operate on the compound
38
- # expression we could wrap it with a facade class.
39
- @pairs.map! { |pair| pair.map(&:first) }
40
-
41
- @populated = true
42
- end
43
-
44
- def populate(expr)
45
- expressions = expr.expressions.to_a
46
-
47
- until expressions.empty?
48
- current = expressions.shift
49
-
50
- if escaped_octal?(current)
51
- @compound_token << current
52
- @compound_token.concat(pop_octal_digits(expressions))
53
- # If we have all the digits we can discard.
54
- end
55
-
56
- next unless current.type == :set
57
-
58
- process_set(expressions, current)
59
- @compound_token.clear
60
- end
61
- end
62
-
63
- def process_set(expressions, current)
64
- case current.token
65
- when :range
66
- @pairs << compose_range(expressions, current)
67
- when :character
68
- # Child expressions may include the range we are looking for.
69
- populate(current)
70
- when :intersection
71
- # Each child expression could have child expressions that lead to ranges.
72
- current.expressions.each do |intersected|
73
- populate(intersected)
74
- end
75
- end
76
- end
77
-
78
- def compose_range(expressions, current)
79
- range_start, range_end = current.expressions
80
- range_start = if @compound_token.size.between?(1, 2) && octal_digit?(range_start.text)
81
- @compound_token.dup << range_start
82
- else
83
- [range_start]
84
- end
85
- range_end = [range_end]
86
- range_end.concat(pop_octal_digits(expressions)) if escaped_octal?(range_end.first)
87
- [range_start, range_end]
88
- end
89
-
90
- def escaped_octal?(expr)
91
- expr.text.valid_encoding? && expr.text =~ /^\\[0-7]$/
92
- end
93
-
94
- def octal_digit?(char)
95
- ('0'..'7').cover?(char)
96
- end
97
-
98
- def pop_octal_digits(expressions)
99
- digits = []
100
-
101
- 2.times do
102
- next unless (next_child = expressions.first)
103
- next unless next_child.type == :literal && next_child.text =~ /^[0-7]$/
104
-
105
- digits << expressions.shift
106
- end
107
-
108
- digits
109
- end
110
- end
111
- end
112
- end
113
- end