rubocop 0.52.1 → 0.53.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/config/default.yml +118 -46
- data/config/disabled.yml +8 -8
- data/config/enabled.yml +84 -28
- data/lib/rubocop.rb +28 -8
- data/lib/rubocop/ast/builder.rb +35 -37
- data/lib/rubocop/ast/node.rb +16 -1
- data/lib/rubocop/ast/node/and_node.rb +0 -8
- data/lib/rubocop/ast/node/block_node.rb +1 -9
- data/lib/rubocop/ast/node/case_node.rb +0 -8
- data/lib/rubocop/ast/node/ensure_node.rb +0 -8
- data/lib/rubocop/ast/node/for_node.rb +0 -8
- data/lib/rubocop/ast/node/or_node.rb +0 -8
- data/lib/rubocop/ast/node/pair_node.rb +0 -8
- data/lib/rubocop/ast/node/resbody_node.rb +0 -8
- data/lib/rubocop/ast/node/send_node.rb +0 -8
- data/lib/rubocop/ast/node/symbol_node.rb +0 -8
- data/lib/rubocop/ast/node/until_node.rb +0 -8
- data/lib/rubocop/ast/node/when_node.rb +0 -8
- data/lib/rubocop/ast/node/while_node.rb +0 -8
- data/lib/rubocop/cli.rb +17 -7
- data/lib/rubocop/comment_config.rb +24 -3
- data/lib/rubocop/config.rb +75 -6
- data/lib/rubocop/config_loader.rb +18 -28
- data/lib/rubocop/config_loader_resolver.rb +61 -9
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +3 -1
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +4 -2
- data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -1
- data/lib/rubocop/cop/commissioner.rb +2 -2
- data/lib/rubocop/cop/cop.rb +4 -0
- data/lib/rubocop/cop/corrector.rb +11 -1
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +3 -6
- data/lib/rubocop/cop/correctors/line_break_corrector.rb +59 -0
- data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/space_corrector.rb +13 -0
- data/lib/rubocop/cop/correctors/unused_arg_corrector.rb +1 -1
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +3 -1
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
- data/lib/rubocop/cop/gemspec/required_ruby_version.rb +3 -5
- data/lib/rubocop/cop/generator.rb +29 -8
- data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +2 -0
- data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +2 -0
- data/lib/rubocop/cop/layout/align_hash.rb +106 -37
- data/lib/rubocop/cop/{lint → layout}/block_alignment.rb +8 -5
- data/lib/rubocop/cop/layout/block_end_newline.rb +7 -17
- data/lib/rubocop/cop/layout/case_indentation.rb +1 -0
- data/lib/rubocop/cop/layout/class_structure.rb +6 -7
- data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
- data/lib/rubocop/cop/{lint → layout}/condition_position.rb +3 -3
- data/lib/rubocop/cop/{lint → layout}/def_end_alignment.rb +2 -1
- data/lib/rubocop/cop/layout/else_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/empty_comment.rb +140 -0
- data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +2 -0
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +2 -0
- data/lib/rubocop/cop/layout/empty_lines.rb +3 -1
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +7 -5
- data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +20 -10
- data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +20 -0
- data/lib/rubocop/cop/{lint → layout}/end_alignment.rb +37 -6
- data/lib/rubocop/cop/layout/end_of_line.rb +1 -0
- data/lib/rubocop/cop/layout/extra_spacing.rb +30 -37
- data/lib/rubocop/cop/layout/first_parameter_indentation.rb +1 -0
- data/lib/rubocop/cop/layout/indent_heredoc.rb +38 -2
- data/lib/rubocop/cop/layout/indentation_consistency.rb +105 -1
- data/lib/rubocop/cop/layout/indentation_width.rb +4 -3
- data/lib/rubocop/cop/layout/initial_indentation.rb +15 -1
- data/lib/rubocop/cop/layout/leading_comment_space.rb +4 -2
- data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +1 -0
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +2 -0
- data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +62 -29
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +74 -33
- data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +16 -2
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +3 -1
- data/lib/rubocop/cop/layout/space_after_method_name.rb +2 -0
- data/lib/rubocop/cop/layout/space_after_not.rb +2 -0
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +1 -0
- data/lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb +15 -2
- data/lib/rubocop/cop/layout/space_around_operators.rb +15 -13
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +13 -1
- data/lib/rubocop/cop/layout/space_before_comment.rb +6 -4
- data/lib/rubocop/cop/layout/space_before_first_arg.rb +1 -0
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +1 -0
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +30 -45
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +3 -2
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +48 -18
- data/lib/rubocop/cop/layout/space_inside_parens.rb +8 -7
- data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +57 -11
- data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +1 -0
- data/lib/rubocop/cop/layout/tab.rb +42 -16
- data/lib/rubocop/cop/layout/trailing_blank_lines.rb +46 -13
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +12 -0
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +5 -3
- data/lib/rubocop/cop/lint/big_decimal_new.rb +44 -0
- data/lib/rubocop/cop/lint/boolean_symbol.rb +2 -2
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +2 -2
- data/lib/rubocop/cop/lint/debugger.rb +2 -2
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +5 -4
- data/lib/rubocop/cop/lint/duplicate_methods.rb +20 -9
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +4 -3
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +16 -10
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +5 -4
- data/lib/rubocop/cop/lint/inherit_exception.rb +2 -2
- data/lib/rubocop/cop/lint/interpolation_check.rb +4 -3
- data/lib/rubocop/cop/lint/literal_as_condition.rb +2 -2
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +2 -0
- data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +7 -5
- data/lib/rubocop/cop/lint/nested_percent_literal.rb +1 -1
- data/lib/rubocop/cop/lint/number_conversion.rb +59 -0
- data/lib/rubocop/cop/lint/ordered_magic_comments.rb +86 -0
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +2 -0
- data/lib/rubocop/cop/lint/percent_string_array.rb +0 -2
- data/lib/rubocop/cop/lint/rand_one.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_with_index.rb +2 -0
- data/lib/rubocop/cop/lint/redundant_with_object.rb +2 -0
- data/lib/rubocop/cop/lint/require_parentheses.rb +2 -0
- data/lib/rubocop/cop/lint/rescue_type.rb +6 -3
- data/lib/rubocop/cop/lint/return_in_void_context.rb +2 -2
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +17 -21
- data/lib/rubocop/cop/lint/script_permission.rb +30 -10
- data/lib/rubocop/cop/lint/shadowed_argument.rb +3 -3
- data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -0
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +2 -2
- data/lib/rubocop/cop/lint/unified_integer.rb +2 -2
- data/lib/rubocop/cop/lint/{unneeded_disable.rb → unneeded_cop_disable_directive.rb} +13 -7
- data/lib/rubocop/cop/lint/unneeded_cop_enable_directive.rb +97 -0
- data/lib/rubocop/cop/lint/unneeded_require_statement.rb +1 -0
- data/lib/rubocop/cop/lint/unreachable_code.rb +3 -3
- data/lib/rubocop/cop/lint/uri_escape_unescape.rb +11 -10
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +7 -5
- data/lib/rubocop/cop/lint/useless_assignment.rb +2 -2
- data/lib/rubocop/cop/lint/useless_setter_call.rb +2 -2
- data/lib/rubocop/cop/lint/void.rb +49 -10
- data/lib/rubocop/cop/metrics/block_nesting.rb +1 -1
- data/lib/rubocop/cop/metrics/line_length.rb +5 -2
- data/lib/rubocop/cop/mixin/alignment.rb +4 -0
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +1 -1
- data/lib/rubocop/cop/mixin/def_node.rb +4 -0
- data/lib/rubocop/cop/mixin/documentation_comment.rb +11 -3
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +12 -2
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +20 -1
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +4 -0
- data/lib/rubocop/cop/mixin/hash_alignment.rb +2 -2
- data/lib/rubocop/cop/mixin/match_range.rb +2 -0
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +6 -0
- data/lib/rubocop/cop/mixin/nil_methods.rb +19 -0
- data/lib/rubocop/cop/mixin/percent_literal.rb +57 -9
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +6 -5
- data/lib/rubocop/cop/mixin/range_help.rb +102 -0
- data/lib/rubocop/cop/mixin/rescue_node.rb +1 -1
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +8 -7
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +11 -9
- data/lib/rubocop/cop/mixin/statement_modifier.rb +3 -10
- data/lib/rubocop/cop/mixin/surrounding_space.rb +38 -8
- data/lib/rubocop/cop/mixin/trailing_body.rb +26 -0
- data/lib/rubocop/cop/mixin/trailing_comma.rb +15 -3
- data/lib/rubocop/cop/mixin/uncommunicative_name.rb +104 -0
- data/lib/rubocop/cop/naming/ascii_identifiers.rb +3 -1
- data/lib/rubocop/cop/naming/file_name.rb +5 -10
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +76 -0
- data/lib/rubocop/cop/naming/uncommunicative_block_param_name.rb +48 -0
- data/lib/rubocop/cop/naming/uncommunicative_method_param_name.rb +57 -0
- data/lib/rubocop/cop/offense.rb +3 -2
- data/lib/rubocop/cop/performance/case_when_splat.rb +1 -0
- data/lib/rubocop/cop/performance/casecmp.rb +17 -8
- data/lib/rubocop/cop/performance/compare_with_block.rb +2 -0
- data/lib/rubocop/cop/performance/count.rb +1 -0
- data/lib/rubocop/cop/performance/fixed_size.rb +41 -0
- data/lib/rubocop/cop/performance/flat_map.rb +2 -0
- data/lib/rubocop/cop/performance/lstrip_rstrip.rb +2 -0
- data/lib/rubocop/cop/performance/redundant_merge.rb +1 -1
- data/lib/rubocop/cop/performance/redundant_sort_by.rb +2 -0
- data/lib/rubocop/cop/performance/regexp_match.rb +4 -0
- data/lib/rubocop/cop/performance/reverse_each.rb +2 -0
- data/lib/rubocop/cop/performance/string_replacement.rb +2 -0
- data/lib/rubocop/cop/rails/active_record_aliases.rb +46 -0
- data/lib/rubocop/cop/rails/blank.rb +3 -3
- data/lib/rubocop/cop/rails/create_table_with_timestamps.rb +6 -0
- data/lib/rubocop/cop/rails/delegate.rb +6 -6
- data/lib/rubocop/cop/rails/file_path.rb +7 -1
- data/lib/rubocop/cop/rails/find_by.rb +2 -0
- data/lib/rubocop/cop/rails/http_positional_arguments.rb +17 -5
- data/lib/rubocop/cop/rails/inverse_of.rb +21 -2
- data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +45 -9
- data/lib/rubocop/cop/rails/presence.rb +8 -2
- data/lib/rubocop/cop/rails/present.rb +5 -5
- data/lib/rubocop/cop/rails/read_write_attribute.rb +4 -3
- data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +1 -0
- data/lib/rubocop/cop/rails/relative_date_constant.rb +4 -3
- data/lib/rubocop/cop/rails/request_referer.rb +3 -2
- data/lib/rubocop/cop/rails/reversible_migration.rb +9 -8
- data/lib/rubocop/cop/rails/safe_navigation.rb +3 -2
- data/lib/rubocop/cop/rails/save_bang.rb +11 -12
- data/lib/rubocop/cop/rails/skips_model_validations.rb +2 -2
- data/lib/rubocop/cop/rails/time_zone.rb +38 -16
- data/lib/rubocop/cop/rails/uniq_before_pluck.rb +26 -16
- data/lib/rubocop/cop/rails/validation.rb +30 -2
- data/lib/rubocop/cop/security/open.rb +48 -0
- data/lib/rubocop/cop/style/and_or.rb +1 -0
- data/lib/rubocop/cop/style/ascii_comments.rb +3 -1
- data/lib/rubocop/cop/style/attr.rb +2 -0
- data/lib/rubocop/cop/style/block_comments.rb +3 -1
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +2 -5
- data/lib/rubocop/cop/style/class_and_module_children.rb +1 -0
- data/lib/rubocop/cop/style/class_vars.rb +23 -0
- data/lib/rubocop/cop/style/colon_method_call.rb +1 -2
- data/lib/rubocop/cop/style/comment_annotation.rb +6 -4
- data/lib/rubocop/cop/style/commented_keyword.rb +3 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +1 -1
- data/lib/rubocop/cop/style/copyright.rb +3 -1
- data/lib/rubocop/cop/style/each_with_object.rb +15 -1
- data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -0
- data/lib/rubocop/cop/style/empty_case_condition.rb +2 -0
- data/lib/rubocop/cop/style/empty_else.rb +9 -5
- data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -0
- data/lib/rubocop/cop/style/empty_line_after_guard_clause.rb +80 -0
- data/lib/rubocop/cop/style/empty_literal.rb +1 -0
- data/lib/rubocop/cop/style/encoding.rb +2 -0
- data/lib/rubocop/cop/style/expand_path_arguments.rb +194 -0
- data/lib/rubocop/cop/style/for.rb +33 -0
- data/lib/rubocop/cop/style/format_string.rb +1 -1
- data/lib/rubocop/cop/style/format_string_token.rb +4 -5
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +2 -1
- data/lib/rubocop/cop/style/hash_syntax.rb +1 -0
- data/lib/rubocop/cop/style/if_unless_modifier.rb +1 -1
- data/lib/rubocop/cop/style/inline_comment.rb +1 -1
- data/lib/rubocop/cop/style/lambda.rb +1 -1
- data/lib/rubocop/cop/style/line_end_concatenation.rb +2 -0
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +2 -0
- data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -0
- data/lib/rubocop/cop/style/missing_else.rb +72 -7
- data/lib/rubocop/cop/style/mixin_usage.rb +3 -5
- data/lib/rubocop/cop/style/module_function.rb +10 -0
- data/lib/rubocop/cop/style/multiline_block_chain.rb +2 -0
- data/lib/rubocop/cop/style/multiline_if_then.rb +1 -0
- data/lib/rubocop/cop/style/nested_modifier.rb +2 -0
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +2 -0
- data/lib/rubocop/cop/style/next.rb +1 -0
- data/lib/rubocop/cop/style/not.rb +2 -0
- data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
- data/lib/rubocop/cop/style/one_line_conditional.rb +2 -2
- data/lib/rubocop/cop/style/redundant_exception.rb +8 -3
- data/lib/rubocop/cop/style/redundant_return.rb +37 -3
- data/lib/rubocop/cop/style/redundant_self.rb +1 -1
- data/lib/rubocop/cop/style/rescue_standard_error.rb +1 -0
- data/lib/rubocop/cop/style/safe_navigation.rb +74 -32
- data/lib/rubocop/cop/style/semicolon.rb +3 -1
- data/lib/rubocop/cop/style/single_line_methods.rb +14 -23
- data/lib/rubocop/cop/style/stderr_puts.rb +2 -0
- data/lib/rubocop/cop/style/string_hash_keys.rb +12 -0
- data/lib/rubocop/cop/style/string_literals.rb +1 -1
- data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +1 -1
- data/lib/rubocop/cop/style/symbol_array.rb +29 -0
- data/lib/rubocop/cop/style/symbol_proc.rb +2 -0
- data/lib/rubocop/cop/style/trailing_body_on_class.rb +43 -0
- data/lib/rubocop/cop/style/trailing_body_on_method_definition.rb +7 -54
- data/lib/rubocop/cop/style/trailing_body_on_module.rb +43 -0
- data/lib/rubocop/cop/style/{trailing_comma_in_literal.rb → trailing_comma_in_array_literal.rb} +2 -20
- data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +56 -0
- data/lib/rubocop/cop/style/trailing_method_end_statement.rb +17 -20
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +1 -0
- data/lib/rubocop/cop/style/unless_else.rb +2 -0
- data/lib/rubocop/cop/style/word_array.rb +0 -1
- data/lib/rubocop/cop/style/yoda_condition.rb +1 -0
- data/lib/rubocop/cop/team.rb +5 -5
- data/lib/rubocop/cop/util.rb +23 -188
- data/lib/rubocop/cop/variable_force.rb +1 -1
- data/lib/rubocop/file_finder.rb +45 -0
- data/lib/rubocop/formatter/disabled_config_formatter.rb +23 -14
- data/lib/rubocop/formatter/fuubar_style_formatter.rb +1 -1
- data/lib/rubocop/formatter/html_formatter.rb +12 -5
- data/lib/rubocop/formatter/json_formatter.rb +1 -1
- data/lib/rubocop/node_pattern.rb +8 -5
- data/lib/rubocop/options.rb +40 -33
- data/lib/rubocop/path_util.rb +5 -8
- data/lib/rubocop/processed_source.rb +53 -0
- data/lib/rubocop/remote_config.rb +1 -1
- data/lib/rubocop/result_cache.rb +1 -1
- data/lib/rubocop/rspec/cop_helper.rb +0 -4
- data/lib/rubocop/rspec/host_environment_simulation_helper.rb +0 -4
- data/lib/rubocop/rspec/shared_contexts.rb +3 -1
- data/lib/rubocop/rspec/shared_examples.rb +23 -25
- data/lib/rubocop/rspec/support.rb +5 -0
- data/lib/rubocop/runner.rb +3 -2
- data/lib/rubocop/string_util.rb +10 -9
- data/lib/rubocop/target_finder.rb +4 -1
- data/lib/rubocop/token.rb +26 -16
- data/lib/rubocop/version.rb +6 -4
- metadata +31 -17
- data/lib/rubocop/cop/performance/hash_each_methods.rb +0 -129
data/lib/rubocop/result_cache.rb
CHANGED
@@ -132,7 +132,7 @@ module RuboCop
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def file_checksum(file, config_store)
|
135
|
-
Digest::MD5.hexdigest(Dir.pwd + file + IO.
|
135
|
+
Digest::MD5.hexdigest(Dir.pwd + file + IO.binread(file) +
|
136
136
|
File.stat(file).mode.to_s +
|
137
137
|
config_store.for(file).to_s)
|
138
138
|
rescue Errno::ENOENT
|
@@ -13,7 +13,7 @@ shared_context 'isolated environment', :isolated_environment do
|
|
13
13
|
tmpdir = File.realpath(tmpdir)
|
14
14
|
|
15
15
|
# Make upwards search for .rubocop.yml files stop at this directory.
|
16
|
-
RuboCop::
|
16
|
+
RuboCop::FileFinder.root_level = tmpdir
|
17
17
|
|
18
18
|
begin
|
19
19
|
virtual_home = File.expand_path(File.join(tmpdir, 'home'))
|
@@ -28,6 +28,8 @@ shared_context 'isolated environment', :isolated_environment do
|
|
28
28
|
end
|
29
29
|
ensure
|
30
30
|
ENV['HOME'] = original_home
|
31
|
+
|
32
|
+
RuboCop::FileFinder.root_level = nil
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -32,34 +32,32 @@ shared_examples_for 'mimics MRI 2.1' do |grep_mri_warning|
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
shared_examples_for 'misaligned' do |
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
shared_examples_for 'misaligned' do |annotated_source, used_style|
|
36
|
+
config_to_allow_offenses = if used_style
|
37
|
+
{ 'EnforcedStyleAlignWith' => used_style.to_s }
|
38
|
+
else
|
39
|
+
{ 'Enabled' => false }
|
40
|
+
end
|
41
|
+
annotated_source.strip_indent.split(/\n\n/).each do |chunk|
|
42
|
+
chunk << "\n" unless chunk.end_with?("\n")
|
43
|
+
source = chunk.lines.reject { |line| line =~ /^ *\^/ }.join
|
44
|
+
name = source.gsub(/\n(?=[a-z ])/, ' <newline> ').gsub(/\s+/, ' ')
|
39
45
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
regexp = /`end` at 2, \d+ is not aligned with `#{base_regexp}` at 1,/
|
45
|
-
expect(cop.messages.first).to match(regexp)
|
46
|
-
expect(cop.highlights.first).to eq('end')
|
46
|
+
it "registers an offense for mismatched #{name}" do
|
47
|
+
expect_offense(chunk)
|
48
|
+
expect(cop.config_to_allow_offenses).to eq(config_to_allow_offenses)
|
49
|
+
end
|
47
50
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
expect(cop.config_to_allow_offenses).to(
|
52
|
-
eq('Enabled' => false).or(
|
53
|
-
satisfy { |h| other_styles.include?(h['EnforcedStyleAlignWith']) }
|
54
|
-
)
|
55
|
-
)
|
56
|
-
end
|
51
|
+
it "auto-corrects mismatched #{name}" do
|
52
|
+
raise if chunk !~
|
53
|
+
/\^\^\^ `end` at (\d), \d is not aligned with `.*` at \d, (\d)./
|
57
54
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
55
|
+
line_index = Integer(Regexp.last_match(1)) - 1
|
56
|
+
correct_indentation = ' ' * Integer(Regexp.last_match(2))
|
57
|
+
expect(autocorrect_source(source))
|
58
|
+
.to eq(source.lines[0...line_index].join +
|
59
|
+
"#{correct_indentation}#{source.lines[line_index].strip}\n")
|
60
|
+
end
|
63
61
|
end
|
64
62
|
end
|
65
63
|
|
@@ -7,3 +7,8 @@ require_relative 'host_environment_simulation_helper'
|
|
7
7
|
require_relative 'shared_contexts'
|
8
8
|
require_relative 'shared_examples'
|
9
9
|
require_relative 'expect_offense'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.include CopHelper
|
13
|
+
config.include HostEnvironmentSimulatorHelper
|
14
|
+
end
|
data/lib/rubocop/runner.rb
CHANGED
@@ -128,8 +128,9 @@ module RuboCop
|
|
128
128
|
def add_unneeded_disables(file, offenses, source)
|
129
129
|
if check_for_unneeded_disables?(source)
|
130
130
|
config = @config_store.for(file)
|
131
|
-
if config.for_cop(Cop::Lint::
|
132
|
-
|
131
|
+
if config.for_cop(Cop::Lint::UnneededCopDisableDirective)
|
132
|
+
.fetch('Enabled')
|
133
|
+
cop = Cop::Lint::UnneededCopDisableDirective.new(config, @options)
|
133
134
|
if cop.relevant_file?(file)
|
134
135
|
cop.check(offenses, source.disabled_line_ranges, source.comments)
|
135
136
|
offenses += cop.offenses
|
data/lib/rubocop/string_util.rb
CHANGED
@@ -18,13 +18,13 @@ module RuboCop
|
|
18
18
|
new(*args).distance
|
19
19
|
end
|
20
20
|
|
21
|
-
def initialize(
|
22
|
-
if
|
23
|
-
@shorter =
|
24
|
-
@longer =
|
21
|
+
def initialize(string_a, string_b)
|
22
|
+
if string_a.size < string_b.size
|
23
|
+
@shorter = string_a
|
24
|
+
@longer = string_b
|
25
25
|
else
|
26
|
-
@shorter =
|
27
|
-
@longer =
|
26
|
+
@shorter = string_b
|
27
|
+
@longer = string_a
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -95,7 +95,7 @@ module RuboCop
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def matching_window
|
98
|
-
@matching_window ||= (longer.size / 2)
|
98
|
+
@matching_window ||= (longer.size / 2) - 1
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
@@ -116,8 +116,9 @@ module RuboCop
|
|
116
116
|
|
117
117
|
attr_reader :boost_threshold, :scaling_factor
|
118
118
|
|
119
|
-
def initialize(
|
120
|
-
|
119
|
+
def initialize(string_a, string_b,
|
120
|
+
boost_threshold = nil, scaling_factor = nil)
|
121
|
+
super(string_a, string_b)
|
121
122
|
@boost_threshold = boost_threshold || DEFAULT_BOOST_THRESHOLD
|
122
123
|
@scaling_factor = scaling_factor || DEFAULT_SCALING_FACTOR
|
123
124
|
end
|
@@ -4,8 +4,11 @@ require 'set'
|
|
4
4
|
|
5
5
|
module RuboCop
|
6
6
|
RUBY_EXTENSIONS = %w[.rb
|
7
|
+
.arb
|
8
|
+
.axlsx
|
7
9
|
.builder
|
8
10
|
.fcgi
|
11
|
+
.gemfile
|
9
12
|
.gemspec
|
10
13
|
.god
|
11
14
|
.jb
|
@@ -118,7 +121,7 @@ module RuboCop
|
|
118
121
|
end
|
119
122
|
|
120
123
|
# Most recently modified file first.
|
121
|
-
target_files.sort_by! { |path| -File.mtime(path)
|
124
|
+
target_files.sort_by! { |path| Integer(-File.mtime(path)) } if fail_fast?
|
122
125
|
|
123
126
|
target_files
|
124
127
|
end
|
data/lib/rubocop/token.rb
CHANGED
@@ -19,21 +19,37 @@ module RuboCop
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def line
|
22
|
-
pos.line
|
22
|
+
@pos.line
|
23
23
|
end
|
24
24
|
|
25
25
|
def column
|
26
|
-
pos.column
|
26
|
+
@pos.column
|
27
27
|
end
|
28
28
|
|
29
29
|
def begin_pos
|
30
|
-
pos.begin_pos
|
30
|
+
@pos.begin_pos
|
31
31
|
end
|
32
32
|
|
33
33
|
def end_pos
|
34
|
-
pos.end_pos
|
34
|
+
@pos.end_pos
|
35
35
|
end
|
36
36
|
|
37
|
+
def to_s
|
38
|
+
"[[#{line}, #{column}], #{type}, #{text.inspect}]"
|
39
|
+
end
|
40
|
+
|
41
|
+
# Checks if there is whitespace after token
|
42
|
+
def space_after?
|
43
|
+
pos.source_buffer.source.match(/\G\s/, end_pos)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Checks if there is whitespace before token
|
47
|
+
def space_before?
|
48
|
+
pos.source_buffer.source.match(/\G\s/, begin_pos - 1)
|
49
|
+
end
|
50
|
+
|
51
|
+
## Type Predicates
|
52
|
+
|
37
53
|
def comment?
|
38
54
|
type == :tCOMMENT
|
39
55
|
end
|
@@ -82,22 +98,16 @@ module RuboCop
|
|
82
98
|
type == :tCOMMA
|
83
99
|
end
|
84
100
|
|
85
|
-
def
|
86
|
-
|
101
|
+
def rescue_modifier?
|
102
|
+
type == :kRESCUE_MOD
|
87
103
|
end
|
88
104
|
|
89
|
-
def
|
90
|
-
|
105
|
+
def end?
|
106
|
+
type == :kEND
|
91
107
|
end
|
92
108
|
|
93
|
-
|
94
|
-
|
95
|
-
pos.source_buffer.source.match(/\G\s/, end_pos)
|
96
|
-
end
|
97
|
-
|
98
|
-
# Checks if there is whitespace before token
|
99
|
-
def space_before?
|
100
|
-
pos.source_buffer.source.match(/\G\s/, begin_pos - 1)
|
109
|
+
def equal_sign?
|
110
|
+
%i[tEQL tOP_ASGN].include?(type)
|
101
111
|
end
|
102
112
|
end
|
103
113
|
end
|
data/lib/rubocop/version.rb
CHANGED
@@ -3,14 +3,16 @@
|
|
3
3
|
module RuboCop
|
4
4
|
# This module holds the RuboCop version information.
|
5
5
|
module Version
|
6
|
-
STRING = '0.
|
6
|
+
STRING = '0.53.0'.freeze
|
7
7
|
|
8
|
-
MSG = '
|
8
|
+
MSG = '%<version>s (using Parser %<parser_version>s, running on ' \
|
9
|
+
'%<ruby_engine>s %<ruby_version>s %<ruby_platform>s)'.freeze
|
9
10
|
|
10
11
|
def self.version(debug = false)
|
11
12
|
if debug
|
12
|
-
format(MSG, STRING, Parser::VERSION,
|
13
|
-
|
13
|
+
format(MSG, version: STRING, parser_version: Parser::VERSION,
|
14
|
+
ruby_engine: RUBY_ENGINE, ruby_version: RUBY_VERSION,
|
15
|
+
ruby_platform: RUBY_PLATFORM)
|
14
16
|
else
|
15
17
|
STRING
|
16
18
|
end
|
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.53.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2018-03-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parallel
|
@@ -32,20 +32,14 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 2.
|
36
|
-
- - "<"
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: '3.0'
|
35
|
+
version: '2.5'
|
39
36
|
type: :runtime
|
40
37
|
prerelease: false
|
41
38
|
version_requirements: !ruby/object:Gem::Requirement
|
42
39
|
requirements:
|
43
40
|
- - ">="
|
44
41
|
- !ruby/object:Gem::Version
|
45
|
-
version: 2.
|
46
|
-
- - "<"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '3.0'
|
42
|
+
version: '2.5'
|
49
43
|
- !ruby/object:Gem::Dependency
|
50
44
|
name: powerpack
|
51
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -203,6 +197,7 @@ files:
|
|
203
197
|
- lib/rubocop/cop/correctors/alignment_corrector.rb
|
204
198
|
- lib/rubocop/cop/correctors/condition_corrector.rb
|
205
199
|
- lib/rubocop/cop/correctors/empty_line_corrector.rb
|
200
|
+
- lib/rubocop/cop/correctors/line_break_corrector.rb
|
206
201
|
- lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb
|
207
202
|
- lib/rubocop/cop/correctors/ordered_gem_corrector.rb
|
208
203
|
- lib/rubocop/cop/correctors/parentheses_corrector.rb
|
@@ -228,13 +223,17 @@ files:
|
|
228
223
|
- lib/rubocop/cop/layout/align_array.rb
|
229
224
|
- lib/rubocop/cop/layout/align_hash.rb
|
230
225
|
- lib/rubocop/cop/layout/align_parameters.rb
|
226
|
+
- lib/rubocop/cop/layout/block_alignment.rb
|
231
227
|
- lib/rubocop/cop/layout/block_end_newline.rb
|
232
228
|
- lib/rubocop/cop/layout/case_indentation.rb
|
233
229
|
- lib/rubocop/cop/layout/class_structure.rb
|
234
230
|
- lib/rubocop/cop/layout/closing_parenthesis_indentation.rb
|
235
231
|
- lib/rubocop/cop/layout/comment_indentation.rb
|
232
|
+
- lib/rubocop/cop/layout/condition_position.rb
|
233
|
+
- lib/rubocop/cop/layout/def_end_alignment.rb
|
236
234
|
- lib/rubocop/cop/layout/dot_position.rb
|
237
235
|
- lib/rubocop/cop/layout/else_alignment.rb
|
236
|
+
- lib/rubocop/cop/layout/empty_comment.rb
|
238
237
|
- lib/rubocop/cop/layout/empty_line_after_magic_comment.rb
|
239
238
|
- lib/rubocop/cop/layout/empty_line_between_defs.rb
|
240
239
|
- lib/rubocop/cop/layout/empty_lines.rb
|
@@ -246,6 +245,7 @@ files:
|
|
246
245
|
- lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb
|
247
246
|
- lib/rubocop/cop/layout/empty_lines_around_method_body.rb
|
248
247
|
- lib/rubocop/cop/layout/empty_lines_around_module_body.rb
|
248
|
+
- lib/rubocop/cop/layout/end_alignment.rb
|
249
249
|
- lib/rubocop/cop/layout/end_of_line.rb
|
250
250
|
- lib/rubocop/cop/layout/extra_spacing.rb
|
251
251
|
- lib/rubocop/cop/layout/first_array_element_line_break.rb
|
@@ -301,12 +301,10 @@ files:
|
|
301
301
|
- lib/rubocop/cop/lint/ambiguous_operator.rb
|
302
302
|
- lib/rubocop/cop/lint/ambiguous_regexp_literal.rb
|
303
303
|
- lib/rubocop/cop/lint/assignment_in_condition.rb
|
304
|
-
- lib/rubocop/cop/lint/
|
304
|
+
- lib/rubocop/cop/lint/big_decimal_new.rb
|
305
305
|
- lib/rubocop/cop/lint/boolean_symbol.rb
|
306
306
|
- lib/rubocop/cop/lint/circular_argument_reference.rb
|
307
|
-
- lib/rubocop/cop/lint/condition_position.rb
|
308
307
|
- lib/rubocop/cop/lint/debugger.rb
|
309
|
-
- lib/rubocop/cop/lint/def_end_alignment.rb
|
310
308
|
- lib/rubocop/cop/lint/deprecated_class_methods.rb
|
311
309
|
- lib/rubocop/cop/lint/duplicate_case_condition.rb
|
312
310
|
- lib/rubocop/cop/lint/duplicate_methods.rb
|
@@ -317,7 +315,6 @@ files:
|
|
317
315
|
- lib/rubocop/cop/lint/empty_expression.rb
|
318
316
|
- lib/rubocop/cop/lint/empty_interpolation.rb
|
319
317
|
- lib/rubocop/cop/lint/empty_when.rb
|
320
|
-
- lib/rubocop/cop/lint/end_alignment.rb
|
321
318
|
- lib/rubocop/cop/lint/end_in_method.rb
|
322
319
|
- lib/rubocop/cop/lint/ensure_return.rb
|
323
320
|
- lib/rubocop/cop/lint/float_out_of_range.rb
|
@@ -336,6 +333,8 @@ files:
|
|
336
333
|
- lib/rubocop/cop/lint/nested_percent_literal.rb
|
337
334
|
- lib/rubocop/cop/lint/next_without_accumulator.rb
|
338
335
|
- lib/rubocop/cop/lint/non_local_exit_from_iterator.rb
|
336
|
+
- lib/rubocop/cop/lint/number_conversion.rb
|
337
|
+
- lib/rubocop/cop/lint/ordered_magic_comments.rb
|
339
338
|
- lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb
|
340
339
|
- lib/rubocop/cop/lint/percent_string_array.rb
|
341
340
|
- lib/rubocop/cop/lint/percent_symbol_array.rb
|
@@ -356,7 +355,8 @@ files:
|
|
356
355
|
- lib/rubocop/cop/lint/syntax.rb
|
357
356
|
- lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb
|
358
357
|
- lib/rubocop/cop/lint/unified_integer.rb
|
359
|
-
- lib/rubocop/cop/lint/
|
358
|
+
- lib/rubocop/cop/lint/unneeded_cop_disable_directive.rb
|
359
|
+
- lib/rubocop/cop/lint/unneeded_cop_enable_directive.rb
|
360
360
|
- lib/rubocop/cop/lint/unneeded_require_statement.rb
|
361
361
|
- lib/rubocop/cop/lint/unneeded_splat_expansion.rb
|
362
362
|
- lib/rubocop/cop/lint/unreachable_code.rb
|
@@ -414,6 +414,7 @@ files:
|
|
414
414
|
- lib/rubocop/cop/mixin/multiline_expression_indentation.rb
|
415
415
|
- lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb
|
416
416
|
- lib/rubocop/cop/mixin/negative_conditional.rb
|
417
|
+
- lib/rubocop/cop/mixin/nil_methods.rb
|
417
418
|
- lib/rubocop/cop/mixin/on_normal_if_unless.rb
|
418
419
|
- lib/rubocop/cop/mixin/ordered_gem_node.rb
|
419
420
|
- lib/rubocop/cop/mixin/parentheses.rb
|
@@ -421,6 +422,7 @@ files:
|
|
421
422
|
- lib/rubocop/cop/mixin/percent_array.rb
|
422
423
|
- lib/rubocop/cop/mixin/percent_literal.rb
|
423
424
|
- lib/rubocop/cop/mixin/preceding_following_alignment.rb
|
425
|
+
- lib/rubocop/cop/mixin/range_help.rb
|
424
426
|
- lib/rubocop/cop/mixin/rescue_node.rb
|
425
427
|
- lib/rubocop/cop/mixin/safe_assignment.rb
|
426
428
|
- lib/rubocop/cop/mixin/safe_mode.rb
|
@@ -433,7 +435,9 @@ files:
|
|
433
435
|
- lib/rubocop/cop/mixin/target_rails_version.rb
|
434
436
|
- lib/rubocop/cop/mixin/target_ruby_version.rb
|
435
437
|
- lib/rubocop/cop/mixin/too_many_lines.rb
|
438
|
+
- lib/rubocop/cop/mixin/trailing_body.rb
|
436
439
|
- lib/rubocop/cop/mixin/trailing_comma.rb
|
440
|
+
- lib/rubocop/cop/mixin/uncommunicative_name.rb
|
437
441
|
- lib/rubocop/cop/mixin/unused_argument.rb
|
438
442
|
- lib/rubocop/cop/naming/accessor_method_name.rb
|
439
443
|
- lib/rubocop/cop/naming/ascii_identifiers.rb
|
@@ -443,8 +447,11 @@ files:
|
|
443
447
|
- lib/rubocop/cop/naming/file_name.rb
|
444
448
|
- lib/rubocop/cop/naming/heredoc_delimiter_case.rb
|
445
449
|
- lib/rubocop/cop/naming/heredoc_delimiter_naming.rb
|
450
|
+
- lib/rubocop/cop/naming/memoized_instance_variable_name.rb
|
446
451
|
- lib/rubocop/cop/naming/method_name.rb
|
447
452
|
- lib/rubocop/cop/naming/predicate_name.rb
|
453
|
+
- lib/rubocop/cop/naming/uncommunicative_block_param_name.rb
|
454
|
+
- lib/rubocop/cop/naming/uncommunicative_method_param_name.rb
|
448
455
|
- lib/rubocop/cop/naming/variable_name.rb
|
449
456
|
- lib/rubocop/cop/naming/variable_number.rb
|
450
457
|
- lib/rubocop/cop/offense.rb
|
@@ -458,7 +465,6 @@ files:
|
|
458
465
|
- lib/rubocop/cop/performance/end_with.rb
|
459
466
|
- lib/rubocop/cop/performance/fixed_size.rb
|
460
467
|
- lib/rubocop/cop/performance/flat_map.rb
|
461
|
-
- lib/rubocop/cop/performance/hash_each_methods.rb
|
462
468
|
- lib/rubocop/cop/performance/lstrip_rstrip.rb
|
463
469
|
- lib/rubocop/cop/performance/range_include.rb
|
464
470
|
- lib/rubocop/cop/performance/redundant_block_call.rb
|
@@ -475,6 +481,7 @@ files:
|
|
475
481
|
- lib/rubocop/cop/performance/unfreeze_string.rb
|
476
482
|
- lib/rubocop/cop/performance/uri_default_parser.rb
|
477
483
|
- lib/rubocop/cop/rails/action_filter.rb
|
484
|
+
- lib/rubocop/cop/rails/active_record_aliases.rb
|
478
485
|
- lib/rubocop/cop/rails/active_support_aliases.rb
|
479
486
|
- lib/rubocop/cop/rails/application_job.rb
|
480
487
|
- lib/rubocop/cop/rails/application_record.rb
|
@@ -518,6 +525,7 @@ files:
|
|
518
525
|
- lib/rubocop/cop/security/eval.rb
|
519
526
|
- lib/rubocop/cop/security/json_load.rb
|
520
527
|
- lib/rubocop/cop/security/marshal_load.rb
|
528
|
+
- lib/rubocop/cop/security/open.rb
|
521
529
|
- lib/rubocop/cop/security/yaml_load.rb
|
522
530
|
- lib/rubocop/cop/severity.rb
|
523
531
|
- lib/rubocop/cop/style/alias.rb
|
@@ -557,12 +565,14 @@ files:
|
|
557
565
|
- lib/rubocop/cop/style/empty_case_condition.rb
|
558
566
|
- lib/rubocop/cop/style/empty_else.rb
|
559
567
|
- lib/rubocop/cop/style/empty_lambda_parameter.rb
|
568
|
+
- lib/rubocop/cop/style/empty_line_after_guard_clause.rb
|
560
569
|
- lib/rubocop/cop/style/empty_literal.rb
|
561
570
|
- lib/rubocop/cop/style/empty_method.rb
|
562
571
|
- lib/rubocop/cop/style/encoding.rb
|
563
572
|
- lib/rubocop/cop/style/end_block.rb
|
564
573
|
- lib/rubocop/cop/style/eval_with_location.rb
|
565
574
|
- lib/rubocop/cop/style/even_odd.rb
|
575
|
+
- lib/rubocop/cop/style/expand_path_arguments.rb
|
566
576
|
- lib/rubocop/cop/style/flip_flop.rb
|
567
577
|
- lib/rubocop/cop/style/for.rb
|
568
578
|
- lib/rubocop/cop/style/format_string.rb
|
@@ -655,9 +665,12 @@ files:
|
|
655
665
|
- lib/rubocop/cop/style/symbol_literal.rb
|
656
666
|
- lib/rubocop/cop/style/symbol_proc.rb
|
657
667
|
- lib/rubocop/cop/style/ternary_parentheses.rb
|
668
|
+
- lib/rubocop/cop/style/trailing_body_on_class.rb
|
658
669
|
- lib/rubocop/cop/style/trailing_body_on_method_definition.rb
|
670
|
+
- lib/rubocop/cop/style/trailing_body_on_module.rb
|
659
671
|
- lib/rubocop/cop/style/trailing_comma_in_arguments.rb
|
660
|
-
- lib/rubocop/cop/style/
|
672
|
+
- lib/rubocop/cop/style/trailing_comma_in_array_literal.rb
|
673
|
+
- lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
|
661
674
|
- lib/rubocop/cop/style/trailing_method_end_statement.rb
|
662
675
|
- lib/rubocop/cop/style/trailing_underscore_variable.rb
|
663
676
|
- lib/rubocop/cop/style/trivial_accessors.rb
|
@@ -683,6 +696,7 @@ files:
|
|
683
696
|
- lib/rubocop/cop/variable_force/variable.rb
|
684
697
|
- lib/rubocop/cop/variable_force/variable_table.rb
|
685
698
|
- lib/rubocop/error.rb
|
699
|
+
- lib/rubocop/file_finder.rb
|
686
700
|
- lib/rubocop/formatter/base_formatter.rb
|
687
701
|
- lib/rubocop/formatter/clang_style_formatter.rb
|
688
702
|
- lib/rubocop/formatter/colorizable.rb
|