rubocop 1.9.0 → 1.11.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 +13 -13
- data/assets/output.html.erb +1 -1
- data/config/default.yml +54 -16
- data/config/obsoletion.yml +4 -0
- data/lib/rubocop.rb +4 -0
- data/lib/rubocop/cli/command/execute_runner.rb +1 -1
- data/lib/rubocop/cli/command/suggest_extensions.rb +1 -1
- data/lib/rubocop/config.rb +4 -1
- data/lib/rubocop/cop/base.rb +1 -0
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +2 -1
- data/lib/rubocop/cop/bundler/gem_comment.rb +1 -0
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +1 -0
- data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -0
- data/lib/rubocop/cop/exclude_limit.rb +26 -0
- data/lib/rubocop/cop/gemspec/date_assignment.rb +57 -0
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +2 -0
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -0
- data/lib/rubocop/cop/gemspec/required_ruby_version.rb +2 -0
- data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +2 -0
- data/lib/rubocop/cop/generator.rb +2 -2
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/example_description.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/node_destructuring.rb +2 -0
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +151 -0
- data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +2 -0
- data/lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +3 -0
- data/lib/rubocop/cop/internal_affairs/style_detected_api_use.rb +4 -0
- data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +2 -0
- data/lib/rubocop/cop/layout/block_alignment.rb +1 -0
- data/lib/rubocop/cop/layout/class_structure.rb +1 -0
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +37 -17
- data/lib/rubocop/cop/layout/extra_spacing.rb +2 -2
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +22 -3
- data/lib/rubocop/cop/layout/indentation_width.rb +1 -0
- data/lib/rubocop/cop/layout/line_length.rb +2 -1
- data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +26 -0
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +1 -1
- data/lib/rubocop/cop/layout/space_before_brackets.rb +9 -4
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +1 -1
- data/lib/rubocop/cop/lint/big_decimal_new.rb +1 -0
- data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -0
- data/lib/rubocop/cop/lint/constant_definition_in_block.rb +2 -0
- data/lib/rubocop/cop/lint/constant_resolution.rb +1 -0
- data/lib/rubocop/cop/lint/debugger.rb +60 -14
- data/lib/rubocop/cop/lint/deprecated_constants.rb +5 -0
- data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +14 -4
- data/lib/rubocop/cop/lint/duplicate_branch.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_methods.rb +3 -0
- data/lib/rubocop/cop/lint/duplicate_require.rb +3 -2
- data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -0
- data/lib/rubocop/cop/lint/else_layout.rb +1 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +1 -0
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +1 -0
- data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +1 -0
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -0
- data/lib/rubocop/cop/lint/inherit_exception.rb +1 -0
- data/lib/rubocop/cop/lint/multiple_comparison.rb +5 -4
- data/lib/rubocop/cop/lint/nested_method_definition.rb +3 -0
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -0
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +7 -0
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +3 -0
- data/lib/rubocop/cop/lint/number_conversion.rb +2 -0
- data/lib/rubocop/cop/lint/raise_exception.rb +2 -0
- data/lib/rubocop/cop/lint/rand_one.rb +1 -0
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +1 -0
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +1 -0
- data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +7 -3
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +1 -0
- data/lib/rubocop/cop/lint/redundant_with_index.rb +1 -0
- data/lib/rubocop/cop/lint/redundant_with_object.rb +1 -0
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +1 -0
- data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +1 -0
- data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +1 -0
- data/lib/rubocop/cop/lint/shadowed_argument.rb +1 -0
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +1 -0
- data/lib/rubocop/cop/lint/struct_new_override.rb +1 -0
- data/lib/rubocop/cop/lint/symbol_conversion.rb +3 -2
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +3 -0
- data/lib/rubocop/cop/lint/unified_integer.rb +1 -0
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +5 -0
- data/lib/rubocop/cop/lint/unreachable_code.rb +1 -0
- data/lib/rubocop/cop/lint/unreachable_loop.rb +1 -0
- data/lib/rubocop/cop/lint/unused_method_argument.rb +1 -0
- data/lib/rubocop/cop/lint/uri_escape_unescape.rb +1 -0
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +4 -0
- data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -0
- data/lib/rubocop/cop/lint/useless_times.rb +3 -0
- data/lib/rubocop/cop/message_annotator.rb +4 -1
- data/lib/rubocop/cop/metrics/block_nesting.rb +2 -2
- data/lib/rubocop/cop/metrics/module_length.rb +1 -0
- data/lib/rubocop/cop/metrics/parameter_lists.rb +6 -2
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +6 -4
- data/lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb +2 -0
- data/lib/rubocop/cop/mixin/code_length.rb +3 -1
- data/lib/rubocop/cop/mixin/configurable_max.rb +1 -0
- data/lib/rubocop/cop/mixin/def_node.rb +1 -0
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +3 -0
- data/lib/rubocop/cop/mixin/empty_parameter.rb +1 -0
- data/lib/rubocop/cop/mixin/enforce_superclass.rb +2 -0
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +1 -0
- data/lib/rubocop/cop/mixin/method_complexity.rb +4 -1
- data/lib/rubocop/cop/mixin/negative_conditional.rb +3 -0
- data/lib/rubocop/cop/mixin/preferred_delimiters.rb +3 -3
- data/lib/rubocop/cop/mixin/rational_literal.rb +1 -0
- data/lib/rubocop/cop/mixin/safe_assignment.rb +5 -0
- data/lib/rubocop/cop/mixin/visibility_help.rb +1 -0
- data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +1 -0
- data/lib/rubocop/cop/naming/constant_name.rb +2 -0
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +2 -0
- data/lib/rubocop/cop/naming/method_name.rb +3 -0
- data/lib/rubocop/cop/naming/predicate_name.rb +1 -0
- data/lib/rubocop/cop/registry.rb +1 -1
- data/lib/rubocop/cop/security/eval.rb +1 -0
- data/lib/rubocop/cop/security/json_load.rb +1 -0
- data/lib/rubocop/cop/security/marshal_load.rb +1 -0
- data/lib/rubocop/cop/security/open.rb +1 -0
- data/lib/rubocop/cop/security/yaml_load.rb +1 -0
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +1 -0
- data/lib/rubocop/cop/style/alias.rb +1 -0
- data/lib/rubocop/cop/style/arguments_forwarding.rb +3 -0
- data/lib/rubocop/cop/style/array_coercion.rb +2 -0
- data/lib/rubocop/cop/style/array_join.rb +1 -0
- data/lib/rubocop/cop/style/attr.rb +1 -0
- data/lib/rubocop/cop/style/case_equality.rb +2 -1
- data/lib/rubocop/cop/style/class_equality_comparison.rb +1 -0
- data/lib/rubocop/cop/style/collection_compact.rb +2 -0
- data/lib/rubocop/cop/style/colon_method_call.rb +1 -0
- data/lib/rubocop/cop/style/command_literal.rb +1 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +2 -0
- data/lib/rubocop/cop/style/constant_visibility.rb +28 -0
- data/lib/rubocop/cop/style/date_time.rb +3 -0
- data/lib/rubocop/cop/style/dir.rb +1 -0
- data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +1 -1
- data/lib/rubocop/cop/style/documentation.rb +5 -0
- data/lib/rubocop/cop/style/documentation_method.rb +1 -0
- data/lib/rubocop/cop/style/double_negation.rb +3 -2
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -0
- data/lib/rubocop/cop/style/each_with_object.rb +1 -0
- data/lib/rubocop/cop/style/empty_literal.rb +9 -0
- data/lib/rubocop/cop/style/endless_method.rb +1 -0
- data/lib/rubocop/cop/style/eval_with_location.rb +90 -28
- data/lib/rubocop/cop/style/even_odd.rb +1 -0
- data/lib/rubocop/cop/style/expand_path_arguments.rb +3 -0
- data/lib/rubocop/cop/style/explicit_block_argument.rb +2 -1
- data/lib/rubocop/cop/style/exponential_notation.rb +6 -7
- data/lib/rubocop/cop/style/float_division.rb +4 -0
- data/lib/rubocop/cop/style/format_string.rb +2 -0
- data/lib/rubocop/cop/style/format_string_token.rb +1 -0
- data/lib/rubocop/cop/style/global_std_stream.rb +1 -0
- data/lib/rubocop/cop/style/hash_conversion.rb +105 -0
- data/lib/rubocop/cop/style/hash_each_methods.rb +1 -0
- data/lib/rubocop/cop/style/hash_except.rb +1 -0
- data/lib/rubocop/cop/style/hash_like_case.rb +1 -0
- data/lib/rubocop/cop/style/hash_transform_keys.rb +4 -0
- data/lib/rubocop/cop/style/hash_transform_values.rb +4 -0
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +37 -11
- data/lib/rubocop/cop/style/implicit_runtime_error.rb +1 -0
- data/lib/rubocop/cop/style/inverse_methods.rb +2 -0
- data/lib/rubocop/cop/style/min_max.rb +1 -0
- data/lib/rubocop/cop/style/mixin_usage.rb +2 -0
- data/lib/rubocop/cop/style/module_function.rb +5 -0
- data/lib/rubocop/cop/style/multiple_comparison.rb +21 -2
- data/lib/rubocop/cop/style/mutable_constant.rb +3 -0
- data/lib/rubocop/cop/style/negated_if_else_condition.rb +1 -0
- data/lib/rubocop/cop/style/nil_comparison.rb +6 -1
- data/lib/rubocop/cop/style/nil_lambda.rb +1 -0
- data/lib/rubocop/cop/style/non_nil_check.rb +7 -0
- data/lib/rubocop/cop/style/numeric_literals.rb +6 -9
- data/lib/rubocop/cop/style/numeric_predicate.rb +4 -1
- data/lib/rubocop/cop/style/option_hash.rb +1 -0
- data/lib/rubocop/cop/style/or_assignment.rb +2 -0
- data/lib/rubocop/cop/style/parallel_assignment.rb +6 -0
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +1 -0
- data/lib/rubocop/cop/style/proc.rb +1 -0
- data/lib/rubocop/cop/style/random_with_offset.rb +5 -0
- data/lib/rubocop/cop/style/redundant_assignment.rb +1 -0
- data/lib/rubocop/cop/style/redundant_begin.rb +7 -1
- data/lib/rubocop/cop/style/redundant_conditional.rb +2 -0
- data/lib/rubocop/cop/style/redundant_exception.rb +2 -0
- data/lib/rubocop/cop/style/redundant_fetch_block.rb +2 -0
- data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +1 -0
- data/lib/rubocop/cop/style/redundant_freeze.rb +1 -0
- data/lib/rubocop/cop/style/redundant_parentheses.rb +13 -0
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +2 -0
- data/lib/rubocop/cop/style/redundant_sort.rb +1 -0
- data/lib/rubocop/cop/style/redundant_sort_by.rb +1 -0
- data/lib/rubocop/cop/style/regexp_literal.rb +1 -1
- data/lib/rubocop/cop/style/rescue_standard_error.rb +2 -0
- data/lib/rubocop/cop/style/return_nil.rb +6 -0
- data/lib/rubocop/cop/style/safe_navigation.rb +2 -0
- data/lib/rubocop/cop/style/sample.rb +1 -0
- data/lib/rubocop/cop/style/signal_exception.rb +3 -0
- data/lib/rubocop/cop/style/single_argument_dig.rb +1 -0
- data/lib/rubocop/cop/style/single_line_methods.rb +2 -0
- data/lib/rubocop/cop/style/slicing_with_range.rb +1 -0
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +4 -4
- data/lib/rubocop/cop/style/special_global_vars.rb +3 -3
- data/lib/rubocop/cop/style/stderr_puts.rb +1 -0
- data/lib/rubocop/cop/style/string_concatenation.rb +1 -0
- data/lib/rubocop/cop/style/string_hash_keys.rb +2 -0
- data/lib/rubocop/cop/style/strip.rb +1 -0
- data/lib/rubocop/cop/style/struct_inheritance.rb +1 -0
- data/lib/rubocop/cop/style/symbol_proc.rb +25 -1
- data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -0
- data/lib/rubocop/cop/style/trailing_body_on_method_definition.rb +1 -0
- data/lib/rubocop/cop/style/trailing_method_end_statement.rb +1 -1
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -0
- data/lib/rubocop/cop/style/unless_logical_operators.rb +99 -0
- data/lib/rubocop/cop/style/unpack_first.rb +1 -0
- data/lib/rubocop/cop/style/yoda_condition.rb +1 -0
- data/lib/rubocop/cop/style/zero_length_predicate.rb +5 -0
- data/lib/rubocop/formatter/offense_count_formatter.rb +1 -1
- data/lib/rubocop/formatter/simple_text_formatter.rb +2 -1
- data/lib/rubocop/formatter/worst_offenders_formatter.rb +1 -1
- data/lib/rubocop/name_similarity.rb +1 -1
- data/lib/rubocop/target_ruby.rb +21 -13
- data/lib/rubocop/version.rb +1 -1
- metadata +12 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dac7fff2f013c47a104cadfc9ca1a02a9f0996c13da30cf53c96f9c427f528bf
|
4
|
+
data.tar.gz: 55120478bfcd4ff14e326c6be7af570852b226ad27a02e9b2835ddda7d8e4324
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b47ab24450c94098487e2efcaf3c6c45314e07523ca7272356908792f06689f95ab4032eed06f9a55a1f68ad75432c599f6bbcec83b5a3ce3e611dab9e2f608
|
7
|
+
data.tar.gz: 1ba4a1fef00d332d644f242d97954cad9ad4cbcb2cf7cad1d2a2bec48540a2ae12d895a107283aac1933dd34230a45b02cb0470290f0c502bae2c5d3e762662f
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
<p align="center">
|
2
|
-
<img src="https://raw.githubusercontent.com/rubocop
|
2
|
+
<img src="https://raw.githubusercontent.com/rubocop/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
|
3
3
|
</p>
|
4
4
|
|
5
5
|
----------
|
6
|
-
[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop
|
6
|
+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
|
7
7
|
[![Gem Version](https://badge.fury.io/rb/rubocop.svg)](https://badge.fury.io/rb/rubocop)
|
8
|
-
[![CircleCI Status](https://circleci.com/gh/rubocop
|
9
|
-
[![Actions Status](https://github.com/rubocop
|
10
|
-
[![Test Coverage](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/test_coverage)](https://codeclimate.com/github/rubocop
|
11
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/maintainability)](https://codeclimate.com/github/rubocop
|
8
|
+
[![CircleCI Status](https://circleci.com/gh/rubocop/rubocop/tree/master.svg?style=svg)](https://circleci.com/gh/rubocop/rubocop/tree/master)
|
9
|
+
[![Actions Status](https://github.com/rubocop/rubocop/workflows/CI/badge.svg?branch=master)](https://github.com/rubocop/rubocop/actions?query=workflow%3ACI)
|
10
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/test_coverage)](https://codeclimate.com/github/rubocop/rubocop/test_coverage)
|
11
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/maintainability)](https://codeclimate.com/github/rubocop/rubocop/maintainability)
|
12
12
|
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=rubocop&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=rubocop&package-manager=bundler&version-scheme=semver)
|
13
13
|
|
14
14
|
> Role models are important. <br/>
|
@@ -20,7 +20,7 @@ Guide](https://rubystyle.guide). Apart from reporting the problems discovered in
|
|
20
20
|
RuboCop can also automatically fix many of them for you.
|
21
21
|
|
22
22
|
RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various
|
23
|
-
[configuration options](https://github.com/rubocop
|
23
|
+
[configuration options](https://github.com/rubocop/rubocop/blob/master/config/default.yml).
|
24
24
|
|
25
25
|
----------
|
26
26
|
[![Patreon](https://img.shields.io/badge/patreon-donate-orange.svg)](https://www.patreon.com/bbatsov)
|
@@ -45,13 +45,13 @@ gem 'rubocop', require: false
|
|
45
45
|
```
|
46
46
|
|
47
47
|
RuboCop is stable between major versions, both in terms of API and cop configuration.
|
48
|
-
We aim
|
48
|
+
We aim to ease the maintenance of RuboCop extensions and the upgrades between RuboCop
|
49
49
|
releases. All big changes are reserved for major releases.
|
50
50
|
To prevent an unwanted RuboCop update you might want to use a conservative version lock
|
51
51
|
in your `Gemfile`:
|
52
52
|
|
53
53
|
```rb
|
54
|
-
gem 'rubocop', '~> 1.
|
54
|
+
gem 'rubocop', '~> 1.11', require: false
|
55
55
|
```
|
56
56
|
|
57
57
|
See [versioning](https://docs.rubocop.org/rubocop/1.0/versioning.html) for further details.
|
@@ -82,7 +82,7 @@ See the [compatibility documentation](https://docs.rubocop.org/rubocop/compatibi
|
|
82
82
|
|
83
83
|
If you use RuboCop in your project, you can include one of these badges in your readme to let people know that your code is written following the community Ruby Style Guide.
|
84
84
|
|
85
|
-
[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop
|
85
|
+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
|
86
86
|
|
87
87
|
[![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide)
|
88
88
|
|
@@ -90,7 +90,7 @@ If you use RuboCop in your project, you can include one of these badges in your
|
|
90
90
|
Here are the Markdown snippets for the two badges:
|
91
91
|
|
92
92
|
``` markdown
|
93
|
-
[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop
|
93
|
+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
|
94
94
|
|
95
95
|
[![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide)
|
96
96
|
```
|
@@ -116,14 +116,14 @@ See the [team page](https://docs.rubocop.org/rubocop/about/team.html) for more d
|
|
116
116
|
## Logo
|
117
117
|
|
118
118
|
RuboCop's logo was created by [Dimiter Petrov](https://www.chadomoto.com/). You can find the logo in various
|
119
|
-
formats [here](https://github.com/rubocop
|
119
|
+
formats [here](https://github.com/rubocop/rubocop/tree/master/logo).
|
120
120
|
|
121
121
|
The logo is licensed under a
|
122
122
|
[Creative Commons Attribution-NonCommercial 4.0 International License](https://creativecommons.org/licenses/by-nc/4.0/deed.en_GB).
|
123
123
|
|
124
124
|
## Contributors
|
125
125
|
|
126
|
-
Here's a [list](https://github.com/rubocop
|
126
|
+
Here's a [list](https://github.com/rubocop/rubocop/graphs/contributors) of
|
127
127
|
all the people who have contributed to the development of RuboCop.
|
128
128
|
|
129
129
|
I'm extremely grateful to each and every one of them!
|
data/assets/output.html.erb
CHANGED
@@ -254,7 +254,7 @@
|
|
254
254
|
<% end %>
|
255
255
|
</div>
|
256
256
|
<footer>
|
257
|
-
Generated by <a href="https://github.com/rubocop
|
257
|
+
Generated by <a href="https://github.com/rubocop/rubocop">RuboCop</a>
|
258
258
|
<span class="version"><%= RuboCop::Version::STRING %></span>
|
259
259
|
</footer>
|
260
260
|
</body>
|
data/config/default.yml
CHANGED
@@ -203,6 +203,13 @@ Bundler/OrderedGems:
|
|
203
203
|
|
204
204
|
#################### Gemspec ###############################
|
205
205
|
|
206
|
+
Gemspec/DateAssignment:
|
207
|
+
Description: 'Checks that `date =` is not used in gemspec file, it is set automatically when the gem is packaged.'
|
208
|
+
Enabled: pending
|
209
|
+
VersionAdded: '1.10'
|
210
|
+
Include:
|
211
|
+
- '**/*.gemspec'
|
212
|
+
|
206
213
|
Gemspec/DuplicatedAssignment:
|
207
214
|
Description: 'An attribute assignment method calls should be listed only once in a gemspec.'
|
208
215
|
Enabled: true
|
@@ -1446,23 +1453,31 @@ Lint/Debugger:
|
|
1446
1453
|
Description: 'Check for debugger calls.'
|
1447
1454
|
Enabled: true
|
1448
1455
|
VersionAdded: '0.14'
|
1449
|
-
VersionChanged: '
|
1450
|
-
DebuggerReceivers:
|
1451
|
-
- binding
|
1452
|
-
- Kernel
|
1453
|
-
- Pry
|
1456
|
+
VersionChanged: '1.10'
|
1457
|
+
DebuggerReceivers: [] # deprecated
|
1454
1458
|
DebuggerMethods:
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1459
|
+
# Groups are available so that a specific group can be disabled in
|
1460
|
+
# a user's configuration, but are otherwise not significant.
|
1461
|
+
Kernel:
|
1462
|
+
- binding.irb
|
1463
|
+
Byebug:
|
1464
|
+
- byebug
|
1465
|
+
- remote_byebug
|
1466
|
+
- Kernel.byebug
|
1467
|
+
- Kernel.remote_byebug
|
1468
|
+
Capybara:
|
1469
|
+
- save_and_open_page
|
1470
|
+
- save_and_open_screenshot
|
1471
|
+
Pry:
|
1472
|
+
- binding.pry
|
1473
|
+
- binding.remote_pry
|
1474
|
+
- binding.pry_remote
|
1475
|
+
- Pry.rescue
|
1476
|
+
Rails:
|
1477
|
+
- debugger
|
1478
|
+
- Kernel.debugger
|
1479
|
+
WebConsole:
|
1480
|
+
- binding.console
|
1466
1481
|
|
1467
1482
|
Lint/DeprecatedClassMethods:
|
1468
1483
|
Description: 'Check for deprecated class method calls.'
|
@@ -3087,6 +3102,8 @@ Style/ConstantVisibility:
|
|
3087
3102
|
visibility declarations.
|
3088
3103
|
Enabled: false
|
3089
3104
|
VersionAdded: '0.66'
|
3105
|
+
VersionChanged: '1.10'
|
3106
|
+
IgnoreModules: false
|
3090
3107
|
|
3091
3108
|
# Checks that you have put a copyright in a comment before any code.
|
3092
3109
|
#
|
@@ -3425,6 +3442,13 @@ Style/HashAsLastArrayItem:
|
|
3425
3442
|
- braces
|
3426
3443
|
- no_braces
|
3427
3444
|
|
3445
|
+
Style/HashConversion:
|
3446
|
+
Description: 'Avoid Hash[] in favor of ary.to_h or literal hashes.'
|
3447
|
+
Enabled: pending
|
3448
|
+
VersionAdded: '1.10'
|
3449
|
+
VersionChanged: '1.11'
|
3450
|
+
AllowSplatArgument: true
|
3451
|
+
|
3428
3452
|
Style/HashEachMethods:
|
3429
3453
|
Description: 'Use Hash#each_key and Hash#each_value.'
|
3430
3454
|
StyleGuide: '#hash-each'
|
@@ -3521,6 +3545,9 @@ Style/IfWithBooleanLiteralBranches:
|
|
3521
3545
|
Description: 'Checks for redundant `if` with boolean literal branches.'
|
3522
3546
|
Enabled: pending
|
3523
3547
|
VersionAdded: '1.9'
|
3548
|
+
SafeAutoCorrect: false
|
3549
|
+
AllowedMethods:
|
3550
|
+
- nonzero?
|
3524
3551
|
|
3525
3552
|
Style/IfWithSemicolon:
|
3526
3553
|
Description: 'Do not use if x; .... Use the ternary operator instead.'
|
@@ -4561,6 +4588,7 @@ Style/SymbolProc:
|
|
4561
4588
|
Safe: false
|
4562
4589
|
VersionAdded: '0.26'
|
4563
4590
|
VersionChanged: '1.5'
|
4591
|
+
AllowMethodsWithArguments: false
|
4564
4592
|
# A list of method names to be ignored by the check.
|
4565
4593
|
# The names should be fairly unique, otherwise you'll end up ignoring lots of code.
|
4566
4594
|
IgnoredMethods:
|
@@ -4713,6 +4741,16 @@ Style/UnlessElse:
|
|
4713
4741
|
Enabled: true
|
4714
4742
|
VersionAdded: '0.9'
|
4715
4743
|
|
4744
|
+
Style/UnlessLogicalOperators:
|
4745
|
+
Description: >-
|
4746
|
+
Checks for use of logical operators in an unless condition.
|
4747
|
+
Enabled: false
|
4748
|
+
VersionAdded: '1.11'
|
4749
|
+
EnforcedStyle: forbid_mixed_logical_operators
|
4750
|
+
SupportedStyles:
|
4751
|
+
- forbid_mixed_logical_operators
|
4752
|
+
- forbid_logical_operators
|
4753
|
+
|
4716
4754
|
Style/UnpackFirst:
|
4717
4755
|
Description: >-
|
4718
4756
|
Checks for accessing the first element of `String#unpack`
|
data/config/obsoletion.yml
CHANGED
@@ -187,6 +187,10 @@ changed_parameters:
|
|
187
187
|
parameters: ExcludedMethods
|
188
188
|
alternative: IgnoredMethods
|
189
189
|
severity: warning
|
190
|
+
- cops: Lint/Debugger
|
191
|
+
parameters: DebuggerReceivers
|
192
|
+
reason: "`DebuggerReceivers` is no longer necessary, method receivers should be specified in `DebuggerMethods` instead."
|
193
|
+
severity: warning
|
190
194
|
|
191
195
|
# Enforced styles that have been removed or replaced
|
192
196
|
changed_enforced_styles:
|
data/lib/rubocop.rb
CHANGED
@@ -35,6 +35,7 @@ require_relative 'rubocop/cop/offense'
|
|
35
35
|
require_relative 'rubocop/cop/message_annotator'
|
36
36
|
require_relative 'rubocop/cop/ignored_node'
|
37
37
|
require_relative 'rubocop/cop/autocorrect_logic'
|
38
|
+
require_relative 'rubocop/cop/exclude_limit'
|
38
39
|
require_relative 'rubocop/cop/badge'
|
39
40
|
require_relative 'rubocop/cop/registry'
|
40
41
|
require_relative 'rubocop/cop/base'
|
@@ -151,6 +152,7 @@ require_relative 'rubocop/cop/bundler/gem_comment'
|
|
151
152
|
require_relative 'rubocop/cop/bundler/insecure_protocol_source'
|
152
153
|
require_relative 'rubocop/cop/bundler/ordered_gems'
|
153
154
|
|
155
|
+
require_relative 'rubocop/cop/gemspec/date_assignment'
|
154
156
|
require_relative 'rubocop/cop/gemspec/duplicated_assignment'
|
155
157
|
require_relative 'rubocop/cop/gemspec/ordered_dependencies'
|
156
158
|
require_relative 'rubocop/cop/gemspec/required_ruby_version'
|
@@ -471,6 +473,7 @@ require_relative 'rubocop/cop/style/global_std_stream'
|
|
471
473
|
require_relative 'rubocop/cop/style/global_vars'
|
472
474
|
require_relative 'rubocop/cop/style/guard_clause'
|
473
475
|
require_relative 'rubocop/cop/style/hash_as_last_array_item'
|
476
|
+
require_relative 'rubocop/cop/style/hash_conversion'
|
474
477
|
require_relative 'rubocop/cop/style/hash_each_methods'
|
475
478
|
require_relative 'rubocop/cop/style/hash_except'
|
476
479
|
require_relative 'rubocop/cop/style/hash_like_case'
|
@@ -602,6 +605,7 @@ require_relative 'rubocop/cop/style/trailing_method_end_statement'
|
|
602
605
|
require_relative 'rubocop/cop/style/trailing_underscore_variable'
|
603
606
|
require_relative 'rubocop/cop/style/trivial_accessors'
|
604
607
|
require_relative 'rubocop/cop/style/unless_else'
|
608
|
+
require_relative 'rubocop/cop/style/unless_logical_operators'
|
605
609
|
require_relative 'rubocop/cop/style/unpack_first'
|
606
610
|
require_relative 'rubocop/cop/style/variable_interpolation'
|
607
611
|
require_relative 'rubocop/cop/style/when_then'
|
@@ -86,7 +86,7 @@ module RuboCop
|
|
86
86
|
def maybe_print_corrected_source
|
87
87
|
# Integration tools (like RubyMine) expect to have only the JSON result
|
88
88
|
# when specifying JSON format. Similar HTML and JUnit are targeted as well.
|
89
|
-
# See: https://github.com/rubocop
|
89
|
+
# See: https://github.com/rubocop/rubocop/issues/8673
|
90
90
|
return if INTEGRATION_FORMATTERS.include?(@options[:format])
|
91
91
|
|
92
92
|
return unless @options[:stdin] && @options[:auto_correct]
|
@@ -22,7 +22,7 @@ module RuboCop
|
|
22
22
|
'RuboCop extension libraries might be helpful:'
|
23
23
|
|
24
24
|
extensions.sort.each do |extension|
|
25
|
-
puts " * #{extension} (http://github.com/rubocop
|
25
|
+
puts " * #{extension} (http://github.com/rubocop/#{extension})"
|
26
26
|
end
|
27
27
|
|
28
28
|
puts
|
data/lib/rubocop/config.rb
CHANGED
data/lib/rubocop/cop/base.rb
CHANGED
@@ -30,7 +30,7 @@ module RuboCop
|
|
30
30
|
# if Dir.exist?(local)
|
31
31
|
# gem 'rubocop', path: local
|
32
32
|
# elsif ENV['RUBOCOP_VERSION'] == 'master'
|
33
|
-
# gem 'rubocop', git: 'https://github.com/rubocop
|
33
|
+
# gem 'rubocop', git: 'https://github.com/rubocop/rubocop.git'
|
34
34
|
# else
|
35
35
|
# gem 'rubocop', '~> 0.90.0'
|
36
36
|
# end
|
@@ -57,6 +57,7 @@ module RuboCop
|
|
57
57
|
|
58
58
|
private
|
59
59
|
|
60
|
+
# @!method gem_declarations(node)
|
60
61
|
def_node_search :gem_declarations, '(send nil? :gem str ...)'
|
61
62
|
|
62
63
|
def duplicated_gem_nodes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
# Allows specified configuration options to have an exclude limit
|
5
|
+
# ie. a maximum value tracked that it can be used by `--auto-gen-config`.
|
6
|
+
module ExcludeLimit
|
7
|
+
# Sets up a configuration option to have an exclude limit tracked.
|
8
|
+
# The parameter name given is transformed into a method name (eg. `Max`
|
9
|
+
# becomes `self.max=` and `MinDigits` becomes `self.min_digits=`).
|
10
|
+
def exclude_limit(parameter_name, method_name: transform(parameter_name))
|
11
|
+
define_method("#{method_name}=") do |value|
|
12
|
+
cfg = config_to_allow_offenses
|
13
|
+
cfg[:exclude_limit] ||= {}
|
14
|
+
current_max = cfg[:exclude_limit][parameter_name]
|
15
|
+
value = [current_max, value].max if current_max
|
16
|
+
cfg[:exclude_limit][parameter_name] = value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def transform(parameter_name)
|
23
|
+
parameter_name.gsub(/(?<!\A)(?=[A-Z])/, '_').downcase
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Gemspec
|
6
|
+
# This cop checks that `date =` is not used in gemspec file.
|
7
|
+
# It is set automatically when the gem is packaged.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
#
|
11
|
+
# # bad
|
12
|
+
# Gem::Specification.new do |spec|
|
13
|
+
# s.name = 'your_cool_gem_name'
|
14
|
+
# spec.date = Time.now.strftime('%Y-%m-%d')
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# # good
|
18
|
+
# Gem::Specification.new do |spec|
|
19
|
+
# s.name = 'your_cool_gem_name'
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
class DateAssignment < Base
|
23
|
+
include RangeHelp
|
24
|
+
extend AutoCorrector
|
25
|
+
|
26
|
+
MSG = 'Do not use `date =` in gemspec, it is set automatically when the gem is packaged.'
|
27
|
+
|
28
|
+
# @!method gem_specification(node)
|
29
|
+
def_node_matcher :gem_specification, <<~PATTERN
|
30
|
+
(block
|
31
|
+
(send
|
32
|
+
(const
|
33
|
+
(const {cbase nil?} :Gem) :Specification) :new)
|
34
|
+
...)
|
35
|
+
PATTERN
|
36
|
+
|
37
|
+
def on_block(block_node)
|
38
|
+
return unless gem_specification(block_node)
|
39
|
+
|
40
|
+
block_parameter = block_node.arguments.first.source
|
41
|
+
|
42
|
+
date_assignment = block_node.descendants.detect do |node|
|
43
|
+
node.send_type? && node.receiver&.source == block_parameter && node.method?(:date=)
|
44
|
+
end
|
45
|
+
|
46
|
+
return unless date_assignment
|
47
|
+
|
48
|
+
add_offense(date_assignment) do |corrector|
|
49
|
+
range = range_by_whole_lines(date_assignment.source_range, include_final_newline: true)
|
50
|
+
|
51
|
+
corrector.remove(range)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -40,6 +40,7 @@ module RuboCop
|
|
40
40
|
MSG = '`%<assignment>s` method calls already given on line '\
|
41
41
|
'%<line_of_first_occurrence>d of the gemspec.'
|
42
42
|
|
43
|
+
# @!method gem_specification(node)
|
43
44
|
def_node_search :gem_specification, <<~PATTERN
|
44
45
|
(block
|
45
46
|
(send
|
@@ -49,6 +50,7 @@ module RuboCop
|
|
49
50
|
(arg $_)) ...)
|
50
51
|
PATTERN
|
51
52
|
|
53
|
+
# @!method assignment_method_declarations(node)
|
52
54
|
def_node_search :assignment_method_declarations, <<~PATTERN
|
53
55
|
(send
|
54
56
|
(lvar #match_block_variable_name?) #assignment_method? ...)
|