rubocop 0.78.0 → 0.82.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +4 -4
- data/config/default.yml +158 -48
- data/lib/rubocop.rb +19 -4
- data/lib/rubocop/ast/builder.rb +45 -42
- data/lib/rubocop/ast/node.rb +12 -19
- data/lib/rubocop/ast/node/array_node.rb +13 -0
- data/lib/rubocop/ast/node/block_node.rb +5 -1
- data/lib/rubocop/ast/node/case_match_node.rb +56 -0
- data/lib/rubocop/ast/node/def_node.rb +11 -0
- data/lib/rubocop/ast/node/forward_args_node.rb +18 -0
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +8 -0
- data/lib/rubocop/ast/node/regexp_node.rb +2 -4
- data/lib/rubocop/ast/traversal.rb +29 -10
- data/lib/rubocop/cli.rb +10 -4
- data/lib/rubocop/cli/command/show_cops.rb +11 -4
- data/lib/rubocop/comment_config.rb +6 -1
- data/lib/rubocop/config.rb +36 -10
- data/lib/rubocop/config_loader.rb +42 -33
- data/lib/rubocop/config_loader_resolver.rb +1 -1
- data/lib/rubocop/config_obsoletion.rb +4 -1
- data/lib/rubocop/config_validator.rb +66 -92
- data/lib/rubocop/cop/autocorrect_logic.rb +6 -3
- data/lib/rubocop/cop/badge.rb +5 -5
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +1 -1
- data/lib/rubocop/cop/corrector.rb +48 -24
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/condition_corrector.rb +1 -2
- data/lib/rubocop/cop/correctors/empty_line_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +3 -3
- data/lib/rubocop/cop/correctors/line_break_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/string_literal_corrector.rb +2 -2
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
- data/lib/rubocop/cop/generator.rb +3 -4
- data/lib/rubocop/cop/generator/configuration_injector.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +1 -1
- data/lib/rubocop/cop/layout/array_alignment.rb +53 -10
- data/lib/rubocop/cop/layout/block_end_newline.rb +5 -3
- data/lib/rubocop/cop/layout/dot_position.rb +1 -1
- data/lib/rubocop/cop/layout/else_alignment.rb +8 -0
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +2 -1
- data/lib/rubocop/cop/layout/end_of_line.rb +2 -2
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +16 -10
- data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/hash_alignment.rb +8 -4
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -2
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/{tab.rb → indentation_style.rb} +48 -6
- data/lib/rubocop/cop/layout/leading_comment_space.rb +34 -3
- data/lib/rubocop/cop/layout/line_length.rb +32 -3
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +15 -6
- data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +0 -4
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +3 -3
- data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +133 -0
- data/lib/rubocop/cop/layout/space_around_operators.rb +19 -1
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +2 -2
- data/lib/rubocop/cop/layout/space_before_first_arg.rb +8 -0
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +2 -2
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +2 -9
- data/lib/rubocop/cop/layout/space_inside_range_literal.rb +2 -2
- data/lib/rubocop/cop/lint/boolean_symbol.rb +12 -0
- data/lib/rubocop/cop/lint/debugger.rb +2 -2
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +1 -1
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
- data/lib/rubocop/cop/lint/inherit_exception.rb +1 -1
- data/lib/rubocop/cop/lint/interpolation_check.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/loop.rb +6 -4
- data/lib/rubocop/cop/lint/multiple_comparison.rb +1 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +2 -2
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +2 -2
- data/lib/rubocop/cop/lint/number_conversion.rb +1 -1
- data/lib/rubocop/cop/lint/percent_string_array.rb +2 -2
- data/lib/rubocop/cop/lint/raise_exception.rb +75 -0
- data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +12 -7
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +1 -1
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +1 -1
- data/lib/rubocop/cop/lint/struct_new_override.rb +58 -0
- data/lib/rubocop/cop/lint/suppressed_exception.rb +12 -22
- data/lib/rubocop/cop/lint/unified_integer.rb +0 -2
- data/lib/rubocop/cop/lint/unused_method_argument.rb +32 -6
- data/lib/rubocop/cop/lint/uri_regexp.rb +4 -4
- data/lib/rubocop/cop/lint/useless_setter_call.rb +4 -0
- data/lib/rubocop/cop/migration/department_name.rb +47 -6
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +4 -0
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +6 -1
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +7 -7
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +171 -0
- data/lib/rubocop/cop/mixin/line_length_help.rb +1 -1
- data/lib/rubocop/cop/mixin/method_complexity.rb +5 -0
- data/lib/rubocop/cop/mixin/statement_modifier.rb +4 -3
- data/lib/rubocop/cop/mixin/trailing_comma.rb +3 -10
- data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +1 -1
- data/lib/rubocop/cop/naming/constant_name.rb +2 -1
- data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +1 -1
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
- data/lib/rubocop/cop/naming/method_name.rb +30 -0
- data/lib/rubocop/cop/naming/method_parameter_name.rb +1 -1
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -1
- data/lib/rubocop/cop/registry.rb +15 -3
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +26 -6
- data/lib/rubocop/cop/style/alias.rb +4 -4
- data/lib/rubocop/cop/style/and_or.rb +5 -6
- data/lib/rubocop/cop/style/array_join.rb +1 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +60 -1
- data/lib/rubocop/cop/style/case_equality.rb +24 -1
- data/lib/rubocop/cop/style/character_literal.rb +2 -2
- data/lib/rubocop/cop/style/collection_methods.rb +2 -0
- data/lib/rubocop/cop/style/conditional_assignment.rb +8 -8
- data/lib/rubocop/cop/style/copyright.rb +1 -1
- data/lib/rubocop/cop/style/dir.rb +1 -1
- data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +49 -0
- data/lib/rubocop/cop/style/documentation.rb +43 -5
- data/lib/rubocop/cop/style/double_cop_disable_directive.rb +1 -1
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
- data/lib/rubocop/cop/style/each_with_object.rb +3 -3
- data/lib/rubocop/cop/style/empty_method.rb +1 -1
- data/lib/rubocop/cop/style/end_block.rb +6 -0
- data/lib/rubocop/cop/style/even_odd.rb +1 -1
- data/lib/rubocop/cop/style/expand_path_arguments.rb +3 -3
- data/lib/rubocop/cop/style/exponential_notation.rb +119 -0
- data/lib/rubocop/cop/style/format_string.rb +2 -2
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +89 -11
- data/lib/rubocop/cop/style/hash_each_methods.rb +89 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +3 -5
- data/lib/rubocop/cop/style/hash_transform_keys.rb +83 -0
- data/lib/rubocop/cop/style/hash_transform_values.rb +80 -0
- data/lib/rubocop/cop/style/if_unless_modifier.rb +23 -3
- data/lib/rubocop/cop/style/inverse_methods.rb +9 -5
- data/lib/rubocop/cop/style/lambda.rb +3 -2
- data/lib/rubocop/cop/style/lambda_call.rb +2 -2
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +7 -205
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +169 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +54 -0
- data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
- data/lib/rubocop/cop/style/module_function.rb +58 -12
- data/lib/rubocop/cop/style/multiline_if_modifier.rb +1 -1
- data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
- data/lib/rubocop/cop/style/multiline_when_then.rb +5 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +2 -4
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +4 -4
- data/lib/rubocop/cop/style/next.rb +2 -2
- data/lib/rubocop/cop/style/nil_comparison.rb +1 -1
- data/lib/rubocop/cop/style/non_nil_check.rb +4 -4
- data/lib/rubocop/cop/style/not.rb +1 -1
- data/lib/rubocop/cop/style/numeric_literal_prefix.rb +1 -1
- data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
- data/lib/rubocop/cop/style/numeric_predicate.rb +5 -4
- data/lib/rubocop/cop/style/one_line_conditional.rb +4 -3
- data/lib/rubocop/cop/style/or_assignment.rb +4 -3
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +7 -7
- data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
- data/lib/rubocop/cop/style/perl_backrefs.rb +2 -2
- data/lib/rubocop/cop/style/proc.rb +1 -1
- data/lib/rubocop/cop/style/raise_args.rb +1 -1
- data/lib/rubocop/cop/style/random_with_offset.rb +3 -3
- data/lib/rubocop/cop/style/redundant_condition.rb +18 -6
- data/lib/rubocop/cop/style/redundant_conditional.rb +1 -1
- data/lib/rubocop/cop/style/redundant_exception.rb +3 -3
- data/lib/rubocop/cop/style/redundant_interpolation.rb +2 -2
- data/lib/rubocop/cop/style/redundant_percent_q.rb +2 -2
- data/lib/rubocop/cop/style/redundant_return.rb +5 -7
- data/lib/rubocop/cop/style/redundant_self.rb +1 -1
- data/lib/rubocop/cop/style/redundant_sort.rb +2 -2
- data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
- data/lib/rubocop/cop/style/return_nil.rb +1 -1
- data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
- data/lib/rubocop/cop/style/self_assignment.rb +1 -1
- data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +1 -4
- data/lib/rubocop/cop/style/string_hash_keys.rb +1 -1
- data/lib/rubocop/cop/style/symbol_array.rb +3 -3
- data/lib/rubocop/cop/style/symbol_literal.rb +2 -2
- data/lib/rubocop/cop/style/ternary_parentheses.rb +2 -3
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +35 -22
- data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +41 -0
- data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +88 -0
- data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +44 -0
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/style/unpack_first.rb +0 -4
- data/lib/rubocop/cop/style/variable_interpolation.rb +1 -1
- data/lib/rubocop/cop/style/while_until_modifier.rb +1 -1
- data/lib/rubocop/cop/style/word_array.rb +1 -1
- data/lib/rubocop/cop/style/yoda_condition.rb +16 -1
- data/lib/rubocop/cop/style/zero_length_predicate.rb +1 -1
- data/lib/rubocop/cop/variable_force.rb +4 -1
- data/lib/rubocop/formatter/clang_style_formatter.rb +1 -1
- data/lib/rubocop/formatter/formatter_set.rb +1 -1
- data/lib/rubocop/formatter/junit_formatter.rb +74 -0
- data/lib/rubocop/formatter/pacman_formatter.rb +1 -1
- data/lib/rubocop/formatter/tap_formatter.rb +1 -1
- data/lib/rubocop/node_pattern.rb +96 -10
- data/lib/rubocop/options.rb +7 -1
- data/lib/rubocop/processed_source.rb +1 -4
- data/lib/rubocop/rspec/cop_helper.rb +1 -1
- data/lib/rubocop/rspec/expect_offense.rb +1 -1
- data/lib/rubocop/rspec/shared_contexts.rb +5 -4
- data/lib/rubocop/runner.rb +1 -1
- data/lib/rubocop/target_ruby.rb +151 -0
- data/lib/rubocop/version.rb +1 -1
- metadata +39 -12
- data/lib/rubocop/cop/lint/end_in_method.rb +0 -40
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +0 -209
- data/lib/rubocop/formatter/disabled_lines_formatter.rb +0 -57
data/lib/rubocop/version.rb
CHANGED
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: 0.
|
4
|
+
version: 0.82.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:
|
13
|
+
date: 2020-04-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: jaro_winkler
|
@@ -46,14 +46,14 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
49
|
+
version: 2.7.0.1
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
56
|
+
version: 2.7.0.1
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: rainbow
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,6 +74,20 @@ dependencies:
|
|
74
74
|
- - "<"
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '4.0'
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: rexml
|
79
|
+
requirement: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
type: :runtime
|
85
|
+
prerelease: false
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
77
91
|
- !ruby/object:Gem::Dependency
|
78
92
|
name: ruby-progressbar
|
79
93
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,7 +111,7 @@ dependencies:
|
|
97
111
|
version: 1.4.0
|
98
112
|
- - "<"
|
99
113
|
- !ruby/object:Gem::Version
|
100
|
-
version: '
|
114
|
+
version: '2.0'
|
101
115
|
type: :runtime
|
102
116
|
prerelease: false
|
103
117
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -107,7 +121,7 @@ dependencies:
|
|
107
121
|
version: 1.4.0
|
108
122
|
- - "<"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
124
|
+
version: '2.0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: bundler
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,6 +170,7 @@ files:
|
|
156
170
|
- lib/rubocop/ast/node/array_node.rb
|
157
171
|
- lib/rubocop/ast/node/block_node.rb
|
158
172
|
- lib/rubocop/ast/node/break_node.rb
|
173
|
+
- lib/rubocop/ast/node/case_match_node.rb
|
159
174
|
- lib/rubocop/ast/node/case_node.rb
|
160
175
|
- lib/rubocop/ast/node/class_node.rb
|
161
176
|
- lib/rubocop/ast/node/def_node.rb
|
@@ -163,6 +178,7 @@ files:
|
|
163
178
|
- lib/rubocop/ast/node/ensure_node.rb
|
164
179
|
- lib/rubocop/ast/node/float_node.rb
|
165
180
|
- lib/rubocop/ast/node/for_node.rb
|
181
|
+
- lib/rubocop/ast/node/forward_args_node.rb
|
166
182
|
- lib/rubocop/ast/node/hash_node.rb
|
167
183
|
- lib/rubocop/ast/node/if_node.rb
|
168
184
|
- lib/rubocop/ast/node/int_node.rb
|
@@ -298,6 +314,7 @@ files:
|
|
298
314
|
- lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb
|
299
315
|
- lib/rubocop/cop/layout/heredoc_indentation.rb
|
300
316
|
- lib/rubocop/cop/layout/indentation_consistency.rb
|
317
|
+
- lib/rubocop/cop/layout/indentation_style.rb
|
301
318
|
- lib/rubocop/cop/layout/indentation_width.rb
|
302
319
|
- lib/rubocop/cop/layout/initial_indentation.rb
|
303
320
|
- lib/rubocop/cop/layout/leading_comment_space.rb
|
@@ -324,6 +341,7 @@ files:
|
|
324
341
|
- lib/rubocop/cop/layout/space_around_block_parameters.rb
|
325
342
|
- lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb
|
326
343
|
- lib/rubocop/cop/layout/space_around_keyword.rb
|
344
|
+
- lib/rubocop/cop/layout/space_around_method_call_operator.rb
|
327
345
|
- lib/rubocop/cop/layout/space_around_operators.rb
|
328
346
|
- lib/rubocop/cop/layout/space_before_block_braces.rb
|
329
347
|
- lib/rubocop/cop/layout/space_before_comma.rb
|
@@ -340,7 +358,6 @@ files:
|
|
340
358
|
- lib/rubocop/cop/layout/space_inside_range_literal.rb
|
341
359
|
- lib/rubocop/cop/layout/space_inside_reference_brackets.rb
|
342
360
|
- lib/rubocop/cop/layout/space_inside_string_interpolation.rb
|
343
|
-
- lib/rubocop/cop/layout/tab.rb
|
344
361
|
- lib/rubocop/cop/layout/trailing_empty_lines.rb
|
345
362
|
- lib/rubocop/cop/layout/trailing_whitespace.rb
|
346
363
|
- lib/rubocop/cop/lint/ambiguous_block_association.rb
|
@@ -362,7 +379,6 @@ files:
|
|
362
379
|
- lib/rubocop/cop/lint/empty_expression.rb
|
363
380
|
- lib/rubocop/cop/lint/empty_interpolation.rb
|
364
381
|
- lib/rubocop/cop/lint/empty_when.rb
|
365
|
-
- lib/rubocop/cop/lint/end_in_method.rb
|
366
382
|
- lib/rubocop/cop/lint/ensure_return.rb
|
367
383
|
- lib/rubocop/cop/lint/erb_new_arguments.rb
|
368
384
|
- lib/rubocop/cop/lint/flip_flop.rb
|
@@ -388,6 +404,7 @@ files:
|
|
388
404
|
- lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb
|
389
405
|
- lib/rubocop/cop/lint/percent_string_array.rb
|
390
406
|
- lib/rubocop/cop/lint/percent_symbol_array.rb
|
407
|
+
- lib/rubocop/cop/lint/raise_exception.rb
|
391
408
|
- lib/rubocop/cop/lint/rand_one.rb
|
392
409
|
- lib/rubocop/cop/lint/redundant_cop_disable_directive.rb
|
393
410
|
- lib/rubocop/cop/lint/redundant_cop_enable_directive.rb
|
@@ -409,6 +426,7 @@ files:
|
|
409
426
|
- lib/rubocop/cop/lint/shadowed_argument.rb
|
410
427
|
- lib/rubocop/cop/lint/shadowed_exception.rb
|
411
428
|
- lib/rubocop/cop/lint/shadowing_outer_local_variable.rb
|
429
|
+
- lib/rubocop/cop/lint/struct_new_override.rb
|
412
430
|
- lib/rubocop/cop/lint/suppressed_exception.rb
|
413
431
|
- lib/rubocop/cop/lint/syntax.rb
|
414
432
|
- lib/rubocop/cop/lint/to_json.rb
|
@@ -460,6 +478,7 @@ files:
|
|
460
478
|
- lib/rubocop/cop/mixin/first_element_line_break.rb
|
461
479
|
- lib/rubocop/cop/mixin/frozen_string_literal.rb
|
462
480
|
- lib/rubocop/cop/mixin/hash_alignment_styles.rb
|
481
|
+
- lib/rubocop/cop/mixin/hash_transform_method.rb
|
463
482
|
- lib/rubocop/cop/mixin/heredoc.rb
|
464
483
|
- lib/rubocop/cop/mixin/ignored_methods.rb
|
465
484
|
- lib/rubocop/cop/mixin/ignored_pattern.rb
|
@@ -535,7 +554,6 @@ files:
|
|
535
554
|
- lib/rubocop/cop/style/begin_block.rb
|
536
555
|
- lib/rubocop/cop/style/block_comments.rb
|
537
556
|
- lib/rubocop/cop/style/block_delimiters.rb
|
538
|
-
- lib/rubocop/cop/style/braces_around_hash_parameters.rb
|
539
557
|
- lib/rubocop/cop/style/case_equality.rb
|
540
558
|
- lib/rubocop/cop/style/character_literal.rb
|
541
559
|
- lib/rubocop/cop/style/class_and_module_children.rb
|
@@ -554,6 +572,7 @@ files:
|
|
554
572
|
- lib/rubocop/cop/style/date_time.rb
|
555
573
|
- lib/rubocop/cop/style/def_with_parentheses.rb
|
556
574
|
- lib/rubocop/cop/style/dir.rb
|
575
|
+
- lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb
|
557
576
|
- lib/rubocop/cop/style/documentation.rb
|
558
577
|
- lib/rubocop/cop/style/documentation_method.rb
|
559
578
|
- lib/rubocop/cop/style/double_cop_disable_directive.rb
|
@@ -571,6 +590,7 @@ files:
|
|
571
590
|
- lib/rubocop/cop/style/eval_with_location.rb
|
572
591
|
- lib/rubocop/cop/style/even_odd.rb
|
573
592
|
- lib/rubocop/cop/style/expand_path_arguments.rb
|
593
|
+
- lib/rubocop/cop/style/exponential_notation.rb
|
574
594
|
- lib/rubocop/cop/style/float_division.rb
|
575
595
|
- lib/rubocop/cop/style/for.rb
|
576
596
|
- lib/rubocop/cop/style/format_string.rb
|
@@ -578,7 +598,10 @@ files:
|
|
578
598
|
- lib/rubocop/cop/style/frozen_string_literal_comment.rb
|
579
599
|
- lib/rubocop/cop/style/global_vars.rb
|
580
600
|
- lib/rubocop/cop/style/guard_clause.rb
|
601
|
+
- lib/rubocop/cop/style/hash_each_methods.rb
|
581
602
|
- lib/rubocop/cop/style/hash_syntax.rb
|
603
|
+
- lib/rubocop/cop/style/hash_transform_keys.rb
|
604
|
+
- lib/rubocop/cop/style/hash_transform_values.rb
|
582
605
|
- lib/rubocop/cop/style/identical_conditional_branches.rb
|
583
606
|
- lib/rubocop/cop/style/if_inside_else.rb
|
584
607
|
- lib/rubocop/cop/style/if_unless_modifier.rb
|
@@ -593,6 +616,8 @@ files:
|
|
593
616
|
- lib/rubocop/cop/style/lambda_call.rb
|
594
617
|
- lib/rubocop/cop/style/line_end_concatenation.rb
|
595
618
|
- lib/rubocop/cop/style/method_call_with_args_parentheses.rb
|
619
|
+
- lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb
|
620
|
+
- lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb
|
596
621
|
- lib/rubocop/cop/style/method_call_without_args_parentheses.rb
|
597
622
|
- lib/rubocop/cop/style/method_called_on_do_end_block.rb
|
598
623
|
- lib/rubocop/cop/style/method_def_parentheses.rb
|
@@ -681,6 +706,7 @@ files:
|
|
681
706
|
- lib/rubocop/cop/style/trailing_body_on_module.rb
|
682
707
|
- lib/rubocop/cop/style/trailing_comma_in_arguments.rb
|
683
708
|
- lib/rubocop/cop/style/trailing_comma_in_array_literal.rb
|
709
|
+
- lib/rubocop/cop/style/trailing_comma_in_block_args.rb
|
684
710
|
- lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
|
685
711
|
- lib/rubocop/cop/style/trailing_method_end_statement.rb
|
686
712
|
- lib/rubocop/cop/style/trailing_underscore_variable.rb
|
@@ -713,13 +739,13 @@ files:
|
|
713
739
|
- lib/rubocop/formatter/clang_style_formatter.rb
|
714
740
|
- lib/rubocop/formatter/colorizable.rb
|
715
741
|
- lib/rubocop/formatter/disabled_config_formatter.rb
|
716
|
-
- lib/rubocop/formatter/disabled_lines_formatter.rb
|
717
742
|
- lib/rubocop/formatter/emacs_style_formatter.rb
|
718
743
|
- lib/rubocop/formatter/file_list_formatter.rb
|
719
744
|
- lib/rubocop/formatter/formatter_set.rb
|
720
745
|
- lib/rubocop/formatter/fuubar_style_formatter.rb
|
721
746
|
- lib/rubocop/formatter/html_formatter.rb
|
722
747
|
- lib/rubocop/formatter/json_formatter.rb
|
748
|
+
- lib/rubocop/formatter/junit_formatter.rb
|
723
749
|
- lib/rubocop/formatter/offense_count_formatter.rb
|
724
750
|
- lib/rubocop/formatter/pacman_formatter.rb
|
725
751
|
- lib/rubocop/formatter/progress_formatter.rb
|
@@ -747,6 +773,7 @@ files:
|
|
747
773
|
- lib/rubocop/string_interpreter.rb
|
748
774
|
- lib/rubocop/string_util.rb
|
749
775
|
- lib/rubocop/target_finder.rb
|
776
|
+
- lib/rubocop/target_ruby.rb
|
750
777
|
- lib/rubocop/token.rb
|
751
778
|
- lib/rubocop/version.rb
|
752
779
|
- lib/rubocop/warning.rb
|
@@ -768,14 +795,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
768
795
|
requirements:
|
769
796
|
- - ">="
|
770
797
|
- !ruby/object:Gem::Version
|
771
|
-
version: 2.
|
798
|
+
version: 2.4.0
|
772
799
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
773
800
|
requirements:
|
774
801
|
- - ">="
|
775
802
|
- !ruby/object:Gem::Version
|
776
803
|
version: '0'
|
777
804
|
requirements: []
|
778
|
-
rubygems_version: 3.
|
805
|
+
rubygems_version: 3.1.2
|
779
806
|
signing_key:
|
780
807
|
specification_version: 4
|
781
808
|
summary: Automatic Ruby code style checking tool.
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module Lint
|
6
|
-
# This cop checks for END blocks in method definitions.
|
7
|
-
#
|
8
|
-
# @example
|
9
|
-
#
|
10
|
-
# # bad
|
11
|
-
#
|
12
|
-
# def some_method
|
13
|
-
# END { do_something }
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# @example
|
17
|
-
#
|
18
|
-
# # good
|
19
|
-
#
|
20
|
-
# def some_method
|
21
|
-
# at_exit { do_something }
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
# @example
|
25
|
-
#
|
26
|
-
# # good
|
27
|
-
#
|
28
|
-
# # outside defs
|
29
|
-
# END { do_something }
|
30
|
-
class EndInMethod < Cop
|
31
|
-
MSG = '`END` found in method definition. Use `at_exit` instead.'
|
32
|
-
|
33
|
-
def on_postexe(node)
|
34
|
-
inside_of_method = node.each_ancestor(:def, :defs).count.nonzero?
|
35
|
-
add_offense(node, location: :keyword) if inside_of_method
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,209 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module Style
|
6
|
-
# This cop checks for braces around the last parameter in a method call
|
7
|
-
# if the last parameter is a hash.
|
8
|
-
# It supports `braces`, `no_braces` and `context_dependent` styles.
|
9
|
-
#
|
10
|
-
# @example EnforcedStyle: braces
|
11
|
-
# # The `braces` style enforces braces around all method
|
12
|
-
# # parameters that are hashes.
|
13
|
-
#
|
14
|
-
# # bad
|
15
|
-
# some_method(x, y, a: 1, b: 2)
|
16
|
-
#
|
17
|
-
# # good
|
18
|
-
# some_method(x, y, {a: 1, b: 2})
|
19
|
-
#
|
20
|
-
# @example EnforcedStyle: no_braces (default)
|
21
|
-
# # The `no_braces` style checks that the last parameter doesn't
|
22
|
-
# # have braces around it.
|
23
|
-
#
|
24
|
-
# # bad
|
25
|
-
# some_method(x, y, {a: 1, b: 2})
|
26
|
-
#
|
27
|
-
# # good
|
28
|
-
# some_method(x, y, a: 1, b: 2)
|
29
|
-
#
|
30
|
-
# @example EnforcedStyle: context_dependent
|
31
|
-
# # The `context_dependent` style checks that the last parameter
|
32
|
-
# # doesn't have braces around it, but requires braces if the
|
33
|
-
# # second to last parameter is also a hash literal.
|
34
|
-
#
|
35
|
-
# # bad
|
36
|
-
# some_method(x, y, {a: 1, b: 2})
|
37
|
-
# some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)
|
38
|
-
#
|
39
|
-
# # good
|
40
|
-
# some_method(x, y, a: 1, b: 2)
|
41
|
-
# some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})
|
42
|
-
class BracesAroundHashParameters < Cop
|
43
|
-
include ConfigurableEnforcedStyle
|
44
|
-
include RangeHelp
|
45
|
-
|
46
|
-
MSG = '%<type>s curly braces around a hash parameter.'
|
47
|
-
|
48
|
-
def on_send(node)
|
49
|
-
return if node.assignment_method? || node.operator_method?
|
50
|
-
|
51
|
-
return unless node.arguments? && node.last_argument.hash_type? &&
|
52
|
-
!node.last_argument.empty?
|
53
|
-
|
54
|
-
check(node.last_argument, node.arguments)
|
55
|
-
end
|
56
|
-
alias on_csend on_send
|
57
|
-
|
58
|
-
def autocorrect(send_node)
|
59
|
-
hash_node = send_node.last_argument
|
60
|
-
|
61
|
-
lambda do |corrector|
|
62
|
-
if hash_node.braces?
|
63
|
-
remove_braces_with_whitespace(corrector,
|
64
|
-
hash_node,
|
65
|
-
extra_space(hash_node))
|
66
|
-
else
|
67
|
-
add_braces(corrector, hash_node)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
private
|
73
|
-
|
74
|
-
def check(arg, args)
|
75
|
-
case style
|
76
|
-
when :braces
|
77
|
-
check_braces(arg)
|
78
|
-
when :no_braces
|
79
|
-
check_no_braces(arg)
|
80
|
-
when :context_dependent
|
81
|
-
check_context_dependent(arg, args)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def check_braces(arg)
|
86
|
-
add_arg_offense(arg, :missing) unless arg.braces?
|
87
|
-
end
|
88
|
-
|
89
|
-
def check_no_braces(arg)
|
90
|
-
return unless arg.braces? && !braces_needed_for_semantics?(arg)
|
91
|
-
|
92
|
-
add_arg_offense(arg, :redundant)
|
93
|
-
end
|
94
|
-
|
95
|
-
def check_context_dependent(arg, args)
|
96
|
-
braces_around_second_from_end = args.size > 1 && args[-2].hash_type?
|
97
|
-
|
98
|
-
if arg.braces?
|
99
|
-
unless braces_around_second_from_end ||
|
100
|
-
braces_needed_for_semantics?(arg)
|
101
|
-
add_arg_offense(arg, :redundant)
|
102
|
-
end
|
103
|
-
elsif braces_around_second_from_end
|
104
|
-
add_arg_offense(arg, :missing)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
# Returns true if there's block inside the braces of the given hash arg
|
109
|
-
# and that block uses do..end. The reason for wanting to check this is
|
110
|
-
# that the do..end could bind to a different method invocation if the
|
111
|
-
# hash braces were removed.
|
112
|
-
def braces_needed_for_semantics?(arg)
|
113
|
-
arg.each_pair do |_key, value|
|
114
|
-
return true if value.block_type? && !value.braces?
|
115
|
-
end
|
116
|
-
false
|
117
|
-
end
|
118
|
-
|
119
|
-
def add_arg_offense(arg, type)
|
120
|
-
add_offense(arg.parent, location: arg.source_range,
|
121
|
-
message: format(MSG,
|
122
|
-
type: type.to_s.capitalize))
|
123
|
-
end
|
124
|
-
|
125
|
-
def extra_space(hash_node)
|
126
|
-
{
|
127
|
-
newlines: extra_left_space?(hash_node) &&
|
128
|
-
extra_right_space?(hash_node),
|
129
|
-
left: extra_left_space?(hash_node),
|
130
|
-
right: extra_right_space?(hash_node)
|
131
|
-
}
|
132
|
-
end
|
133
|
-
|
134
|
-
def extra_left_space?(hash_node)
|
135
|
-
@extra_left_space ||= begin
|
136
|
-
top_line = hash_node.source_range.source_line
|
137
|
-
top_line.delete(' ') == '{'
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def extra_right_space?(hash_node)
|
142
|
-
@extra_right_space ||= begin
|
143
|
-
bottom_line_number = hash_node.source_range.last_line
|
144
|
-
bottom_line = processed_source.lines[bottom_line_number - 1]
|
145
|
-
bottom_line.delete(' ') == '}'
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def remove_braces_with_whitespace(corrector, node, space)
|
150
|
-
loc = node.loc
|
151
|
-
|
152
|
-
if node.multiline?
|
153
|
-
remove_braces_with_range(corrector,
|
154
|
-
left_whole_line_range(loc.begin),
|
155
|
-
right_whole_line_range(loc.end))
|
156
|
-
else
|
157
|
-
remove_braces_with_range(corrector,
|
158
|
-
left_brace_and_space(loc.begin, space),
|
159
|
-
right_brace_and_space(loc.end, space))
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
def remove_braces_with_range(corrector, left_range, right_range)
|
164
|
-
corrector.remove(left_range)
|
165
|
-
corrector.remove(right_range)
|
166
|
-
end
|
167
|
-
|
168
|
-
def left_whole_line_range(loc_begin)
|
169
|
-
if range_by_whole_lines(loc_begin).source.strip == '{'
|
170
|
-
range_by_whole_lines(loc_begin, include_final_newline: true)
|
171
|
-
else
|
172
|
-
loc_begin
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
def right_whole_line_range(loc_end)
|
177
|
-
if range_by_whole_lines(loc_end).source.strip =~ /\A}\s*,?\z/
|
178
|
-
range_by_whole_lines(loc_end, include_final_newline: true)
|
179
|
-
else
|
180
|
-
loc_end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
def left_brace_and_space(loc_begin, space)
|
185
|
-
range_with_surrounding_space(range: loc_begin,
|
186
|
-
side: :right,
|
187
|
-
newlines: space[:newlines],
|
188
|
-
whitespace: space[:left])
|
189
|
-
end
|
190
|
-
|
191
|
-
def right_brace_and_space(loc_end, space)
|
192
|
-
brace_and_space =
|
193
|
-
range_with_surrounding_space(
|
194
|
-
range: loc_end,
|
195
|
-
side: :left,
|
196
|
-
newlines: space[:newlines],
|
197
|
-
whitespace: space[:right]
|
198
|
-
)
|
199
|
-
range_with_surrounding_comma(brace_and_space, :left)
|
200
|
-
end
|
201
|
-
|
202
|
-
def add_braces(corrector, node)
|
203
|
-
corrector.insert_before(node.source_range, '{')
|
204
|
-
corrector.insert_after(node.source_range, '}')
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|