rubocop 0.92.0 → 0.93.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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +30 -0
  4. data/lib/rubocop.rb +3 -1
  5. data/lib/rubocop/cached_data.rb +2 -1
  6. data/lib/rubocop/cop/correctors/line_break_corrector.rb +2 -2
  7. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +10 -10
  8. data/lib/rubocop/cop/layout/dot_position.rb +6 -9
  9. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +6 -7
  10. data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +1 -1
  11. data/lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb +2 -11
  12. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +0 -4
  13. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +2 -0
  14. data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +18 -1
  15. data/lib/rubocop/cop/lint/boolean_symbol.rb +3 -0
  16. data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +37 -0
  17. data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -0
  18. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
  19. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +78 -0
  20. data/lib/rubocop/cop/metrics/block_length.rb +3 -1
  21. data/lib/rubocop/cop/metrics/class_length.rb +14 -6
  22. data/lib/rubocop/cop/mixin/hash_transform_method.rb +1 -1
  23. data/lib/rubocop/cop/offense.rb +15 -2
  24. data/lib/rubocop/cop/style/access_modifier_declarations.rb +6 -2
  25. data/lib/rubocop/cop/style/accessor_grouping.rb +3 -0
  26. data/lib/rubocop/cop/style/case_like_if.rb +20 -4
  27. data/lib/rubocop/cop/style/class_equality_comparison.rb +64 -0
  28. data/lib/rubocop/cop/style/combinable_loops.rb +8 -1
  29. data/lib/rubocop/cop/style/comment_annotation.rb +6 -0
  30. data/lib/rubocop/cop/style/explicit_block_argument.rb +6 -2
  31. data/lib/rubocop/cop/style/for.rb +0 -4
  32. data/lib/rubocop/cop/style/format_string_token.rb +1 -1
  33. data/lib/rubocop/cop/style/method_def_parentheses.rb +0 -4
  34. data/lib/rubocop/cop/style/nested_ternary_operator.rb +2 -0
  35. data/lib/rubocop/cop/style/raise_args.rb +0 -3
  36. data/lib/rubocop/cop/style/redundant_begin.rb +36 -8
  37. data/lib/rubocop/cop/style/redundant_condition.rb +5 -1
  38. data/lib/rubocop/cop/style/redundant_interpolation.rb +6 -1
  39. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +39 -24
  40. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +8 -15
  41. data/lib/rubocop/cop/style/string_concatenation.rb +1 -1
  42. data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
  43. data/lib/rubocop/cop/variable_force/branch.rb +0 -4
  44. data/lib/rubocop/ext/regexp_node.rb +20 -4
  45. data/lib/rubocop/result_cache.rb +8 -2
  46. data/lib/rubocop/rspec/cop_helper.rb +1 -1
  47. data/lib/rubocop/runner.rb +4 -4
  48. data/lib/rubocop/target_finder.rb +23 -25
  49. data/lib/rubocop/version.rb +1 -1
  50. metadata +11 -9
  51. data/lib/rubocop/cop/mixin/regexp_literal_help.rb +0 -43
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- # Common functionality for handling Regexp literals.
6
- module RegexpLiteralHelp
7
- private
8
-
9
- def freespace_mode_regexp?(node)
10
- regopt = node.children.find(&:regopt_type?)
11
-
12
- regopt.children.include?(:x)
13
- end
14
-
15
- def pattern_source(node)
16
- freespace_mode = freespace_mode_regexp?(node)
17
-
18
- node.children.reject(&:regopt_type?).map do |child|
19
- source_with_comments_and_interpolations_blanked(child, freespace_mode)
20
- end.join
21
- end
22
-
23
- def source_with_comments_and_interpolations_blanked(child, freespace_mode)
24
- source = child.source
25
-
26
- # We don't want to consider the contents of interpolations or free-space mode comments as
27
- # part of the pattern source, but need to preserve their width, to allow offsets to
28
- # correctly line up with the original source: spaces have no effect, and preserve width.
29
- if child.begin_type?
30
- replace_match_with_spaces(source, /.*/m) # replace all content
31
- elsif freespace_mode
32
- replace_match_with_spaces(source, /(?<!\\)#.*/) # replace any comments
33
- else
34
- source
35
- end
36
- end
37
-
38
- def replace_match_with_spaces(source, pattern)
39
- source.sub(pattern) { ' ' * Regexp.last_match[0].length }
40
- end
41
- end
42
- end
43
- end