rubocop 1.27.0 → 1.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +50 -9
- data/config/obsoletion.yml +10 -1
- data/lib/rubocop/cli/command/suggest_extensions.rb +1 -1
- data/lib/rubocop/cop/gemspec/date_assignment.rb +2 -2
- data/lib/rubocop/cop/layout/case_indentation.rb +16 -0
- data/lib/rubocop/cop/layout/indentation_width.rb +2 -2
- data/lib/rubocop/cop/layout/line_length.rb +4 -4
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +19 -2
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_require.rb +10 -1
- data/lib/rubocop/cop/lint/unreachable_loop.rb +4 -4
- data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +1 -1
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +16 -2
- data/lib/rubocop/cop/mixin/allowed_pattern.rb +40 -0
- data/lib/rubocop/cop/mixin/comments_help.rb +3 -1
- data/lib/rubocop/cop/naming/method_name.rb +5 -5
- data/lib/rubocop/cop/offense.rb +1 -1
- data/lib/rubocop/cop/security/compound_hash.rb +105 -0
- data/lib/rubocop/cop/style/fetch_env_var.rb +76 -0
- data/lib/rubocop/cop/style/guard_clause.rb +45 -0
- data/lib/rubocop/cop/style/if_unless_modifier.rb +5 -4
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +4 -4
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +33 -11
- data/lib/rubocop/cop/style/object_then.rb +69 -0
- data/lib/rubocop/cop/style/redundant_initialize.rb +39 -4
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +5 -0
- data/lib/rubocop/cop/style/single_argument_dig.rb +4 -0
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +7 -7
- data/lib/rubocop/cop/style/special_global_vars.rb +66 -8
- data/lib/rubocop/cop/style/symbol_proc.rb +24 -0
- data/lib/rubocop/cop/variable_force/branch.rb +1 -1
- data/lib/rubocop/options.rb +27 -1
- data/lib/rubocop/result_cache.rb +3 -3
- data/lib/rubocop/rspec/shared_contexts.rb +2 -2
- data/lib/rubocop/runner.rb +29 -3
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +4 -1
- metadata +9 -6
- data/lib/rubocop/cop/mixin/ignored_pattern.rb +0 -29
@@ -57,6 +57,34 @@ module RuboCop
|
|
57
57
|
# puts $=
|
58
58
|
# puts $*
|
59
59
|
#
|
60
|
+
# @example EnforcedStyle: use_builtin_english_names
|
61
|
+
#
|
62
|
+
# Like `use_perl_names` but allows builtin global vars.
|
63
|
+
#
|
64
|
+
# # good
|
65
|
+
# puts $LOAD_PATH
|
66
|
+
# puts $LOADED_FEATURES
|
67
|
+
# puts $PROGRAM_NAME
|
68
|
+
# puts ARGV
|
69
|
+
# puts $:
|
70
|
+
# puts $"
|
71
|
+
# puts $0
|
72
|
+
# puts $!
|
73
|
+
# puts $@
|
74
|
+
# puts $;
|
75
|
+
# puts $,
|
76
|
+
# puts $/
|
77
|
+
# puts $\
|
78
|
+
# puts $.
|
79
|
+
# puts $_
|
80
|
+
# puts $>
|
81
|
+
# puts $<
|
82
|
+
# puts $$
|
83
|
+
# puts $?
|
84
|
+
# puts $~
|
85
|
+
# puts $=
|
86
|
+
# puts $*
|
87
|
+
#
|
60
88
|
class SpecialGlobalVars < Base
|
61
89
|
include ConfigurableEnforcedStyle
|
62
90
|
include RangeHelp
|
@@ -91,18 +119,37 @@ module RuboCop
|
|
91
119
|
:$* => %i[$ARGV ARGV]
|
92
120
|
}
|
93
121
|
|
122
|
+
# Anything *not* in this set is provided by the English library.
|
123
|
+
NON_ENGLISH_VARS = Set.new(%i[$LOAD_PATH $LOADED_FEATURES $PROGRAM_NAME ARGV]).freeze
|
124
|
+
|
94
125
|
PERL_VARS = ENGLISH_VARS.flat_map { |k, vs| vs.map { |v| [v, [k]] } }.to_h
|
95
126
|
|
96
127
|
ENGLISH_VARS.merge!(ENGLISH_VARS.flat_map { |_, vs| vs.map { |v| [v, [v]] } }.to_h)
|
97
128
|
PERL_VARS.merge!(PERL_VARS.flat_map { |_, vs| vs.map { |v| [v, [v]] } }.to_h)
|
129
|
+
BUILTIN_VARS = PERL_VARS.merge(
|
130
|
+
NON_ENGLISH_VARS
|
131
|
+
.select { |v| v.to_s.start_with?('$') }
|
132
|
+
.flat_map { |v| [[v, [v]], PERL_VARS[v].flat_map { |a| [a, [v]] }] }
|
133
|
+
.to_h
|
134
|
+
)
|
135
|
+
|
98
136
|
ENGLISH_VARS.each_value(&:freeze).freeze
|
99
137
|
PERL_VARS.each_value(&:freeze).freeze
|
138
|
+
BUILTIN_VARS.each_value(&:freeze).freeze
|
100
139
|
|
101
|
-
|
102
|
-
|
140
|
+
STYLE_VARS_MAP = {
|
141
|
+
use_english_names: ENGLISH_VARS,
|
142
|
+
use_perl_names: PERL_VARS,
|
143
|
+
use_builtin_english_names: BUILTIN_VARS
|
144
|
+
}.freeze
|
103
145
|
|
104
146
|
LIBRARY_NAME = 'English'
|
105
147
|
|
148
|
+
def on_new_investigation
|
149
|
+
super
|
150
|
+
@required_english = false
|
151
|
+
end
|
152
|
+
|
106
153
|
def on_gvar(node)
|
107
154
|
global_var, = *node
|
108
155
|
|
@@ -111,7 +158,7 @@ module RuboCop
|
|
111
158
|
if preferred.include?(global_var)
|
112
159
|
correct_style_detected
|
113
160
|
else
|
114
|
-
|
161
|
+
style_detected(matching_styles(global_var))
|
115
162
|
|
116
163
|
add_offense(node, message: message(global_var)) do |corrector|
|
117
164
|
autocorrect(corrector, node, global_var)
|
@@ -130,7 +177,11 @@ module RuboCop
|
|
130
177
|
def autocorrect(corrector, node, global_var)
|
131
178
|
node = node.parent while node.parent&.begin_type? && node.parent.children.one?
|
132
179
|
|
133
|
-
|
180
|
+
if should_require_english?(global_var)
|
181
|
+
ensure_required(corrector, node, LIBRARY_NAME)
|
182
|
+
|
183
|
+
@required_english = true
|
184
|
+
end
|
134
185
|
|
135
186
|
corrector.replace(node, replacement(node, global_var))
|
136
187
|
end
|
@@ -175,11 +226,17 @@ module RuboCop
|
|
175
226
|
end
|
176
227
|
|
177
228
|
def preferred_names(global)
|
178
|
-
|
179
|
-
|
180
|
-
else
|
181
|
-
PERL_VARS[global]
|
229
|
+
vars = STYLE_VARS_MAP.fetch(style) do
|
230
|
+
raise ArgumentError, "Invalid style: #{style.inspect}"
|
182
231
|
end
|
232
|
+
|
233
|
+
vars[global]
|
234
|
+
end
|
235
|
+
|
236
|
+
def matching_styles(global)
|
237
|
+
STYLE_VARS_MAP.map do |style, vars|
|
238
|
+
style if vars.values.flatten(1).include? global
|
239
|
+
end.compact
|
183
240
|
end
|
184
241
|
|
185
242
|
def english_name_replacement(preferred_name, node)
|
@@ -195,6 +252,7 @@ module RuboCop
|
|
195
252
|
def should_require_english?(global_var)
|
196
253
|
style == :use_english_names &&
|
197
254
|
add_require_english? &&
|
255
|
+
!@required_english &&
|
198
256
|
!NON_ENGLISH_VARS.include?(preferred_names(global_var).first)
|
199
257
|
end
|
200
258
|
end
|
@@ -52,7 +52,24 @@ module RuboCop
|
|
52
52
|
# @example AllowMethodsWithArguments: true
|
53
53
|
# # good
|
54
54
|
# something.do_something(foo) { |o| o.bar }
|
55
|
+
#
|
56
|
+
# @example AllowComments: false (default)
|
57
|
+
# # bad
|
58
|
+
# something.do_something do |s| # some comment
|
59
|
+
# # some comment
|
60
|
+
# s.upcase # some comment
|
61
|
+
# # some comment
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# @example AllowComments: true
|
65
|
+
# # good - if there are comment in either position
|
66
|
+
# something.do_something do |s| # some comment
|
67
|
+
# # some comment
|
68
|
+
# s.upcase # some comment
|
69
|
+
# # some comment
|
70
|
+
# end
|
55
71
|
class SymbolProc < Base
|
72
|
+
include CommentsHelp
|
56
73
|
include RangeHelp
|
57
74
|
include IgnoredMethods
|
58
75
|
extend AutoCorrector
|
@@ -78,6 +95,7 @@ module RuboCop
|
|
78
95
|
[Layout::SpaceBeforeBlockBraces]
|
79
96
|
end
|
80
97
|
|
98
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
81
99
|
def on_block(node)
|
82
100
|
symbol_proc?(node) do |dispatch_node, arguments_node, method_name|
|
83
101
|
# TODO: Rails-specific handling that we should probably make
|
@@ -88,10 +106,12 @@ module RuboCop
|
|
88
106
|
return if ignored_method?(dispatch_node.method_name)
|
89
107
|
return if allow_if_method_has_argument?(node)
|
90
108
|
return if node.block_type? && destructuring_block_argument?(arguments_node)
|
109
|
+
return if allow_comments? && contains_comments?(node)
|
91
110
|
|
92
111
|
register_offense(node, method_name, dispatch_node.method_name)
|
93
112
|
end
|
94
113
|
end
|
114
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
95
115
|
alias on_numblock on_block
|
96
116
|
|
97
117
|
def destructuring_block_argument?(argument_node)
|
@@ -148,6 +168,10 @@ module RuboCop
|
|
148
168
|
def allow_if_method_has_argument?(node)
|
149
169
|
!!cop_config.fetch('AllowMethodsWithArguments', false) && !node.arguments.count.zero?
|
150
170
|
end
|
171
|
+
|
172
|
+
def allow_comments?
|
173
|
+
cop_config.fetch('AllowComments', false)
|
174
|
+
end
|
151
175
|
end
|
152
176
|
end
|
153
177
|
end
|
data/lib/rubocop/options.rb
CHANGED
@@ -123,6 +123,8 @@ module RuboCop
|
|
123
123
|
option(opts, '--display-time')
|
124
124
|
option(opts, '--display-only-failed')
|
125
125
|
option(opts, '--display-only-fail-level-offenses')
|
126
|
+
option(opts, '--display-only-correctable')
|
127
|
+
option(opts, '--display-only-safe-correctable')
|
126
128
|
end
|
127
129
|
end
|
128
130
|
|
@@ -310,9 +312,12 @@ module RuboCop
|
|
310
312
|
raise OptionArgumentError, '--autocorrect cannot be used with ' \
|
311
313
|
'--display-only-fail-level-offenses'
|
312
314
|
end
|
315
|
+
|
313
316
|
validate_auto_gen_config
|
314
317
|
validate_auto_correct
|
315
318
|
validate_display_only_failed
|
319
|
+
validate_display_only_failed_and_display_only_correctable
|
320
|
+
validate_display_only_correctable_and_auto_correct
|
316
321
|
disable_parallel_when_invalid_option_combo
|
317
322
|
|
318
323
|
return if incompatible_options.size <= 1
|
@@ -342,6 +347,24 @@ module RuboCop
|
|
342
347
|
format('--display-only-failed can only be used together with --format junit.')
|
343
348
|
end
|
344
349
|
|
350
|
+
def validate_display_only_correctable_and_auto_correct
|
351
|
+
return if !@options.key?(:safe_auto_correct) && !@options.key?(:auto_correct)
|
352
|
+
return if !@options.key?(:display_only_correctable) &&
|
353
|
+
!@options.key?(:display_only_safe_correctable)
|
354
|
+
|
355
|
+
raise OptionArgumentError,
|
356
|
+
'--auto-correct cannot be used with --display-only-[safe-]correctable.'
|
357
|
+
end
|
358
|
+
|
359
|
+
def validate_display_only_failed_and_display_only_correctable
|
360
|
+
return unless @options.key?(:display_only_failed)
|
361
|
+
return if !@options.key?(:display_only_correctable) &&
|
362
|
+
!@options.key?(:display_only_safe_correctable)
|
363
|
+
|
364
|
+
raise OptionArgumentError,
|
365
|
+
format('--display-only-failed cannot be used together with other display options.')
|
366
|
+
end
|
367
|
+
|
345
368
|
def validate_auto_correct
|
346
369
|
return if @options.key?(:auto_correct)
|
347
370
|
return unless @options.key?(:disable_uncorrectable)
|
@@ -405,7 +428,7 @@ module RuboCop
|
|
405
428
|
def validate_cache_enabled_for_cache_root
|
406
429
|
return unless @options[:cache] == 'false'
|
407
430
|
|
408
|
-
raise OptionArgumentError, '--cache-root
|
431
|
+
raise OptionArgumentError, '--cache-root cannot be used with --cache false'
|
409
432
|
end
|
410
433
|
end
|
411
434
|
|
@@ -481,6 +504,9 @@ module RuboCop
|
|
481
504
|
display_only_fail_level_offenses:
|
482
505
|
['Only output offense messages at',
|
483
506
|
'the specified --fail-level or above'],
|
507
|
+
display_only_correctable: ['Only output correctable offense messages.'],
|
508
|
+
display_only_safe_correctable: ['Only output safe-correctable offense messages',
|
509
|
+
'when combined with --display-only-correctable.'],
|
484
510
|
show_cops: ['Shows the given cops, or all cops by',
|
485
511
|
'default, and their configurations for the',
|
486
512
|
'current directory.'],
|
data/lib/rubocop/result_cache.rb
CHANGED
@@ -66,12 +66,12 @@ module RuboCop
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def self.cache_root(config_store)
|
69
|
-
root = ENV
|
69
|
+
root = ENV.fetch('RUBOCOP_CACHE_ROOT', nil)
|
70
70
|
root ||= config_store.for_pwd.for_all_cops['CacheRootDirectory']
|
71
71
|
root ||= if ENV.key?('XDG_CACHE_HOME')
|
72
72
|
# Include user ID in the path to make sure the user has write
|
73
73
|
# access.
|
74
|
-
File.join(ENV
|
74
|
+
File.join(ENV.fetch('XDG_CACHE_HOME'), Process.uid.to_s)
|
75
75
|
else
|
76
76
|
# On FreeBSD, the /home path is a symbolic link to /usr/home
|
77
77
|
# and the $HOME environment variable returns the /home path.
|
@@ -81,7 +81,7 @@ module RuboCop
|
|
81
81
|
#
|
82
82
|
# To avoid raising warn log messages on FreeBSD, we retrieve
|
83
83
|
# the real path of the home folder.
|
84
|
-
File.join(File.realpath(ENV
|
84
|
+
File.join(File.realpath(ENV.fetch('HOME')), '.cache')
|
85
85
|
end
|
86
86
|
File.join(root, 'rubocop_cache')
|
87
87
|
end
|
@@ -5,8 +5,8 @@ require 'tmpdir'
|
|
5
5
|
RSpec.shared_context 'isolated environment', :isolated_environment do
|
6
6
|
around do |example|
|
7
7
|
Dir.mktmpdir do |tmpdir|
|
8
|
-
original_home = ENV
|
9
|
-
original_xdg_config_home = ENV
|
8
|
+
original_home = ENV.fetch('HOME', nil)
|
9
|
+
original_xdg_config_home = ENV.fetch('XDG_CONFIG_HOME', nil)
|
10
10
|
|
11
11
|
# Make sure to expand all symlinks in the path first. Otherwise we may
|
12
12
|
# get mismatched pathnames when loading config files later on.
|
data/lib/rubocop/runner.rb
CHANGED
@@ -207,9 +207,7 @@ module RuboCop
|
|
207
207
|
end
|
208
208
|
|
209
209
|
def file_finished(file, offenses)
|
210
|
-
|
211
|
-
offenses = offenses.select { |o| considered_failure?(o) }
|
212
|
-
end
|
210
|
+
offenses = offenses_to_report(offenses)
|
213
211
|
formatter_set.file_finished(file, offenses)
|
214
212
|
end
|
215
213
|
|
@@ -380,6 +378,34 @@ module RuboCop
|
|
380
378
|
!offense.corrected? && offense.severity >= minimum_severity_to_fail
|
381
379
|
end
|
382
380
|
|
381
|
+
def offenses_to_report(offenses)
|
382
|
+
if @options[:display_only_fail_level_offenses]
|
383
|
+
offenses.select { |o| considered_failure?(o) }
|
384
|
+
elsif @options[:display_only_safe_correctable]
|
385
|
+
offenses.select { |o| supports_safe_auto_correct?(o) }
|
386
|
+
elsif @options[:display_only_correctable]
|
387
|
+
offenses.select(&:correctable?)
|
388
|
+
else
|
389
|
+
offenses
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
def supports_safe_auto_correct?(offense)
|
394
|
+
cop_class = Cop::Registry.global.find_by_cop_name(offense.cop_name)
|
395
|
+
default_cfg = default_config(offense.cop_name)
|
396
|
+
|
397
|
+
offense.correctable? &&
|
398
|
+
cop_class&.support_autocorrect? && mark_as_safe_by_config?(default_cfg)
|
399
|
+
end
|
400
|
+
|
401
|
+
def mark_as_safe_by_config?(config)
|
402
|
+
config.nil? || (config.fetch('Safe', true) && config.fetch('SafeAutoCorrect', true))
|
403
|
+
end
|
404
|
+
|
405
|
+
def default_config(cop_name)
|
406
|
+
RuboCop::ConfigLoader.default_configuration[cop_name]
|
407
|
+
end
|
408
|
+
|
383
409
|
def minimum_severity_to_fail
|
384
410
|
@minimum_severity_to_fail ||= begin
|
385
411
|
# Unless given explicitly as `fail_level`, `:info` severity offenses do not fail
|
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
@@ -62,6 +62,7 @@ require_relative 'rubocop/cop/mixin/array_syntax'
|
|
62
62
|
require_relative 'rubocop/cop/mixin/alignment'
|
63
63
|
require_relative 'rubocop/cop/mixin/allowed_identifiers'
|
64
64
|
require_relative 'rubocop/cop/mixin/allowed_methods'
|
65
|
+
require_relative 'rubocop/cop/mixin/allowed_pattern'
|
65
66
|
require_relative 'rubocop/cop/mixin/auto_corrector'
|
66
67
|
require_relative 'rubocop/cop/mixin/check_assignment'
|
67
68
|
require_relative 'rubocop/cop/mixin/check_line_breakable'
|
@@ -86,7 +87,6 @@ require_relative 'rubocop/cop/mixin/gem_declaration'
|
|
86
87
|
require_relative 'rubocop/cop/mixin/gemspec_help'
|
87
88
|
require_relative 'rubocop/cop/mixin/hash_alignment_styles'
|
88
89
|
require_relative 'rubocop/cop/mixin/hash_transform_method'
|
89
|
-
require_relative 'rubocop/cop/mixin/ignored_pattern'
|
90
90
|
require_relative 'rubocop/cop/mixin/ignored_methods'
|
91
91
|
require_relative 'rubocop/cop/mixin/integer_node'
|
92
92
|
require_relative 'rubocop/cop/mixin/interpolation'
|
@@ -485,6 +485,7 @@ require_relative 'rubocop/cop/style/even_odd'
|
|
485
485
|
require_relative 'rubocop/cop/style/expand_path_arguments'
|
486
486
|
require_relative 'rubocop/cop/style/explicit_block_argument'
|
487
487
|
require_relative 'rubocop/cop/style/exponential_notation'
|
488
|
+
require_relative 'rubocop/cop/style/fetch_env_var'
|
488
489
|
require_relative 'rubocop/cop/style/file_read'
|
489
490
|
require_relative 'rubocop/cop/style/file_write'
|
490
491
|
require_relative 'rubocop/cop/style/float_division'
|
@@ -567,6 +568,7 @@ require_relative 'rubocop/cop/style/numbered_parameters_limit'
|
|
567
568
|
require_relative 'rubocop/cop/style/numeric_literals'
|
568
569
|
require_relative 'rubocop/cop/style/numeric_literal_prefix'
|
569
570
|
require_relative 'rubocop/cop/style/numeric_predicate'
|
571
|
+
require_relative 'rubocop/cop/style/object_then'
|
570
572
|
require_relative 'rubocop/cop/style/one_line_conditional'
|
571
573
|
require_relative 'rubocop/cop/style/or_assignment'
|
572
574
|
require_relative 'rubocop/cop/style/option_hash'
|
@@ -651,6 +653,7 @@ require_relative 'rubocop/cop/style/word_array'
|
|
651
653
|
require_relative 'rubocop/cop/style/yoda_condition'
|
652
654
|
require_relative 'rubocop/cop/style/zero_length_predicate'
|
653
655
|
|
656
|
+
require_relative 'rubocop/cop/security/compound_hash'
|
654
657
|
require_relative 'rubocop/cop/security/eval'
|
655
658
|
require_relative 'rubocop/cop/security/io_methods'
|
656
659
|
require_relative 'rubocop/cop/security/json_load'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.28.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-04-
|
13
|
+
date: 2022-04-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parallel
|
@@ -100,7 +100,7 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
103
|
+
version: 1.17.0
|
104
104
|
- - "<"
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '2.0'
|
@@ -110,7 +110,7 @@ dependencies:
|
|
110
110
|
requirements:
|
111
111
|
- - ">="
|
112
112
|
- !ruby/object:Gem::Version
|
113
|
-
version: 1.
|
113
|
+
version: 1.17.0
|
114
114
|
- - "<"
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '2.0'
|
@@ -522,6 +522,7 @@ files:
|
|
522
522
|
- lib/rubocop/cop/mixin/alignment.rb
|
523
523
|
- lib/rubocop/cop/mixin/allowed_identifiers.rb
|
524
524
|
- lib/rubocop/cop/mixin/allowed_methods.rb
|
525
|
+
- lib/rubocop/cop/mixin/allowed_pattern.rb
|
525
526
|
- lib/rubocop/cop/mixin/annotation_comment.rb
|
526
527
|
- lib/rubocop/cop/mixin/array_min_size.rb
|
527
528
|
- lib/rubocop/cop/mixin/array_syntax.rb
|
@@ -551,7 +552,6 @@ files:
|
|
551
552
|
- lib/rubocop/cop/mixin/hash_transform_method.rb
|
552
553
|
- lib/rubocop/cop/mixin/heredoc.rb
|
553
554
|
- lib/rubocop/cop/mixin/ignored_methods.rb
|
554
|
-
- lib/rubocop/cop/mixin/ignored_pattern.rb
|
555
555
|
- lib/rubocop/cop/mixin/integer_node.rb
|
556
556
|
- lib/rubocop/cop/mixin/interpolation.rb
|
557
557
|
- lib/rubocop/cop/mixin/line_length_help.rb
|
@@ -610,6 +610,7 @@ files:
|
|
610
610
|
- lib/rubocop/cop/naming/variable_number.rb
|
611
611
|
- lib/rubocop/cop/offense.rb
|
612
612
|
- lib/rubocop/cop/registry.rb
|
613
|
+
- lib/rubocop/cop/security/compound_hash.rb
|
613
614
|
- lib/rubocop/cop/security/eval.rb
|
614
615
|
- lib/rubocop/cop/security/io_methods.rb
|
615
616
|
- lib/rubocop/cop/security/json_load.rb
|
@@ -678,6 +679,7 @@ files:
|
|
678
679
|
- lib/rubocop/cop/style/expand_path_arguments.rb
|
679
680
|
- lib/rubocop/cop/style/explicit_block_argument.rb
|
680
681
|
- lib/rubocop/cop/style/exponential_notation.rb
|
682
|
+
- lib/rubocop/cop/style/fetch_env_var.rb
|
681
683
|
- lib/rubocop/cop/style/file_read.rb
|
682
684
|
- lib/rubocop/cop/style/file_write.rb
|
683
685
|
- lib/rubocop/cop/style/float_division.rb
|
@@ -753,6 +755,7 @@ files:
|
|
753
755
|
- lib/rubocop/cop/style/numeric_literal_prefix.rb
|
754
756
|
- lib/rubocop/cop/style/numeric_literals.rb
|
755
757
|
- lib/rubocop/cop/style/numeric_predicate.rb
|
758
|
+
- lib/rubocop/cop/style/object_then.rb
|
756
759
|
- lib/rubocop/cop/style/one_line_conditional.rb
|
757
760
|
- lib/rubocop/cop/style/open_struct_use.rb
|
758
761
|
- lib/rubocop/cop/style/option_hash.rb
|
@@ -915,7 +918,7 @@ metadata:
|
|
915
918
|
homepage_uri: https://rubocop.org/
|
916
919
|
changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
|
917
920
|
source_code_uri: https://github.com/rubocop/rubocop/
|
918
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
921
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.28/
|
919
922
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
920
923
|
rubygems_mfa_required: 'true'
|
921
924
|
post_install_message:
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
# This module encapsulates the ability to ignore certain lines when
|
6
|
-
# parsing.
|
7
|
-
module IgnoredPattern
|
8
|
-
private
|
9
|
-
|
10
|
-
def ignored_line?(line)
|
11
|
-
line = if line.respond_to?(:source_line)
|
12
|
-
line.source_line
|
13
|
-
elsif line.respond_to?(:node)
|
14
|
-
line.node.source_range.source_line
|
15
|
-
end
|
16
|
-
|
17
|
-
matches_ignored_pattern?(line)
|
18
|
-
end
|
19
|
-
|
20
|
-
def matches_ignored_pattern?(line)
|
21
|
-
ignored_patterns.any? { |pattern| Regexp.new(pattern).match?(line) }
|
22
|
-
end
|
23
|
-
|
24
|
-
def ignored_patterns
|
25
|
-
cop_config['IgnoredPatterns'] || []
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|