rubocop 1.57.1 → 1.65.0
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/LICENSE.txt +1 -1
- data/README.md +4 -5
- data/assets/output.css.erb +159 -0
- data/assets/output.html.erb +1 -160
- data/config/default.yml +136 -19
- data/lib/rubocop/cached_data.rb +11 -3
- data/lib/rubocop/cli/command/auto_generate_config.rb +22 -8
- data/lib/rubocop/cli/command/lsp.rb +2 -2
- data/lib/rubocop/cli/command/show_docs_url.rb +2 -2
- data/lib/rubocop/cli.rb +10 -1
- data/lib/rubocop/config.rb +36 -12
- data/lib/rubocop/config_finder.rb +12 -2
- data/lib/rubocop/config_loader.rb +1 -2
- data/lib/rubocop/config_loader_resolver.rb +9 -3
- data/lib/rubocop/config_obsoletion.rb +11 -8
- data/lib/rubocop/config_validator.rb +14 -7
- data/lib/rubocop/cop/autocorrect_logic.rb +6 -1
- data/lib/rubocop/cop/base.rb +63 -16
- data/lib/rubocop/cop/bundler/gem_comment.rb +2 -2
- data/lib/rubocop/cop/bundler/gem_version.rb +3 -5
- data/lib/rubocop/cop/cop.rb +20 -2
- data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +4 -8
- data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +5 -13
- data/lib/rubocop/cop/documentation.rb +16 -6
- data/lib/rubocop/cop/exclude_limit.rb +1 -1
- data/lib/rubocop/cop/force.rb +12 -0
- data/lib/rubocop/cop/gemspec/add_runtime_dependency.rb +38 -0
- data/lib/rubocop/cop/gemspec/dependency_version.rb +3 -5
- data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +2 -2
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +2 -2
- data/lib/rubocop/cop/gemspec/required_ruby_version.rb +5 -1
- data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +3 -3
- data/lib/rubocop/cop/internal_affairs/example_description.rb +6 -5
- data/lib/rubocop/cop/internal_affairs/method_name_end_with.rb +8 -6
- data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +19 -20
- data/lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb +53 -0
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +123 -29
- data/lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb +34 -0
- data/lib/rubocop/cop/internal_affairs.rb +2 -0
- data/lib/rubocop/cop/layout/argument_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/case_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/empty_comment.rb +3 -1
- data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +14 -7
- data/lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb +1 -1
- data/lib/rubocop/cop/layout/end_alignment.rb +15 -3
- data/lib/rubocop/cop/layout/extra_spacing.rb +4 -10
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +24 -7
- data/lib/rubocop/cop/layout/first_parameter_indentation.rb +1 -1
- 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/indentation_width.rb +1 -1
- data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +1 -1
- data/lib/rubocop/cop/layout/line_length.rb +20 -20
- data/lib/rubocop/cop/layout/redundant_line_break.rb +16 -3
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +4 -4
- data/lib/rubocop/cop/layout/single_line_block_chain.rb +5 -0
- data/lib/rubocop/cop/layout/space_around_operators.rb +53 -20
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +19 -10
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +3 -4
- data/lib/rubocop/cop/legacy/corrector.rb +12 -2
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +6 -6
- data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +2 -2
- data/lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb +1 -1
- data/lib/rubocop/cop/lint/debugger.rb +29 -3
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_case_condition.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_methods.rb +1 -1
- data/lib/rubocop/cop/lint/empty_conditional_body.rb +2 -2
- data/lib/rubocop/cop/lint/empty_when.rb +1 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +24 -17
- data/lib/rubocop/cop/lint/float_comparison.rb +10 -0
- data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +2 -1
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +14 -7
- data/lib/rubocop/cop/lint/it_without_arguments_in_block.rb +56 -0
- data/lib/rubocop/cop/lint/literal_as_condition.rb +1 -1
- data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +85 -0
- data/lib/rubocop/cop/lint/mixed_case_range.rb +9 -4
- data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +6 -21
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +3 -5
- data/lib/rubocop/cop/lint/number_conversion.rb +9 -4
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +54 -6
- data/lib/rubocop/cop/lint/redundant_with_index.rb +6 -2
- data/lib/rubocop/cop/lint/redundant_with_object.rb +2 -2
- data/lib/rubocop/cop/lint/rescue_type.rb +1 -3
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +3 -4
- data/lib/rubocop/cop/lint/script_permission.rb +3 -3
- data/lib/rubocop/cop/lint/self_assignment.rb +38 -0
- data/lib/rubocop/cop/lint/shadowed_argument.rb +1 -0
- data/lib/rubocop/cop/lint/symbol_conversion.rb +7 -2
- data/lib/rubocop/cop/lint/syntax.rb +6 -3
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +1 -3
- data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +1 -1
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +3 -2
- data/lib/rubocop/cop/lint/unreachable_code.rb +4 -2
- data/lib/rubocop/cop/lint/unreachable_loop.rb +8 -2
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +2 -2
- data/lib/rubocop/cop/lint/useless_times.rb +2 -2
- data/lib/rubocop/cop/lint/void.rb +53 -12
- data/lib/rubocop/cop/metrics/abc_size.rb +3 -3
- data/lib/rubocop/cop/metrics/block_nesting.rb +19 -7
- data/lib/rubocop/cop/metrics/class_length.rb +6 -1
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +5 -5
- data/lib/rubocop/cop/mixin/alignment.rb +5 -1
- data/lib/rubocop/cop/mixin/allowed_methods.rb +7 -1
- data/lib/rubocop/cop/mixin/allowed_pattern.rb +15 -3
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +1 -1
- data/lib/rubocop/cop/mixin/code_length.rb +12 -1
- data/lib/rubocop/cop/mixin/comments_help.rb +16 -12
- data/lib/rubocop/cop/mixin/configurable_formatting.rb +1 -0
- data/lib/rubocop/cop/mixin/configurable_max.rb +5 -1
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +23 -13
- data/lib/rubocop/cop/mixin/method_complexity.rb +15 -6
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +1 -1
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/rescue_node.rb +4 -0
- data/lib/rubocop/cop/mixin/safe_assignment.rb +1 -1
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
- data/lib/rubocop/cop/naming/block_forwarding.rb +34 -7
- data/lib/rubocop/cop/naming/constant_name.rb +1 -2
- data/lib/rubocop/cop/naming/file_name.rb +2 -2
- data/lib/rubocop/cop/naming/inclusive_language.rb +1 -2
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
- data/lib/rubocop/cop/naming/predicate_name.rb +2 -2
- data/lib/rubocop/cop/registry.rb +1 -1
- data/lib/rubocop/cop/security/compound_hash.rb +2 -2
- data/lib/rubocop/cop/security/open.rb +2 -2
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +52 -2
- data/lib/rubocop/cop/style/accessor_grouping.rb +1 -1
- data/lib/rubocop/cop/style/alias.rb +1 -0
- data/lib/rubocop/cop/style/arguments_forwarding.rb +155 -21
- data/lib/rubocop/cop/style/array_first_last.rb +64 -0
- data/lib/rubocop/cop/style/auto_resource_cleanup.rb +21 -14
- data/lib/rubocop/cop/style/bisected_attr_accessor.rb +2 -2
- data/lib/rubocop/cop/style/case_like_if.rb +5 -5
- data/lib/rubocop/cop/style/class_check.rb +1 -0
- data/lib/rubocop/cop/style/class_vars.rb +3 -3
- data/lib/rubocop/cop/style/collection_compact.rb +21 -11
- data/lib/rubocop/cop/style/combinable_loops.rb +13 -7
- data/lib/rubocop/cop/style/commented_keyword.rb +5 -2
- data/lib/rubocop/cop/style/concat_array_literals.rb +1 -0
- data/lib/rubocop/cop/style/conditional_assignment.rb +7 -8
- data/lib/rubocop/cop/style/copyright.rb +31 -21
- data/lib/rubocop/cop/style/date_time.rb +5 -4
- data/lib/rubocop/cop/style/documentation.rb +24 -24
- data/lib/rubocop/cop/style/documentation_method.rb +20 -0
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +7 -7
- data/lib/rubocop/cop/style/each_with_object.rb +2 -2
- data/lib/rubocop/cop/style/empty_literal.rb +1 -1
- data/lib/rubocop/cop/style/eval_with_location.rb +6 -15
- data/lib/rubocop/cop/style/exact_regexp_match.rb +4 -2
- data/lib/rubocop/cop/style/explicit_block_argument.rb +2 -2
- data/lib/rubocop/cop/style/for.rb +2 -0
- data/lib/rubocop/cop/style/format_string.rb +9 -9
- data/lib/rubocop/cop/style/hash_each_methods.rb +105 -11
- data/lib/rubocop/cop/style/hash_except.rb +10 -6
- data/lib/rubocop/cop/style/hash_syntax.rb +24 -2
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +12 -1
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +5 -3
- data/lib/rubocop/cop/style/inverse_methods.rb +14 -13
- data/lib/rubocop/cop/style/invertible_unless_condition.rb +44 -2
- data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +82 -50
- data/lib/rubocop/cop/style/map_into_array.rb +175 -0
- data/lib/rubocop/cop/style/map_to_hash.rb +18 -8
- data/lib/rubocop/cop/style/map_to_set.rb +1 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +19 -5
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +2 -4
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +20 -0
- data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/missing_respond_to_missing.rb +2 -2
- data/lib/rubocop/cop/style/multiline_method_signature.rb +10 -1
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +5 -3
- data/lib/rubocop/cop/style/next.rb +1 -1
- data/lib/rubocop/cop/style/nil_comparison.rb +2 -0
- data/lib/rubocop/cop/style/numeric_literal_prefix.rb +1 -1
- data/lib/rubocop/cop/style/numeric_predicate.rb +10 -2
- data/lib/rubocop/cop/style/object_then.rb +5 -3
- data/lib/rubocop/cop/style/one_line_conditional.rb +1 -1
- data/lib/rubocop/cop/style/operator_method_call.rb +2 -2
- data/lib/rubocop/cop/style/parallel_assignment.rb +3 -5
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +8 -0
- data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
- data/lib/rubocop/cop/style/raise_args.rb +4 -1
- data/lib/rubocop/cop/style/redundant_argument.rb +27 -3
- data/lib/rubocop/cop/style/redundant_assignment.rb +10 -2
- data/lib/rubocop/cop/style/redundant_begin.rb +1 -1
- data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +5 -4
- data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +17 -10
- data/lib/rubocop/cop/style/redundant_each.rb +7 -4
- data/lib/rubocop/cop/style/redundant_fetch_block.rb +3 -3
- data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +1 -1
- data/lib/rubocop/cop/style/redundant_filter_chain.rb +5 -4
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +19 -2
- data/lib/rubocop/cop/style/redundant_parentheses.rb +50 -19
- data/lib/rubocop/cop/style/redundant_percent_q.rb +1 -1
- data/lib/rubocop/cop/style/redundant_return.rb +7 -1
- data/lib/rubocop/cop/style/redundant_self.rb +17 -2
- data/lib/rubocop/cop/style/redundant_sort.rb +9 -8
- data/lib/rubocop/cop/style/redundant_sort_by.rb +2 -2
- data/lib/rubocop/cop/style/redundant_string_escape.rb +1 -1
- data/lib/rubocop/cop/style/require_order.rb +1 -1
- data/lib/rubocop/cop/style/sample.rb +3 -4
- data/lib/rubocop/cop/style/select_by_regexp.rb +7 -6
- data/lib/rubocop/cop/style/self_assignment.rb +1 -1
- data/lib/rubocop/cop/style/semicolon.rb +8 -0
- data/lib/rubocop/cop/style/send.rb +4 -4
- data/lib/rubocop/cop/style/send_with_literal_method_name.rb +104 -0
- data/lib/rubocop/cop/style/single_argument_dig.rb +7 -3
- data/lib/rubocop/cop/style/single_line_do_end_block.rb +3 -1
- data/lib/rubocop/cop/style/slicing_with_range.rb +76 -10
- data/lib/rubocop/cop/style/special_global_vars.rb +1 -2
- data/lib/rubocop/cop/style/string_chars.rb +1 -0
- data/lib/rubocop/cop/style/strip.rb +7 -4
- data/lib/rubocop/cop/style/super_arguments.rb +174 -0
- data/lib/rubocop/cop/style/super_with_args_parentheses.rb +35 -0
- data/lib/rubocop/cop/style/symbol_proc.rb +75 -5
- data/lib/rubocop/cop/style/top_level_method_definition.rb +1 -1
- data/lib/rubocop/cop/style/unpack_first.rb +11 -14
- data/lib/rubocop/cop/style/zero_length_predicate.rb +28 -24
- data/lib/rubocop/cop/team.rb +13 -0
- data/lib/rubocop/cop/util.rb +7 -1
- data/lib/rubocop/cop/utils/regexp_ranges.rb +1 -1
- data/lib/rubocop/cops_documentation_generator.rb +16 -4
- data/lib/rubocop/directive_comment.rb +10 -8
- data/lib/rubocop/ext/regexp_node.rb +9 -4
- data/lib/rubocop/ext/regexp_parser.rb +4 -21
- data/lib/rubocop/formatter/clang_style_formatter.rb +3 -7
- data/lib/rubocop/formatter/disabled_config_formatter.rb +23 -8
- data/lib/rubocop/formatter/formatter_set.rb +7 -1
- data/lib/rubocop/formatter/html_formatter.rb +37 -14
- data/lib/rubocop/formatter/json_formatter.rb +0 -1
- data/lib/rubocop/formatter/offense_count_formatter.rb +12 -2
- data/lib/rubocop/formatter/tap_formatter.rb +3 -7
- data/lib/rubocop/formatter.rb +1 -1
- data/lib/rubocop/lockfile.rb +56 -7
- data/lib/rubocop/lsp/logger.rb +1 -1
- data/lib/rubocop/lsp/routes.rb +12 -15
- data/lib/rubocop/lsp/runtime.rb +1 -1
- data/lib/rubocop/lsp/server.rb +7 -2
- data/lib/rubocop/lsp/severity.rb +1 -1
- data/lib/rubocop/lsp.rb +36 -0
- data/lib/rubocop/magic_comment.rb +1 -1
- data/lib/rubocop/options.rb +14 -11
- data/lib/rubocop/path_util.rb +6 -2
- data/lib/rubocop/rake_task.rb +1 -1
- data/lib/rubocop/result_cache.rb +0 -1
- data/lib/rubocop/rspec/cop_helper.rb +8 -2
- data/lib/rubocop/rspec/expect_offense.rb +16 -8
- data/lib/rubocop/rspec/shared_contexts.rb +73 -16
- data/lib/rubocop/rspec/support.rb +3 -0
- data/lib/rubocop/runner.rb +14 -3
- data/lib/rubocop/server/cache.rb +11 -2
- data/lib/rubocop/server/client_command/exec.rb +2 -3
- data/lib/rubocop/server/client_command/start.rb +1 -1
- data/lib/rubocop/server/core.rb +4 -0
- data/lib/rubocop/server/server_command/exec.rb +0 -1
- data/lib/rubocop/target_finder.rb +84 -78
- data/lib/rubocop/target_ruby.rb +82 -80
- data/lib/rubocop/version.rb +19 -4
- data/lib/rubocop.rb +8 -0
- metadata +27 -29
- /data/lib/rubocop/formatter/{git_hub_actions_formatter.rb → github_actions_formatter.rb} +0 -0
data/config/default.yml
CHANGED
|
@@ -144,6 +144,12 @@ AllCops:
|
|
|
144
144
|
# Ruby version is still unresolved, RuboCop will use the oldest officially
|
|
145
145
|
# supported Ruby version (currently Ruby 2.7).
|
|
146
146
|
TargetRubyVersion: ~
|
|
147
|
+
# You can specify the parser engine. There are two options available:
|
|
148
|
+
# - `parser_whitequark` ... https://github.com/whitequark/parser
|
|
149
|
+
# - `parser_prism` ... https://github.com/ruby/prism (`Prism::Translation::Parser`)
|
|
150
|
+
# By default, `parser` is used. For the `TargetRubyVersion` value, `parser` can be specified for versions `2.0` and above.
|
|
151
|
+
# `parser_prism` can be specified for versions `3.3` and above. `parser_prism` is faster but still considered experimental.
|
|
152
|
+
ParserEngine: parser_whitequark
|
|
147
153
|
# Determines if a notification for extension libraries should be shown when
|
|
148
154
|
# rubocop is run. Keys are the name of the extension, and values are an array
|
|
149
155
|
# of gems in the Gemfile that the extension is suggested for, if not already
|
|
@@ -157,6 +163,7 @@ AllCops:
|
|
|
157
163
|
rubocop-graphql: [graphql]
|
|
158
164
|
rubocop-capybara: [capybara]
|
|
159
165
|
rubocop-factory_bot: [factory_bot, factory_bot_rails]
|
|
166
|
+
rubocop-rspec_rails: [rspec-rails]
|
|
160
167
|
# Enable/Disable checking the methods extended by Active Support.
|
|
161
168
|
ActiveSupportExtensionsEnabled: false
|
|
162
169
|
|
|
@@ -255,6 +262,15 @@ Bundler/OrderedGems:
|
|
|
255
262
|
|
|
256
263
|
#################### Gemspec ###############################
|
|
257
264
|
|
|
265
|
+
Gemspec/AddRuntimeDependency:
|
|
266
|
+
Description: 'Prefer `add_dependency` over `add_runtime_dependency`.'
|
|
267
|
+
StyleGuide: '#add_dependency_vs_add_runtime_dependency'
|
|
268
|
+
Reference: https://github.com/rubygems/rubygems/issues/7799#issuecomment-2192720316
|
|
269
|
+
Enabled: pending
|
|
270
|
+
VersionAdded: '1.65'
|
|
271
|
+
Include:
|
|
272
|
+
- '**/*.gemspec'
|
|
273
|
+
|
|
258
274
|
Gemspec/DependencyVersion:
|
|
259
275
|
Description: 'Requires or forbids specifying gem dependency versions.'
|
|
260
276
|
Enabled: false
|
|
@@ -556,7 +572,9 @@ Layout/ElseAlignment:
|
|
|
556
572
|
Layout/EmptyComment:
|
|
557
573
|
Description: 'Checks empty comment.'
|
|
558
574
|
Enabled: true
|
|
575
|
+
AutoCorrect: contextual
|
|
559
576
|
VersionAdded: '0.53'
|
|
577
|
+
VersionChanged: '1.61'
|
|
560
578
|
AllowBorderComment: true
|
|
561
579
|
AllowMarginComment: true
|
|
562
580
|
|
|
@@ -1351,6 +1369,10 @@ Layout/SpaceAroundOperators:
|
|
|
1351
1369
|
SupportedStylesForExponentOperator:
|
|
1352
1370
|
- space
|
|
1353
1371
|
- no_space
|
|
1372
|
+
EnforcedStyleForRationalLiterals: no_space
|
|
1373
|
+
SupportedStylesForRationalLiterals:
|
|
1374
|
+
- space
|
|
1375
|
+
- no_space
|
|
1354
1376
|
|
|
1355
1377
|
Layout/SpaceBeforeBlockBraces:
|
|
1356
1378
|
Description: >-
|
|
@@ -1645,7 +1667,7 @@ Lint/Debugger:
|
|
|
1645
1667
|
Description: 'Check for debugger calls.'
|
|
1646
1668
|
Enabled: true
|
|
1647
1669
|
VersionAdded: '0.14'
|
|
1648
|
-
VersionChanged: '1.
|
|
1670
|
+
VersionChanged: '1.63'
|
|
1649
1671
|
DebuggerMethods:
|
|
1650
1672
|
# Groups are available so that a specific group can be disabled in
|
|
1651
1673
|
# a user's configuration, but are otherwise not significant.
|
|
@@ -1658,8 +1680,14 @@ Lint/Debugger:
|
|
|
1658
1680
|
- Kernel.byebug
|
|
1659
1681
|
- Kernel.remote_byebug
|
|
1660
1682
|
Capybara:
|
|
1683
|
+
- page.save_and_open_page
|
|
1684
|
+
- page.save_and_open_screenshot
|
|
1685
|
+
- page.save_page
|
|
1686
|
+
- page.save_screenshot
|
|
1661
1687
|
- save_and_open_page
|
|
1662
1688
|
- save_and_open_screenshot
|
|
1689
|
+
- save_page
|
|
1690
|
+
- save_screenshot
|
|
1663
1691
|
debug.rb:
|
|
1664
1692
|
- binding.b
|
|
1665
1693
|
- binding.break
|
|
@@ -1681,6 +1709,10 @@ Lint/Debugger:
|
|
|
1681
1709
|
- jard
|
|
1682
1710
|
WebConsole:
|
|
1683
1711
|
- binding.console
|
|
1712
|
+
DebuggerRequires:
|
|
1713
|
+
debug.rb:
|
|
1714
|
+
- debug/open
|
|
1715
|
+
- debug/start
|
|
1684
1716
|
|
|
1685
1717
|
Lint/DeprecatedClassMethods:
|
|
1686
1718
|
Description: 'Check for deprecated class method calls.'
|
|
@@ -1821,16 +1853,18 @@ Lint/EmptyClass:
|
|
|
1821
1853
|
Lint/EmptyConditionalBody:
|
|
1822
1854
|
Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
|
|
1823
1855
|
Enabled: true
|
|
1856
|
+
AutoCorrect: contextual
|
|
1824
1857
|
SafeAutoCorrect: false
|
|
1825
1858
|
AllowComments: true
|
|
1826
1859
|
VersionAdded: '0.89'
|
|
1827
|
-
VersionChanged: '1.
|
|
1860
|
+
VersionChanged: '1.61'
|
|
1828
1861
|
|
|
1829
1862
|
Lint/EmptyEnsure:
|
|
1830
1863
|
Description: 'Checks for empty ensure block.'
|
|
1831
1864
|
Enabled: true
|
|
1865
|
+
AutoCorrect: contextual
|
|
1832
1866
|
VersionAdded: '0.10'
|
|
1833
|
-
VersionChanged: '
|
|
1867
|
+
VersionChanged: '1.61'
|
|
1834
1868
|
|
|
1835
1869
|
Lint/EmptyExpression:
|
|
1836
1870
|
Description: 'Checks for empty expressions.'
|
|
@@ -1852,8 +1886,9 @@ Lint/EmptyInPattern:
|
|
|
1852
1886
|
Lint/EmptyInterpolation:
|
|
1853
1887
|
Description: 'Checks for empty string interpolation.'
|
|
1854
1888
|
Enabled: true
|
|
1889
|
+
AutoCorrect: contextual
|
|
1855
1890
|
VersionAdded: '0.20'
|
|
1856
|
-
VersionChanged: '
|
|
1891
|
+
VersionChanged: '1.61'
|
|
1857
1892
|
|
|
1858
1893
|
Lint/EmptyWhen:
|
|
1859
1894
|
Description: 'Checks for `when` branches with empty bodies.'
|
|
@@ -1959,6 +1994,12 @@ Lint/InterpolationCheck:
|
|
|
1959
1994
|
VersionAdded: '0.50'
|
|
1960
1995
|
VersionChanged: '1.40'
|
|
1961
1996
|
|
|
1997
|
+
Lint/ItWithoutArgumentsInBlock:
|
|
1998
|
+
Description: 'Checks uses of `it` calls without arguments in block.'
|
|
1999
|
+
Reference: 'https://bugs.ruby-lang.org/issues/18980'
|
|
2000
|
+
Enabled: pending
|
|
2001
|
+
VersionAdded: '1.59'
|
|
2002
|
+
|
|
1962
2003
|
Lint/LambdaWithoutLiteralBlock:
|
|
1963
2004
|
Description: 'Checks uses of lambda without a literal block.'
|
|
1964
2005
|
Enabled: pending
|
|
@@ -1969,6 +2010,11 @@ Lint/LiteralAsCondition:
|
|
|
1969
2010
|
Enabled: true
|
|
1970
2011
|
VersionAdded: '0.51'
|
|
1971
2012
|
|
|
2013
|
+
Lint/LiteralAssignmentInCondition:
|
|
2014
|
+
Description: 'Checks for literal assignments in the conditions.'
|
|
2015
|
+
Enabled: pending
|
|
2016
|
+
VersionAdded: '1.58'
|
|
2017
|
+
|
|
1972
2018
|
Lint/LiteralInInterpolation:
|
|
1973
2019
|
Description: 'Checks for literals used in interpolation.'
|
|
1974
2020
|
Enabled: true
|
|
@@ -2380,7 +2426,9 @@ Lint/TopLevelReturnWithArgument:
|
|
|
2380
2426
|
Lint/TrailingCommaInAttributeDeclaration:
|
|
2381
2427
|
Description: 'Checks for trailing commas in attribute declarations.'
|
|
2382
2428
|
Enabled: true
|
|
2429
|
+
AutoCorrect: contextual
|
|
2383
2430
|
VersionAdded: '0.90'
|
|
2431
|
+
VersionChanged: '1.61'
|
|
2384
2432
|
|
|
2385
2433
|
Lint/TripleQuotes:
|
|
2386
2434
|
Description: 'Checks for useless triple quote constructs.'
|
|
@@ -2440,8 +2488,9 @@ Lint/UnusedBlockArgument:
|
|
|
2440
2488
|
Description: 'Checks for unused block arguments.'
|
|
2441
2489
|
StyleGuide: '#underscore-unused-vars'
|
|
2442
2490
|
Enabled: true
|
|
2491
|
+
AutoCorrect: contextual
|
|
2443
2492
|
VersionAdded: '0.21'
|
|
2444
|
-
VersionChanged: '
|
|
2493
|
+
VersionChanged: '1.61'
|
|
2445
2494
|
IgnoreEmptyBlocks: true
|
|
2446
2495
|
AllowUnusedKeywordArguments: false
|
|
2447
2496
|
|
|
@@ -2449,8 +2498,9 @@ Lint/UnusedMethodArgument:
|
|
|
2449
2498
|
Description: 'Checks for unused method arguments.'
|
|
2450
2499
|
StyleGuide: '#underscore-unused-vars'
|
|
2451
2500
|
Enabled: true
|
|
2501
|
+
AutoCorrect: contextual
|
|
2452
2502
|
VersionAdded: '0.21'
|
|
2453
|
-
VersionChanged: '
|
|
2503
|
+
VersionChanged: '1.61'
|
|
2454
2504
|
AllowUnusedKeywordArguments: false
|
|
2455
2505
|
IgnoreEmptyMethods: true
|
|
2456
2506
|
IgnoreNotImplementedMethods: true
|
|
@@ -2474,8 +2524,9 @@ Lint/UriRegexp:
|
|
|
2474
2524
|
Lint/UselessAccessModifier:
|
|
2475
2525
|
Description: 'Checks for useless access modifiers.'
|
|
2476
2526
|
Enabled: true
|
|
2527
|
+
AutoCorrect: contextual
|
|
2477
2528
|
VersionAdded: '0.20'
|
|
2478
|
-
VersionChanged: '
|
|
2529
|
+
VersionChanged: '1.61'
|
|
2479
2530
|
ContextCreatingMethods: []
|
|
2480
2531
|
MethodCreatingMethods: []
|
|
2481
2532
|
|
|
@@ -2483,8 +2534,9 @@ Lint/UselessAssignment:
|
|
|
2483
2534
|
Description: 'Checks for useless assignment to a local variable.'
|
|
2484
2535
|
StyleGuide: '#underscore-unused-vars'
|
|
2485
2536
|
Enabled: true
|
|
2537
|
+
AutoCorrect: contextual
|
|
2486
2538
|
VersionAdded: '0.11'
|
|
2487
|
-
VersionChanged: '1.
|
|
2539
|
+
VersionChanged: '1.61'
|
|
2488
2540
|
SafeAutoCorrect: false
|
|
2489
2541
|
|
|
2490
2542
|
Lint/UselessElseWithoutRescue:
|
|
@@ -2496,8 +2548,9 @@ Lint/UselessElseWithoutRescue:
|
|
|
2496
2548
|
Lint/UselessMethodDefinition:
|
|
2497
2549
|
Description: 'Checks for useless method definitions.'
|
|
2498
2550
|
Enabled: true
|
|
2551
|
+
AutoCorrect: contextual
|
|
2499
2552
|
VersionAdded: '0.90'
|
|
2500
|
-
VersionChanged: '
|
|
2553
|
+
VersionChanged: '1.61'
|
|
2501
2554
|
Safe: false
|
|
2502
2555
|
|
|
2503
2556
|
Lint/UselessRescue:
|
|
@@ -2520,13 +2573,17 @@ Lint/UselessSetterCall:
|
|
|
2520
2573
|
Lint/UselessTimes:
|
|
2521
2574
|
Description: 'Checks for useless `Integer#times` calls.'
|
|
2522
2575
|
Enabled: true
|
|
2523
|
-
VersionAdded: '0.91'
|
|
2524
2576
|
Safe: false
|
|
2577
|
+
AutoCorrect: contextual
|
|
2578
|
+
VersionAdded: '0.91'
|
|
2579
|
+
VersionChanged: '1.61'
|
|
2525
2580
|
|
|
2526
2581
|
Lint/Void:
|
|
2527
2582
|
Description: 'Possible use of operator/literal/variable in void context.'
|
|
2528
2583
|
Enabled: true
|
|
2584
|
+
AutoCorrect: contextual
|
|
2529
2585
|
VersionAdded: '0.9'
|
|
2586
|
+
VersionChanged: '1.61'
|
|
2530
2587
|
CheckForMethodsWithNoSideEffects: false
|
|
2531
2588
|
|
|
2532
2589
|
#################### Metrics ###############################
|
|
@@ -2569,8 +2626,9 @@ Metrics/BlockNesting:
|
|
|
2569
2626
|
StyleGuide: '#three-is-the-number-thou-shalt-count'
|
|
2570
2627
|
Enabled: true
|
|
2571
2628
|
VersionAdded: '0.25'
|
|
2572
|
-
VersionChanged: '
|
|
2629
|
+
VersionChanged: '1.65'
|
|
2573
2630
|
CountBlocks: false
|
|
2631
|
+
CountModifierForms: false
|
|
2574
2632
|
Max: 3
|
|
2575
2633
|
|
|
2576
2634
|
Metrics/ClassLength:
|
|
@@ -2725,7 +2783,8 @@ Naming/FileName:
|
|
|
2725
2783
|
VersionChanged: '1.23'
|
|
2726
2784
|
# Camel case file names listed in `AllCops:Include` and all file names listed
|
|
2727
2785
|
# in `AllCops:Exclude` are excluded by default. Add extra excludes here.
|
|
2728
|
-
Exclude:
|
|
2786
|
+
Exclude:
|
|
2787
|
+
- Rakefile.rb
|
|
2729
2788
|
# When `true`, requires that each source file should define a class or module
|
|
2730
2789
|
# with a name which matches the file name (converted to ... case).
|
|
2731
2790
|
# It further expects it to be nested inside modules which match the names
|
|
@@ -3041,6 +3100,7 @@ Style/AccessModifierDeclarations:
|
|
|
3041
3100
|
- inline
|
|
3042
3101
|
- group
|
|
3043
3102
|
AllowModifiersOnSymbols: true
|
|
3103
|
+
AllowModifiersOnAttrs: true
|
|
3044
3104
|
SafeAutoCorrect: false
|
|
3045
3105
|
|
|
3046
3106
|
Style/AccessorGrouping:
|
|
@@ -3085,7 +3145,19 @@ Style/ArgumentsForwarding:
|
|
|
3085
3145
|
Enabled: pending
|
|
3086
3146
|
AllowOnlyRestArgument: true
|
|
3087
3147
|
UseAnonymousForwarding: true
|
|
3148
|
+
RedundantRestArgumentNames:
|
|
3149
|
+
- args
|
|
3150
|
+
- arguments
|
|
3151
|
+
RedundantKeywordRestArgumentNames:
|
|
3152
|
+
- kwargs
|
|
3153
|
+
- options
|
|
3154
|
+
- opts
|
|
3155
|
+
RedundantBlockArgumentNames:
|
|
3156
|
+
- blk
|
|
3157
|
+
- block
|
|
3158
|
+
- proc
|
|
3088
3159
|
VersionAdded: '1.1'
|
|
3160
|
+
VersionChanged: '1.58'
|
|
3089
3161
|
|
|
3090
3162
|
Style/ArrayCoercion:
|
|
3091
3163
|
Description: >-
|
|
@@ -3096,6 +3168,13 @@ Style/ArrayCoercion:
|
|
|
3096
3168
|
Enabled: false
|
|
3097
3169
|
VersionAdded: '0.88'
|
|
3098
3170
|
|
|
3171
|
+
Style/ArrayFirstLast:
|
|
3172
|
+
Description: 'Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`.'
|
|
3173
|
+
Reference: '#first-and-last'
|
|
3174
|
+
Enabled: false
|
|
3175
|
+
VersionAdded: '1.58'
|
|
3176
|
+
Safe: false
|
|
3177
|
+
|
|
3099
3178
|
Style/ArrayIntersect:
|
|
3100
3179
|
Description: 'Use `array1.intersect?(array2)` instead of `(array1 & array2).any?`.'
|
|
3101
3180
|
Enabled: 'pending'
|
|
@@ -3619,6 +3698,7 @@ Style/DocumentationMethod:
|
|
|
3619
3698
|
Description: 'Checks for missing documentation comment for public methods.'
|
|
3620
3699
|
Enabled: false
|
|
3621
3700
|
VersionAdded: '0.43'
|
|
3701
|
+
AllowedMethods: []
|
|
3622
3702
|
Exclude:
|
|
3623
3703
|
- 'spec/**/*'
|
|
3624
3704
|
- 'test/**/*'
|
|
@@ -3667,8 +3747,9 @@ Style/EmptyCaseCondition:
|
|
|
3667
3747
|
Style/EmptyElse:
|
|
3668
3748
|
Description: 'Avoid empty else-clauses.'
|
|
3669
3749
|
Enabled: true
|
|
3750
|
+
AutoCorrect: contextual
|
|
3670
3751
|
VersionAdded: '0.28'
|
|
3671
|
-
VersionChanged: '
|
|
3752
|
+
VersionChanged: '1.61'
|
|
3672
3753
|
EnforcedStyle: both
|
|
3673
3754
|
# empty - warn only on empty `else`
|
|
3674
3755
|
# nil - warn on `else` with nil in it
|
|
@@ -3682,7 +3763,9 @@ Style/EmptyElse:
|
|
|
3682
3763
|
Style/EmptyHeredoc:
|
|
3683
3764
|
Description: 'Checks for using empty heredoc to reduce redundancy.'
|
|
3684
3765
|
Enabled: pending
|
|
3766
|
+
AutoCorrect: contextual
|
|
3685
3767
|
VersionAdded: '1.32'
|
|
3768
|
+
VersionChanged: '1.61'
|
|
3686
3769
|
|
|
3687
3770
|
Style/EmptyLambdaParameter:
|
|
3688
3771
|
Description: 'Omit parens for empty lambda parameters.'
|
|
@@ -3700,7 +3783,9 @@ Style/EmptyMethod:
|
|
|
3700
3783
|
Description: 'Checks the formatting of empty method definitions.'
|
|
3701
3784
|
StyleGuide: '#no-single-line-methods'
|
|
3702
3785
|
Enabled: true
|
|
3786
|
+
AutoCorrect: contextual
|
|
3703
3787
|
VersionAdded: '0.46'
|
|
3788
|
+
VersionChanged: '1.61'
|
|
3704
3789
|
EnforcedStyle: compact
|
|
3705
3790
|
SupportedStyles:
|
|
3706
3791
|
- compact
|
|
@@ -3995,6 +4080,8 @@ Style/HashSyntax:
|
|
|
3995
4080
|
- either
|
|
3996
4081
|
# forces use of the 3.1 syntax only if all values can be omitted in the hash.
|
|
3997
4082
|
- consistent
|
|
4083
|
+
# allow either (implicit or explicit) syntax but enforce consistency within a single hash
|
|
4084
|
+
- either_consistent
|
|
3998
4085
|
# Force hashes that have a symbol value to use hash rockets
|
|
3999
4086
|
UseHashRocketsWithSymbolValues: false
|
|
4000
4087
|
# Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
|
|
@@ -4215,6 +4302,13 @@ Style/MapCompactWithConditionalBlock:
|
|
|
4215
4302
|
Enabled: pending
|
|
4216
4303
|
VersionAdded: '1.30'
|
|
4217
4304
|
|
|
4305
|
+
Style/MapIntoArray:
|
|
4306
|
+
Description: 'Checks for usages of `each` with `<<`, `push`, or `append` which can be replaced by `map`.'
|
|
4307
|
+
StyleGuide: '#functional-code'
|
|
4308
|
+
Enabled: pending
|
|
4309
|
+
VersionAdded: '1.63'
|
|
4310
|
+
Safe: false
|
|
4311
|
+
|
|
4218
4312
|
Style/MapToHash:
|
|
4219
4313
|
Description: 'Prefer `to_h` with a block over `map.to_h`.'
|
|
4220
4314
|
Enabled: pending
|
|
@@ -4678,6 +4772,7 @@ Style/OperatorMethodCall:
|
|
|
4678
4772
|
|
|
4679
4773
|
Style/OptionHash:
|
|
4680
4774
|
Description: "Don't use option hashes when you can use keyword arguments."
|
|
4775
|
+
StyleGuide: '#keyword-arguments-vs-option-hashes'
|
|
4681
4776
|
Enabled: false
|
|
4682
4777
|
VersionAdded: '0.33'
|
|
4683
4778
|
VersionChanged: '0.34'
|
|
@@ -4800,8 +4895,9 @@ Style/RaiseArgs:
|
|
|
4800
4895
|
Description: 'Checks the arguments passed to raise/fail.'
|
|
4801
4896
|
StyleGuide: '#exception-class-messages'
|
|
4802
4897
|
Enabled: true
|
|
4898
|
+
Safe: false
|
|
4803
4899
|
VersionAdded: '0.14'
|
|
4804
|
-
VersionChanged: '1.
|
|
4900
|
+
VersionChanged: '1.61'
|
|
4805
4901
|
EnforcedStyle: exploded
|
|
4806
4902
|
SupportedStyles:
|
|
4807
4903
|
- compact # raise Exception.new(msg)
|
|
@@ -4902,7 +4998,7 @@ Style/RedundantFetchBlock:
|
|
|
4902
4998
|
Description: >-
|
|
4903
4999
|
Use `fetch(key, value)` instead of `fetch(key) { value }`
|
|
4904
5000
|
when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
|
|
4905
|
-
Reference: 'https://github.com/
|
|
5001
|
+
Reference: 'https://github.com/fastruby/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
|
|
4906
5002
|
Enabled: true
|
|
4907
5003
|
Safe: false
|
|
4908
5004
|
# If enabled, this cop will autocorrect usages of
|
|
@@ -4942,10 +5038,11 @@ Style/RedundantHeredocDelimiterQuotes:
|
|
|
4942
5038
|
Style/RedundantInitialize:
|
|
4943
5039
|
Description: 'Checks for redundant `initialize` methods.'
|
|
4944
5040
|
Enabled: pending
|
|
5041
|
+
AutoCorrect: contextual
|
|
4945
5042
|
Safe: false
|
|
4946
5043
|
AllowComments: true
|
|
4947
5044
|
VersionAdded: '1.27'
|
|
4948
|
-
VersionChanged: '1.
|
|
5045
|
+
VersionChanged: '1.61'
|
|
4949
5046
|
|
|
4950
5047
|
Style/RedundantInterpolation:
|
|
4951
5048
|
Description: 'Checks for strings that are just an interpolated expression.'
|
|
@@ -5123,7 +5220,7 @@ Style/Sample:
|
|
|
5123
5220
|
Description: >-
|
|
5124
5221
|
Use `sample` instead of `shuffle.first`,
|
|
5125
5222
|
`shuffle.last`, and `shuffle[Integer]`.
|
|
5126
|
-
Reference: 'https://github.com/
|
|
5223
|
+
Reference: 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
|
|
5127
5224
|
Enabled: true
|
|
5128
5225
|
VersionAdded: '0.30'
|
|
5129
5226
|
|
|
@@ -5157,6 +5254,13 @@ Style/Send:
|
|
|
5157
5254
|
Enabled: false
|
|
5158
5255
|
VersionAdded: '0.33'
|
|
5159
5256
|
|
|
5257
|
+
Style/SendWithLiteralMethodName:
|
|
5258
|
+
Description: 'Detects the use of the `public_send` method with a static method name argument.'
|
|
5259
|
+
Enabled: pending
|
|
5260
|
+
Safe: false
|
|
5261
|
+
AllowSend: true
|
|
5262
|
+
VersionAdded: '1.64'
|
|
5263
|
+
|
|
5160
5264
|
Style/SignalException:
|
|
5161
5265
|
Description: 'Checks for proper usage of fail and raise.'
|
|
5162
5266
|
StyleGuide: '#prefer-raise-over-fail'
|
|
@@ -5190,6 +5294,7 @@ Style/SingleLineBlockParams:
|
|
|
5190
5294
|
|
|
5191
5295
|
Style/SingleLineDoEndBlock:
|
|
5192
5296
|
Description: 'Checks for single-line `do`...`end` blocks.'
|
|
5297
|
+
StyleGuide: '#single-line-do-end-block'
|
|
5193
5298
|
Enabled: pending
|
|
5194
5299
|
VersionAdded: '1.57'
|
|
5195
5300
|
|
|
@@ -5202,7 +5307,8 @@ Style/SingleLineMethods:
|
|
|
5202
5307
|
AllowIfMethodIsEmpty: true
|
|
5203
5308
|
|
|
5204
5309
|
Style/SlicingWithRange:
|
|
5205
|
-
Description: 'Checks array slicing is done with endless ranges when suitable.'
|
|
5310
|
+
Description: 'Checks array slicing is done with redundant, endless, and beginless ranges when suitable.'
|
|
5311
|
+
StyleGuide: '#slicing-with-ranges'
|
|
5206
5312
|
Enabled: true
|
|
5207
5313
|
VersionAdded: '0.83'
|
|
5208
5314
|
Safe: false
|
|
@@ -5329,6 +5435,17 @@ Style/StructInheritance:
|
|
|
5329
5435
|
VersionAdded: '0.29'
|
|
5330
5436
|
VersionChanged: '1.20'
|
|
5331
5437
|
|
|
5438
|
+
Style/SuperArguments:
|
|
5439
|
+
Description: 'Call `super` without arguments and parentheses when the signature is identical.'
|
|
5440
|
+
Enabled: pending
|
|
5441
|
+
VersionAdded: '1.64'
|
|
5442
|
+
|
|
5443
|
+
Style/SuperWithArgsParentheses:
|
|
5444
|
+
Description: 'Use parentheses for `super` with arguments.'
|
|
5445
|
+
StyleGuide: '#super-with-args'
|
|
5446
|
+
Enabled: pending
|
|
5447
|
+
VersionAdded: '1.58'
|
|
5448
|
+
|
|
5332
5449
|
Style/SwapValues:
|
|
5333
5450
|
Description: 'Enforces the use of shorthand-style swapping of 2 variables.'
|
|
5334
5451
|
StyleGuide: '#values-swapping'
|
|
@@ -5358,7 +5475,7 @@ Style/SymbolProc:
|
|
|
5358
5475
|
Enabled: true
|
|
5359
5476
|
Safe: false
|
|
5360
5477
|
VersionAdded: '0.26'
|
|
5361
|
-
VersionChanged: '1.
|
|
5478
|
+
VersionChanged: '1.64'
|
|
5362
5479
|
AllowMethodsWithArguments: false
|
|
5363
5480
|
# A list of method names to be always allowed by the check.
|
|
5364
5481
|
# The names should be fairly unique, otherwise you'll end up ignoring lots of code.
|
data/lib/rubocop/cached_data.rb
CHANGED
|
@@ -48,11 +48,19 @@ module RuboCop
|
|
|
48
48
|
source_buffer = Parser::Source::Buffer.new(@filename)
|
|
49
49
|
source_buffer.source = File.read(@filename, encoding: Encoding::UTF_8)
|
|
50
50
|
offenses.map! do |o|
|
|
51
|
-
location =
|
|
52
|
-
o['location']['begin_pos'],
|
|
53
|
-
o['location']['end_pos'])
|
|
51
|
+
location = location_from_source_buffer(o, source_buffer)
|
|
54
52
|
Cop::Offense.new(o['severity'], location, o['message'], o['cop_name'], o['status'].to_sym)
|
|
55
53
|
end
|
|
56
54
|
end
|
|
55
|
+
|
|
56
|
+
def location_from_source_buffer(offense, source_buffer)
|
|
57
|
+
begin_pos = offense['location']['begin_pos']
|
|
58
|
+
end_pos = offense['location']['end_pos']
|
|
59
|
+
if begin_pos.zero? && end_pos.zero?
|
|
60
|
+
Cop::Offense::NO_LOCATION
|
|
61
|
+
else
|
|
62
|
+
Parser::Source::Range.new(source_buffer, begin_pos, end_pos)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
57
65
|
end
|
|
58
66
|
end
|
|
@@ -10,13 +10,17 @@ module RuboCop
|
|
|
10
10
|
|
|
11
11
|
AUTO_GENERATED_FILE = '.rubocop_todo.yml'
|
|
12
12
|
YAML_OPTIONAL_DOC_START = /\A---(\s+#|\s*\z)/.freeze
|
|
13
|
+
PLACEHOLDER = '###rubocop:inherit_here'
|
|
13
14
|
|
|
14
15
|
PHASE_1 = 'Phase 1 of 2: run Layout/LineLength cop'
|
|
15
16
|
PHASE_2 = 'Phase 2 of 2: run all cops'
|
|
16
17
|
|
|
17
18
|
PHASE_1_OVERRIDDEN = '(skipped because the default Layout/LineLength:Max is overridden)'
|
|
18
19
|
PHASE_1_DISABLED = '(skipped because Layout/LineLength is disabled)'
|
|
19
|
-
|
|
20
|
+
PHASE_1_SKIPPED_ONLY_COPS =
|
|
21
|
+
'(skipped because a list of cops is passed to the `--only` flag)'
|
|
22
|
+
PHASE_1_SKIPPED_ONLY_EXCLUDE =
|
|
23
|
+
'(skipped because only excludes will be generated due to `--auto-gen-only-exclude` flag)'
|
|
20
24
|
|
|
21
25
|
def run
|
|
22
26
|
add_formatter
|
|
@@ -28,12 +32,14 @@ module RuboCop
|
|
|
28
32
|
private
|
|
29
33
|
|
|
30
34
|
def maybe_run_line_length_cop
|
|
31
|
-
if
|
|
35
|
+
if only_exclude?
|
|
36
|
+
skip_line_length_cop(PHASE_1_SKIPPED_ONLY_EXCLUDE)
|
|
37
|
+
elsif !line_length_enabled?(@config_store.for_pwd)
|
|
32
38
|
skip_line_length_cop(PHASE_1_DISABLED)
|
|
33
39
|
elsif !same_max_line_length?(@config_store.for_pwd, ConfigLoader.default_configuration)
|
|
34
40
|
skip_line_length_cop(PHASE_1_OVERRIDDEN)
|
|
35
41
|
elsif options_has_only_flag?
|
|
36
|
-
skip_line_length_cop(
|
|
42
|
+
skip_line_length_cop(PHASE_1_SKIPPED_ONLY_COPS)
|
|
37
43
|
else
|
|
38
44
|
run_line_length_cop
|
|
39
45
|
end
|
|
@@ -64,6 +70,10 @@ module RuboCop
|
|
|
64
70
|
@options[:only]
|
|
65
71
|
end
|
|
66
72
|
|
|
73
|
+
def only_exclude?
|
|
74
|
+
@options[:auto_gen_only_exclude]
|
|
75
|
+
end
|
|
76
|
+
|
|
67
77
|
# Do an initial run with only Layout/LineLength so that cops that
|
|
68
78
|
# depend on Layout/LineLength:Max get the correct value for that
|
|
69
79
|
# parameter.
|
|
@@ -125,15 +135,19 @@ module RuboCop
|
|
|
125
135
|
|
|
126
136
|
def existing_configuration(config_file)
|
|
127
137
|
File.read(config_file, encoding: Encoding::UTF_8)
|
|
128
|
-
.sub(/^inherit_from: *[^\n]+/,
|
|
129
|
-
.sub(/^inherit_from: *(\n *- *[^\n]+)+/,
|
|
138
|
+
.sub(/^inherit_from: *[^\n]+/, PLACEHOLDER)
|
|
139
|
+
.sub(/^inherit_from: *(\n *- *[^\n]+)+/, PLACEHOLDER)
|
|
130
140
|
end
|
|
131
141
|
|
|
132
142
|
def write_config_file(file_name, file_string, rubocop_yml_contents)
|
|
133
143
|
lines = /\S/.match?(rubocop_yml_contents) ? rubocop_yml_contents.split("\n", -1) : []
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
144
|
+
unless rubocop_yml_contents&.include?(PLACEHOLDER)
|
|
145
|
+
doc_start_index = lines.index { |line| YAML_OPTIONAL_DOC_START.match?(line) } || -1
|
|
146
|
+
lines.insert(doc_start_index + 1, PLACEHOLDER)
|
|
147
|
+
end
|
|
148
|
+
File.write(file_name, lines.join("\n")
|
|
149
|
+
.sub(/#{PLACEHOLDER}\n*/o, "inherit_from:#{file_string}\n\n")
|
|
150
|
+
.sub(/\n\n+\Z/, "\n"))
|
|
137
151
|
end
|
|
138
152
|
|
|
139
153
|
def relative_path_to_todo_from_options_config
|
|
@@ -7,11 +7,11 @@ module RuboCop
|
|
|
7
7
|
module Command
|
|
8
8
|
# Start Language Server Protocol of RuboCop.
|
|
9
9
|
# @api private
|
|
10
|
-
class
|
|
10
|
+
class LSP < Base
|
|
11
11
|
self.command_name = :lsp
|
|
12
12
|
|
|
13
13
|
def run
|
|
14
|
-
RuboCop::
|
|
14
|
+
RuboCop::LSP::Server.new(@config_store).start
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
end
|
|
@@ -26,10 +26,10 @@ module RuboCop
|
|
|
26
26
|
|
|
27
27
|
cops_array.each do |cop_name|
|
|
28
28
|
cop = registry_hash[cop_name]
|
|
29
|
-
|
|
30
29
|
next if cop.empty?
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
url = Cop::Documentation.url_for(cop.first, @config)
|
|
32
|
+
puts url if url
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
puts
|
data/lib/rubocop/cli.rb
CHANGED
|
@@ -12,7 +12,7 @@ module RuboCop
|
|
|
12
12
|
STATUS_INTERRUPTED = Signal.list['INT'] + 128
|
|
13
13
|
DEFAULT_PARALLEL_OPTIONS = %i[
|
|
14
14
|
color config debug display_style_guide display_time display_only_fail_level_offenses
|
|
15
|
-
display_only_failed except extra_details fail_level fix_layout format
|
|
15
|
+
display_only_failed editor_mode except extra_details fail_level fix_layout format
|
|
16
16
|
ignore_disable_comments lint only only_guide_cops require safe
|
|
17
17
|
autocorrect safe_autocorrect autocorrect_all
|
|
18
18
|
].freeze
|
|
@@ -57,6 +57,10 @@ module RuboCop
|
|
|
57
57
|
rescue RuboCop::Error => e
|
|
58
58
|
warn Rainbow("Error: #{e.message}").red
|
|
59
59
|
STATUS_ERROR
|
|
60
|
+
rescue Interrupt
|
|
61
|
+
warn ''
|
|
62
|
+
warn 'Exiting...'
|
|
63
|
+
STATUS_INTERRUPTED
|
|
60
64
|
rescue Finished
|
|
61
65
|
STATUS_SUCCESS
|
|
62
66
|
rescue OptionParser::InvalidOption => e
|
|
@@ -151,6 +155,7 @@ module RuboCop
|
|
|
151
155
|
|
|
152
156
|
def act_on_options
|
|
153
157
|
set_options_to_config_loader
|
|
158
|
+
handle_editor_mode
|
|
154
159
|
|
|
155
160
|
@config_store.options_config = @options[:config] if @options[:config]
|
|
156
161
|
@config_store.force_default_config! if @options[:force_default_config]
|
|
@@ -174,6 +179,10 @@ module RuboCop
|
|
|
174
179
|
ConfigLoader.ignore_unrecognized_cops = @options[:ignore_unrecognized_cops]
|
|
175
180
|
end
|
|
176
181
|
|
|
182
|
+
def handle_editor_mode
|
|
183
|
+
RuboCop::LSP.enable if @options[:editor_mode]
|
|
184
|
+
end
|
|
185
|
+
|
|
177
186
|
# rubocop:disable Metrics/CyclomaticComplexity
|
|
178
187
|
def handle_exiting_options
|
|
179
188
|
return unless Options::EXITING_OPTIONS.any? { |o| @options.key? o }
|