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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +30 -0
- data/lib/rubocop.rb +3 -1
- data/lib/rubocop/cached_data.rb +2 -1
- data/lib/rubocop/cop/correctors/line_break_corrector.rb +2 -2
- data/lib/rubocop/cop/gemspec/required_ruby_version.rb +10 -10
- data/lib/rubocop/cop/layout/dot_position.rb +6 -9
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +6 -7
- data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb +2 -11
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +0 -4
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +2 -0
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +18 -1
- data/lib/rubocop/cop/lint/boolean_symbol.rb +3 -0
- data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +37 -0
- data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -0
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +78 -0
- data/lib/rubocop/cop/metrics/block_length.rb +3 -1
- data/lib/rubocop/cop/metrics/class_length.rb +14 -6
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +1 -1
- data/lib/rubocop/cop/offense.rb +15 -2
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +6 -2
- data/lib/rubocop/cop/style/accessor_grouping.rb +3 -0
- data/lib/rubocop/cop/style/case_like_if.rb +20 -4
- data/lib/rubocop/cop/style/class_equality_comparison.rb +64 -0
- data/lib/rubocop/cop/style/combinable_loops.rb +8 -1
- data/lib/rubocop/cop/style/comment_annotation.rb +6 -0
- data/lib/rubocop/cop/style/explicit_block_argument.rb +6 -2
- data/lib/rubocop/cop/style/for.rb +0 -4
- data/lib/rubocop/cop/style/format_string_token.rb +1 -1
- data/lib/rubocop/cop/style/method_def_parentheses.rb +0 -4
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +2 -0
- data/lib/rubocop/cop/style/raise_args.rb +0 -3
- data/lib/rubocop/cop/style/redundant_begin.rb +36 -8
- data/lib/rubocop/cop/style/redundant_condition.rb +5 -1
- data/lib/rubocop/cop/style/redundant_interpolation.rb +6 -1
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +39 -24
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +8 -15
- data/lib/rubocop/cop/style/string_concatenation.rb +1 -1
- data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
- data/lib/rubocop/cop/variable_force/branch.rb +0 -4
- data/lib/rubocop/ext/regexp_node.rb +20 -4
- data/lib/rubocop/result_cache.rb +8 -2
- data/lib/rubocop/rspec/cop_helper.rb +1 -1
- data/lib/rubocop/runner.rb +4 -4
- data/lib/rubocop/target_finder.rb +23 -25
- data/lib/rubocop/version.rb +1 -1
- metadata +11 -9
- 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
|