rubocop 0.79.0 → 0.83.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 +5 -5
- data/config/default.yml +184 -50
- data/lib/rubocop.rb +15 -5
- data/lib/rubocop/ast/builder.rb +2 -0
- 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/mixin/method_dispatch_node.rb +8 -0
- data/lib/rubocop/ast/node/regexp_node.rb +2 -4
- data/lib/rubocop/ast/node/send_node.rb +4 -0
- data/lib/rubocop/ast/traversal.rb +20 -9
- data/lib/rubocop/cli.rb +11 -5
- data/lib/rubocop/comment_config.rb +6 -1
- data/lib/rubocop/config.rb +40 -10
- data/lib/rubocop/config_loader.rb +43 -33
- data/lib/rubocop/config_loader_resolver.rb +28 -1
- data/lib/rubocop/config_obsoletion.rb +4 -1
- data/lib/rubocop/config_validator.rb +18 -1
- 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/generator.rb +3 -2
- 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/condition_position.rb +12 -2
- 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/empty_lines_around_attribute_accessor.rb +68 -0
- 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/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 +36 -4
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -1
- 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/multiline_operation_indentation.rb +13 -4
- 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 +37 -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/layout/trailing_whitespace.rb +2 -2
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +38 -0
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +14 -0
- data/lib/rubocop/cop/lint/boolean_symbol.rb +12 -0
- data/lib/rubocop/cop/lint/debugger.rb +2 -2
- data/lib/rubocop/cop/lint/duplicate_methods.rb +1 -5
- data/lib/rubocop/cop/lint/empty_when.rb +29 -6
- data/lib/rubocop/cop/lint/ensure_return.rb +18 -1
- 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_as_condition.rb +10 -13
- 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/parentheses_as_grouped_expression.rb +21 -9
- 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 -6
- 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 -28
- 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_access_modifier.rb +12 -0
- data/lib/rubocop/cop/lint/useless_assignment.rb +3 -2
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +5 -0
- data/lib/rubocop/cop/lint/useless_setter_call.rb +4 -0
- data/lib/rubocop/cop/migration/department_name.rb +36 -10
- 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 +16 -1
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +178 -0
- data/lib/rubocop/cop/mixin/line_length_help.rb +2 -1
- data/lib/rubocop/cop/mixin/method_complexity.rb +5 -0
- data/lib/rubocop/cop/mixin/parser_diagnostic.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +7 -22
- data/lib/rubocop/cop/mixin/target_ruby_version.rb +5 -1
- 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 +26 -0
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -1
- data/lib/rubocop/cop/registry.rb +11 -4
- 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 -5
- 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/guard_clause.rb +25 -2
- 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/if_with_semicolon.rb +16 -0
- 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 +1 -21
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +5 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +5 -4
- 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 +16 -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 +1 -1
- data/lib/rubocop/cop/style/one_line_conditional.rb +4 -3
- data/lib/rubocop/cop/style/optional_arguments.rb +1 -1
- data/lib/rubocop/cop/style/or_assignment.rb +4 -3
- 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/slicing_with_range.rb +39 -0
- 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/zero_length_predicate.rb +1 -1
- data/lib/rubocop/cop/util.rb +24 -0
- data/lib/rubocop/cop/variable_force.rb +4 -1
- data/lib/rubocop/cop/variable_force/assignment.rb +1 -0
- data/lib/rubocop/cop/variable_force/scope.rb +1 -0
- data/lib/rubocop/cop/variable_force/variable.rb +1 -0
- 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/name_similarity.rb +12 -9
- data/lib/rubocop/node_pattern.rb +96 -10
- data/lib/rubocop/options.rb +18 -5
- 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 +0 -4
- data/lib/rubocop/runner.rb +7 -2
- data/lib/rubocop/target_finder.rb +6 -4
- data/lib/rubocop/target_ruby.rb +2 -2
- data/lib/rubocop/version.rb +1 -1
- metadata +35 -25
- 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/string_util.rb +0 -14
@@ -163,7 +163,7 @@ module RuboCop
|
|
163
163
|
ast, comments, tokens = parser.tokenize(@buffer)
|
164
164
|
|
165
165
|
ast.respond_to?(:complete!) && ast.complete!
|
166
|
-
rescue Parser::SyntaxError
|
166
|
+
rescue Parser::SyntaxError
|
167
167
|
# All errors are in diagnostics. No need to handle exception.
|
168
168
|
end
|
169
169
|
|
@@ -175,9 +175,6 @@ module RuboCop
|
|
175
175
|
# rubocop:disable Metrics/MethodLength
|
176
176
|
def parser_class(ruby_version)
|
177
177
|
case ruby_version
|
178
|
-
when 2.3
|
179
|
-
require 'parser/ruby23'
|
180
|
-
Parser::Ruby23
|
181
178
|
when 2.4
|
182
179
|
require 'parser/ruby24'
|
183
180
|
Parser::Ruby24
|
@@ -153,7 +153,7 @@ module RuboCop
|
|
153
153
|
annotations = []
|
154
154
|
|
155
155
|
annotated_source.each_line do |source_line|
|
156
|
-
if source_line
|
156
|
+
if ANNOTATION_PATTERN.match?(source_line)
|
157
157
|
annotations << [source.size, source_line]
|
158
158
|
else
|
159
159
|
source << source_line
|
data/lib/rubocop/runner.rb
CHANGED
@@ -61,7 +61,12 @@ module RuboCop
|
|
61
61
|
|
62
62
|
def find_target_files(paths)
|
63
63
|
target_finder = TargetFinder.new(@config_store, @options)
|
64
|
-
|
64
|
+
mode = if @options[:only_recognized_file_types]
|
65
|
+
:only_recognized_file_types
|
66
|
+
else
|
67
|
+
:all_file_types
|
68
|
+
end
|
69
|
+
target_files = target_finder.find(paths, mode)
|
65
70
|
target_files.each(&:freeze).freeze
|
66
71
|
end
|
67
72
|
|
@@ -314,7 +319,7 @@ module RuboCop
|
|
314
319
|
|
315
320
|
cop_classes.reject! { |c| c.match?(@options[:except]) }
|
316
321
|
|
317
|
-
Cop::Registry.new(cop_classes)
|
322
|
+
Cop::Registry.new(cop_classes, @options)
|
318
323
|
end
|
319
324
|
end
|
320
325
|
|
@@ -27,7 +27,7 @@ module RuboCop
|
|
27
27
|
# (if any). If args is empty, recursively find all Ruby source
|
28
28
|
# files under the current directory
|
29
29
|
# @return [Array] array of file paths
|
30
|
-
def find(args)
|
30
|
+
def find(args, mode)
|
31
31
|
return target_files_in_dir if args.empty?
|
32
32
|
|
33
33
|
files = []
|
@@ -36,7 +36,7 @@ module RuboCop
|
|
36
36
|
files += if File.directory?(arg)
|
37
37
|
target_files_in_dir(arg.chomp(File::SEPARATOR))
|
38
38
|
else
|
39
|
-
process_explicit_path(arg)
|
39
|
+
process_explicit_path(arg, mode)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -169,10 +169,12 @@ module RuboCop
|
|
169
169
|
ruby_file?(file) || configured_include?(file)
|
170
170
|
end
|
171
171
|
|
172
|
-
def process_explicit_path(path)
|
172
|
+
def process_explicit_path(path, mode)
|
173
173
|
files = path.include?('*') ? Dir[path] : [path]
|
174
174
|
|
175
|
-
|
175
|
+
if mode == :only_recognized_file_types || force_exclusion?
|
176
|
+
files.select! { |file| included_file?(file) }
|
177
|
+
end
|
176
178
|
|
177
179
|
return files unless force_exclusion?
|
178
180
|
|
data/lib/rubocop/target_ruby.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
module RuboCop
|
4
4
|
# The kind of Ruby that code inspected by RuboCop is written in.
|
5
5
|
class TargetRuby
|
6
|
-
KNOWN_RUBIES = [2.
|
6
|
+
KNOWN_RUBIES = [2.4, 2.5, 2.6, 2.7].freeze
|
7
7
|
DEFAULT_VERSION = KNOWN_RUBIES.first
|
8
8
|
|
9
9
|
OBSOLETE_RUBIES = {
|
10
|
-
1.9 => '0.50', 2.0 => '0.50', 2.1 => '0.58', 2.2 => '0.69'
|
10
|
+
1.9 => '0.50', 2.0 => '0.50', 2.1 => '0.58', 2.2 => '0.69', 2.3 => '0.82'
|
11
11
|
}.freeze
|
12
12
|
private_constant :KNOWN_RUBIES, :OBSOLETE_RUBIES
|
13
13
|
|
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.83.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,22 +10,8 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-05-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: jaro_winkler
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
-
requirements:
|
19
|
-
- - "~>"
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 1.5.1
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
requirements:
|
26
|
-
- - "~>"
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
version: 1.5.1
|
29
15
|
- !ruby/object:Gem::Dependency
|
30
16
|
name: parallel
|
31
17
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,6 +60,20 @@ dependencies:
|
|
74
60
|
- - "<"
|
75
61
|
- !ruby/object:Gem::Version
|
76
62
|
version: '4.0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rexml
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
77
|
- !ruby/object:Gem::Dependency
|
78
78
|
name: ruby-progressbar
|
79
79
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,7 +97,7 @@ dependencies:
|
|
97
97
|
version: 1.4.0
|
98
98
|
- - "<"
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version: '
|
100
|
+
version: '2.0'
|
101
101
|
type: :runtime
|
102
102
|
prerelease: false
|
103
103
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -107,7 +107,7 @@ dependencies:
|
|
107
107
|
version: 1.4.0
|
108
108
|
- - "<"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '2.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: bundler
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- lib/rubocop/ast/node/array_node.rb
|
157
157
|
- lib/rubocop/ast/node/block_node.rb
|
158
158
|
- lib/rubocop/ast/node/break_node.rb
|
159
|
+
- lib/rubocop/ast/node/case_match_node.rb
|
159
160
|
- lib/rubocop/ast/node/case_node.rb
|
160
161
|
- lib/rubocop/ast/node/class_node.rb
|
161
162
|
- lib/rubocop/ast/node/def_node.rb
|
@@ -278,6 +279,7 @@ files:
|
|
278
279
|
- lib/rubocop/cop/layout/empty_lines.rb
|
279
280
|
- lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb
|
280
281
|
- lib/rubocop/cop/layout/empty_lines_around_arguments.rb
|
282
|
+
- lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb
|
281
283
|
- lib/rubocop/cop/layout/empty_lines_around_begin_body.rb
|
282
284
|
- lib/rubocop/cop/layout/empty_lines_around_block_body.rb
|
283
285
|
- lib/rubocop/cop/layout/empty_lines_around_class_body.rb
|
@@ -299,6 +301,7 @@ files:
|
|
299
301
|
- lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb
|
300
302
|
- lib/rubocop/cop/layout/heredoc_indentation.rb
|
301
303
|
- lib/rubocop/cop/layout/indentation_consistency.rb
|
304
|
+
- lib/rubocop/cop/layout/indentation_style.rb
|
302
305
|
- lib/rubocop/cop/layout/indentation_width.rb
|
303
306
|
- lib/rubocop/cop/layout/initial_indentation.rb
|
304
307
|
- lib/rubocop/cop/layout/leading_comment_space.rb
|
@@ -325,6 +328,7 @@ files:
|
|
325
328
|
- lib/rubocop/cop/layout/space_around_block_parameters.rb
|
326
329
|
- lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb
|
327
330
|
- lib/rubocop/cop/layout/space_around_keyword.rb
|
331
|
+
- lib/rubocop/cop/layout/space_around_method_call_operator.rb
|
328
332
|
- lib/rubocop/cop/layout/space_around_operators.rb
|
329
333
|
- lib/rubocop/cop/layout/space_before_block_braces.rb
|
330
334
|
- lib/rubocop/cop/layout/space_before_comma.rb
|
@@ -341,7 +345,6 @@ files:
|
|
341
345
|
- lib/rubocop/cop/layout/space_inside_range_literal.rb
|
342
346
|
- lib/rubocop/cop/layout/space_inside_reference_brackets.rb
|
343
347
|
- lib/rubocop/cop/layout/space_inside_string_interpolation.rb
|
344
|
-
- lib/rubocop/cop/layout/tab.rb
|
345
348
|
- lib/rubocop/cop/layout/trailing_empty_lines.rb
|
346
349
|
- lib/rubocop/cop/layout/trailing_whitespace.rb
|
347
350
|
- lib/rubocop/cop/lint/ambiguous_block_association.rb
|
@@ -363,7 +366,6 @@ files:
|
|
363
366
|
- lib/rubocop/cop/lint/empty_expression.rb
|
364
367
|
- lib/rubocop/cop/lint/empty_interpolation.rb
|
365
368
|
- lib/rubocop/cop/lint/empty_when.rb
|
366
|
-
- lib/rubocop/cop/lint/end_in_method.rb
|
367
369
|
- lib/rubocop/cop/lint/ensure_return.rb
|
368
370
|
- lib/rubocop/cop/lint/erb_new_arguments.rb
|
369
371
|
- lib/rubocop/cop/lint/flip_flop.rb
|
@@ -389,6 +391,7 @@ files:
|
|
389
391
|
- lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb
|
390
392
|
- lib/rubocop/cop/lint/percent_string_array.rb
|
391
393
|
- lib/rubocop/cop/lint/percent_symbol_array.rb
|
394
|
+
- lib/rubocop/cop/lint/raise_exception.rb
|
392
395
|
- lib/rubocop/cop/lint/rand_one.rb
|
393
396
|
- lib/rubocop/cop/lint/redundant_cop_disable_directive.rb
|
394
397
|
- lib/rubocop/cop/lint/redundant_cop_enable_directive.rb
|
@@ -410,6 +413,7 @@ files:
|
|
410
413
|
- lib/rubocop/cop/lint/shadowed_argument.rb
|
411
414
|
- lib/rubocop/cop/lint/shadowed_exception.rb
|
412
415
|
- lib/rubocop/cop/lint/shadowing_outer_local_variable.rb
|
416
|
+
- lib/rubocop/cop/lint/struct_new_override.rb
|
413
417
|
- lib/rubocop/cop/lint/suppressed_exception.rb
|
414
418
|
- lib/rubocop/cop/lint/syntax.rb
|
415
419
|
- lib/rubocop/cop/lint/to_json.rb
|
@@ -461,6 +465,7 @@ files:
|
|
461
465
|
- lib/rubocop/cop/mixin/first_element_line_break.rb
|
462
466
|
- lib/rubocop/cop/mixin/frozen_string_literal.rb
|
463
467
|
- lib/rubocop/cop/mixin/hash_alignment_styles.rb
|
468
|
+
- lib/rubocop/cop/mixin/hash_transform_method.rb
|
464
469
|
- lib/rubocop/cop/mixin/heredoc.rb
|
465
470
|
- lib/rubocop/cop/mixin/ignored_methods.rb
|
466
471
|
- lib/rubocop/cop/mixin/ignored_pattern.rb
|
@@ -536,7 +541,6 @@ files:
|
|
536
541
|
- lib/rubocop/cop/style/begin_block.rb
|
537
542
|
- lib/rubocop/cop/style/block_comments.rb
|
538
543
|
- lib/rubocop/cop/style/block_delimiters.rb
|
539
|
-
- lib/rubocop/cop/style/braces_around_hash_parameters.rb
|
540
544
|
- lib/rubocop/cop/style/case_equality.rb
|
541
545
|
- lib/rubocop/cop/style/character_literal.rb
|
542
546
|
- lib/rubocop/cop/style/class_and_module_children.rb
|
@@ -555,6 +559,7 @@ files:
|
|
555
559
|
- lib/rubocop/cop/style/date_time.rb
|
556
560
|
- lib/rubocop/cop/style/def_with_parentheses.rb
|
557
561
|
- lib/rubocop/cop/style/dir.rb
|
562
|
+
- lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb
|
558
563
|
- lib/rubocop/cop/style/documentation.rb
|
559
564
|
- lib/rubocop/cop/style/documentation_method.rb
|
560
565
|
- lib/rubocop/cop/style/double_cop_disable_directive.rb
|
@@ -572,6 +577,7 @@ files:
|
|
572
577
|
- lib/rubocop/cop/style/eval_with_location.rb
|
573
578
|
- lib/rubocop/cop/style/even_odd.rb
|
574
579
|
- lib/rubocop/cop/style/expand_path_arguments.rb
|
580
|
+
- lib/rubocop/cop/style/exponential_notation.rb
|
575
581
|
- lib/rubocop/cop/style/float_division.rb
|
576
582
|
- lib/rubocop/cop/style/for.rb
|
577
583
|
- lib/rubocop/cop/style/format_string.rb
|
@@ -579,7 +585,10 @@ files:
|
|
579
585
|
- lib/rubocop/cop/style/frozen_string_literal_comment.rb
|
580
586
|
- lib/rubocop/cop/style/global_vars.rb
|
581
587
|
- lib/rubocop/cop/style/guard_clause.rb
|
588
|
+
- lib/rubocop/cop/style/hash_each_methods.rb
|
582
589
|
- lib/rubocop/cop/style/hash_syntax.rb
|
590
|
+
- lib/rubocop/cop/style/hash_transform_keys.rb
|
591
|
+
- lib/rubocop/cop/style/hash_transform_values.rb
|
583
592
|
- lib/rubocop/cop/style/identical_conditional_branches.rb
|
584
593
|
- lib/rubocop/cop/style/if_inside_else.rb
|
585
594
|
- lib/rubocop/cop/style/if_unless_modifier.rb
|
@@ -666,6 +675,7 @@ files:
|
|
666
675
|
- lib/rubocop/cop/style/signal_exception.rb
|
667
676
|
- lib/rubocop/cop/style/single_line_block_params.rb
|
668
677
|
- lib/rubocop/cop/style/single_line_methods.rb
|
678
|
+
- lib/rubocop/cop/style/slicing_with_range.rb
|
669
679
|
- lib/rubocop/cop/style/special_global_vars.rb
|
670
680
|
- lib/rubocop/cop/style/stabby_lambda_parentheses.rb
|
671
681
|
- lib/rubocop/cop/style/stderr_puts.rb
|
@@ -684,6 +694,7 @@ files:
|
|
684
694
|
- lib/rubocop/cop/style/trailing_body_on_module.rb
|
685
695
|
- lib/rubocop/cop/style/trailing_comma_in_arguments.rb
|
686
696
|
- lib/rubocop/cop/style/trailing_comma_in_array_literal.rb
|
697
|
+
- lib/rubocop/cop/style/trailing_comma_in_block_args.rb
|
687
698
|
- lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
|
688
699
|
- lib/rubocop/cop/style/trailing_method_end_statement.rb
|
689
700
|
- lib/rubocop/cop/style/trailing_underscore_variable.rb
|
@@ -716,13 +727,13 @@ files:
|
|
716
727
|
- lib/rubocop/formatter/clang_style_formatter.rb
|
717
728
|
- lib/rubocop/formatter/colorizable.rb
|
718
729
|
- lib/rubocop/formatter/disabled_config_formatter.rb
|
719
|
-
- lib/rubocop/formatter/disabled_lines_formatter.rb
|
720
730
|
- lib/rubocop/formatter/emacs_style_formatter.rb
|
721
731
|
- lib/rubocop/formatter/file_list_formatter.rb
|
722
732
|
- lib/rubocop/formatter/formatter_set.rb
|
723
733
|
- lib/rubocop/formatter/fuubar_style_formatter.rb
|
724
734
|
- lib/rubocop/formatter/html_formatter.rb
|
725
735
|
- lib/rubocop/formatter/json_formatter.rb
|
736
|
+
- lib/rubocop/formatter/junit_formatter.rb
|
726
737
|
- lib/rubocop/formatter/offense_count_formatter.rb
|
727
738
|
- lib/rubocop/formatter/pacman_formatter.rb
|
728
739
|
- lib/rubocop/formatter/progress_formatter.rb
|
@@ -748,7 +759,6 @@ files:
|
|
748
759
|
- lib/rubocop/rspec/support.rb
|
749
760
|
- lib/rubocop/runner.rb
|
750
761
|
- lib/rubocop/string_interpreter.rb
|
751
|
-
- lib/rubocop/string_util.rb
|
752
762
|
- lib/rubocop/target_finder.rb
|
753
763
|
- lib/rubocop/target_ruby.rb
|
754
764
|
- lib/rubocop/token.rb
|
@@ -772,14 +782,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
772
782
|
requirements:
|
773
783
|
- - ">="
|
774
784
|
- !ruby/object:Gem::Version
|
775
|
-
version: 2.
|
785
|
+
version: 2.4.0
|
776
786
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
777
787
|
requirements:
|
778
788
|
- - ">="
|
779
789
|
- !ruby/object:Gem::Version
|
780
790
|
version: '0'
|
781
791
|
requirements: []
|
782
|
-
rubygems_version: 3.
|
792
|
+
rubygems_version: 3.1.2
|
783
793
|
signing_key:
|
784
794
|
specification_version: 4
|
785
795
|
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
|