Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #7592] Line end concatenation indentation cop #9883

Merged
merged 3 commits into from Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/fix_manually_fix_the_remaining_offense_after.md
@@ -0,0 +1 @@
* [#7592](https://github.com/rubocop/rubocop/pull/7592): Add cop `Layout/LineEndStringConcatenationIndentation`. ([@jonas054][])
68 changes: 41 additions & 27 deletions config/default.yml
Expand Up @@ -270,8 +270,8 @@ Layout/AccessModifierIndentation:
SupportedStyles:
- outdent
- indent
# By default, the indentation width from Layout/IndentationWidth is used
# But it can be overridden by setting this parameter
# By default the indentation width from `Layout/IndentationWidth` is used,
# but it can be overridden by setting this parameter.
IndentationWidth: ~

Layout/ArgumentAlignment:
Expand Down Expand Up @@ -299,8 +299,8 @@ Layout/ArgumentAlignment:
SupportedStyles:
- with_first_argument
- with_fixed_indentation
# By default, the indentation width from Layout/IndentationWidth is used
# But it can be overridden by setting this parameter
# By default the indentation width from `Layout/IndentationWidth` is used,
# but it can be overridden by setting this parameter.
IndentationWidth: ~

Layout/ArrayAlignment:
Expand Down Expand Up @@ -328,8 +328,8 @@ Layout/ArrayAlignment:
SupportedStyles:
- with_first_element
- with_fixed_indentation
# By default, the indentation width from Layout/IndentationWidth is used
# But it can be overridden by setting this parameter
# By default the indentation width from `Layout/IndentationWidth` is used,
# but it can be overridden by setting this parameter.
IndentationWidth: ~

Layout/AssignmentIndentation:
Expand All @@ -339,8 +339,8 @@ Layout/AssignmentIndentation:
Enabled: true
VersionAdded: '0.49'
VersionChanged: '0.77'
# By default, the indentation width from `Layout/IndentationWidth` is used
# But it can be overridden by setting this parameter
# By default the indentation width from `Layout/IndentationWidth` is used,
# but it can be overridden by setting this parameter.
IndentationWidth: ~

Layout/BeginEndAlignment:
Expand Down Expand Up @@ -387,9 +387,9 @@ Layout/CaseIndentation:
- case
- end
IndentOneStep: false
# By default, the indentation width from `Layout/IndentationWidth` is used.
# But it can be overridden by setting this parameter.
# This only matters if `IndentOneStep` is `true`
# By default the indentation width from `Layout/IndentationWidth` is used,
# but it can be overridden by setting this parameter.
# This only matters if `IndentOneStep` is `true`.
IndentationWidth: ~

Layout/ClassStructure:
Expand Down Expand Up @@ -666,8 +666,8 @@ Layout/FirstArgumentIndentation:
# Same as `special_for_inner_method_call` except that the special rule only
# applies if the outer method call encloses its arguments in parentheses.
- special_for_inner_method_call_in_parentheses
# By default, the indentation width from `Layout/IndentationWidth` is used
# But it can be overridden by setting this parameter
# By default the indentation width from `Layout/IndentationWidth` is used,
# but it can be overridden by setting this parameter.
IndentationWidth: ~

Layout/FirstArrayElementIndentation:
Expand All @@ -693,8 +693,8 @@ Layout/FirstArrayElementIndentation:
- special_inside_parentheses
- consistent
- align_brackets
# By default, the indentation width from `Layout/IndentationWidth` is used
# But it can be overridden by setting this parameter
# By default the indentation width from `Layout/IndentationWidth` is used,
# but it can be overridden by setting this parameter.
IndentationWidth: ~

Layout/FirstArrayElementLineBreak:
Expand Down Expand Up @@ -725,8 +725,8 @@ Layout/FirstHashElementIndentation:
- special_inside_parentheses
- consistent
- align_braces
# By default, the indentation width from `Layout/IndentationWidth` is used
# But it can be overridden by setting this parameter
# By default the indentation width from `Layout/IndentationWidth` is used,
# but it can be overridden by setting this parameter.
IndentationWidth: ~

Layout/FirstHashElementLineBreak:
Expand Down Expand Up @@ -761,8 +761,8 @@ Layout/FirstParameterIndentation:
SupportedStyles:
- consistent
- align_parentheses
# By default, the indentation width from `Layout/IndentationWidth` is used
# But it can be overridden by setting this parameter
# By default the indentation width from `Layout/IndentationWidth` is used,
# but it can be overridden by setting this parameter.
IndentationWidth: ~

Layout/HashAlignment:
Expand Down Expand Up @@ -883,8 +883,8 @@ Layout/IndentationStyle:
Enabled: true
VersionAdded: '0.49'
VersionChanged: '0.82'
# By default, the indentation width from Layout/IndentationWidth is used
# But it can be overridden by setting this parameter
# By default the indentation width from `Layout/IndentationWidth` is used,
# but it can be overridden by setting this parameter.
# It is used during auto-correction to determine how many spaces should
# replace each tab.
IndentationWidth: ~
Expand Down Expand Up @@ -923,6 +923,20 @@ Layout/LeadingEmptyLines:
VersionAdded: '0.57'
VersionChanged: '0.77'

Layout/LineEndStringConcatenationIndentation:
Description: >-
Checks the indentation of the next line after a line that
ends with a string literal and a backslash.
Enabled: pending
VersionAdded: '<<next>>'
EnforcedStyle: aligned
SupportedStyles:
- aligned
- indented
# By default the indentation width from `Layout/IndentationWidth` is used,
# but it can be overridden by setting this parameter.
IndentationWidth: ~

Layout/LineLength:
Description: 'Checks that line length does not exceed the configured limit.'
StyleGuide: '#max-line-length'
Expand Down Expand Up @@ -1053,8 +1067,8 @@ Layout/MultilineMethodCallIndentation:
- aligned
- indented
- indented_relative_to_receiver
# By default, the indentation width from Layout/IndentationWidth is used
# But it can be overridden by setting this parameter
# By default the indentation width from `Layout/IndentationWidth` is used,
# but it can be overridden by setting this parameter.
IndentationWidth: ~

Layout/MultilineMethodDefinitionBraceLayout:
Expand Down Expand Up @@ -1083,8 +1097,8 @@ Layout/MultilineOperationIndentation:
SupportedStyles:
- aligned
- indented
# By default, the indentation width from `Layout/IndentationWidth` is used
# But it can be overridden by setting this parameter
# By default the indentation width from `Layout/IndentationWidth` is used,
# but it can be overridden by setting this parameter.
IndentationWidth: ~

Layout/ParameterAlignment:
Expand Down Expand Up @@ -1112,8 +1126,8 @@ Layout/ParameterAlignment:
SupportedStyles:
- with_first_parameter
- with_fixed_indentation
# By default, the indentation width from Layout/IndentationWidth is used
# But it can be overridden by setting this parameter
# By default the indentation width from `Layout/IndentationWidth` is used,
# but it can be overridden by setting this parameter.
IndentationWidth: ~

Layout/RedundantLineBreak:
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop.rb
Expand Up @@ -211,6 +211,7 @@
require_relative 'rubocop/cop/layout/initial_indentation'
require_relative 'rubocop/cop/layout/leading_comment_space'
require_relative 'rubocop/cop/layout/leading_empty_lines'
require_relative 'rubocop/cop/layout/line_end_string_concatenation_indentation'
require_relative 'rubocop/cop/layout/line_length'
require_relative 'rubocop/cop/layout/multiline_array_brace_layout'
require_relative 'rubocop/cop/layout/multiline_array_line_breaks'
Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/cli/command/suggest_extensions.rb
Expand Up @@ -19,16 +19,16 @@ def run

puts
puts 'Tip: Based on detected gems, the following '\
'RuboCop extension libraries might be helpful:'
'RuboCop extension libraries might be helpful:'

extensions.sort.each do |extension|
puts " * #{extension} (https://github.com/rubocop/#{extension})"
end

puts
puts 'You can opt out of this message by adding the following to your config '\
'(see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions '\
'for more options):'
'(see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions '\
'for more options):'
puts ' AllCops:'
puts ' SuggestExtensions: false'

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/config_loader.rb
Expand Up @@ -229,7 +229,7 @@ def check_duplication(yaml_code, absolute_path)
line1 = key1.start_line + 1
line2 = key2.start_line + 1
"#{smart_path}:#{line1}: " \
"`#{value}` is concealed by line #{line2}"
"`#{value}` is concealed by line #{line2}"
else
"#{smart_path}: `#{value}` is concealed by duplicate"
end
Expand Down
10 changes: 5 additions & 5 deletions lib/rubocop/config_validator.rb
Expand Up @@ -81,11 +81,11 @@ def check_target_ruby

msg = if last_version
"RuboCop found unsupported Ruby version #{target_ruby_version} " \
"in #{source}. #{target_ruby_version}-compatible " \
"analysis was dropped after version #{last_version}."
"in #{source}. #{target_ruby_version}-compatible " \
"analysis was dropped after version #{last_version}."
else
'RuboCop found unknown Ruby version ' \
"#{target_ruby_version.inspect} in #{source}."
"#{target_ruby_version.inspect} in #{source}."
end

msg += "\nSupported versions: #{TargetRuby.supported_versions.join(', ')}"
Expand Down Expand Up @@ -179,8 +179,8 @@ def validate_enforced_styles(valid_cop_names) # rubocop:todo Metrics/AbcSize
next if validate_support_and_has_list(name, style, valid)

msg = "invalid #{style_name} '#{style}' for #{name} found in " \
"#{smart_loaded_path}\n" \
"Valid choices are: #{valid.join(', ')}"
"#{smart_loaded_path}\n" \
"Valid choices are: #{valid.join(', ')}"
raise ValidationError, msg
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/base.rb
Expand Up @@ -261,7 +261,7 @@ def ready
# @deprecated Make potential errors with previous API more obvious
def offenses
raise 'The offenses are not directly available; ' \
'they are returned as the result of the investigation'
'they are returned as the result of the investigation'
end

### Reserved for Commissioner
Expand Down Expand Up @@ -441,7 +441,7 @@ def custom_severity
severity.to_sym
else
message = "Warning: Invalid severity '#{severity}'. " \
"Valid severities are #{Severity::NAMES.join(', ')}."
"Valid severities are #{Severity::NAMES.join(', ')}."
warn(Rainbow(message).red)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/bundler/duplicated_gem.rb
Expand Up @@ -39,7 +39,7 @@ class DuplicatedGem < Base
include RangeHelp

MSG = 'Gem `%<gem_name>s` requirements already given on line '\
'%<line_of_first_occurrence>d of the Gemfile.'
'%<line_of_first_occurrence>d of the Gemfile.'

def on_new_investigation
return if processed_source.blank?
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/generator.rb
Expand Up @@ -104,7 +104,7 @@ def on_send(node)

CONFIGURATION_ADDED_MESSAGE =
'[modify] A configuration for the cop is added into ' \
'%<configuration_file_path>s.'
'%<configuration_file_path>s.'

def initialize(name, github_user, output: $stdout)
@badge = Badge.parse(name)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/internal_affairs/node_matcher_directive.rb
Expand Up @@ -25,7 +25,7 @@ class NodeMatcherDirective < Base

MSG = 'Preceed `%<method>s` with a `@!method` YARD directive.'
MSG_WRONG_NAME = '`@!method` YARD directive has invalid method name, ' \
'use `%<expected>s` instead of `%<actual>s`.'
'use `%<expected>s` instead of `%<actual>s`.'
MSG_TOO_MANY = 'Multiple `@!method` YARD directives found for this matcher.'

RESTRICT_ON_SEND = %i[def_node_matcher def_node_search].to_set.freeze
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/layout/argument_alignment.rb
Expand Up @@ -50,7 +50,7 @@ class ArgumentAlignment < Base
ALIGN_PARAMS_MSG = 'Align the arguments of a method call if they span more than one line.'

FIXED_INDENT_MSG = 'Use one level of indentation for arguments ' \
'following the first line of a multi-line method call.'
'following the first line of a multi-line method call.'

def on_send(node)
first_arg = node.first_argument
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/layout/array_alignment.rb
Expand Up @@ -38,10 +38,10 @@ class ArrayAlignment < Base
extend AutoCorrector

ALIGN_ELEMENTS_MSG = 'Align the elements of an array literal ' \
'if they span more than one line.'
'if they span more than one line.'

FIXED_INDENT_MSG = 'Use one level of indentation for elements ' \
'following the first line of a multi-line array.'
'following the first line of a multi-line array.'

def on_array(node)
return if node.children.size < 2
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/layout/block_alignment.rb
Expand Up @@ -210,7 +210,7 @@ def alt_start_msg(start_loc, source_line_column)

def format_source_line_column(source_line_column)
"`#{source_line_column[:source]}` at #{source_line_column[:line]}, " \
"#{source_line_column[:column]}"
"#{source_line_column[:column]}"
end

def compute_start_col(ancestor_node, node)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/layout/comment_indentation.rb
Expand Up @@ -37,7 +37,7 @@ class CommentIndentation < Base
extend AutoCorrector

MSG = 'Incorrect indentation detected (column %<column>d ' \
'instead of %<correct_comment_indentation>d).'
'instead of %<correct_comment_indentation>d).'

def on_new_investigation
processed_source.comments.each { |comment| check(comment) }
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/layout/first_array_element_indentation.rb
Expand Up @@ -161,10 +161,10 @@ def msg(left_parenthesis)
'Indent the right bracket the same as the left bracket.'
elsif style == :special_inside_parentheses && left_parenthesis
'Indent the right bracket the same as the first position ' \
'after the preceding left parenthesis.'
'after the preceding left parenthesis.'
else
'Indent the right bracket the same as the start of the line' \
' where the left bracket is.'
' where the left bracket is.'
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/layout/first_hash_element_indentation.rb
Expand Up @@ -178,10 +178,10 @@ def message_for_right_brace(left_parenthesis)
'Indent the right brace the same as the left brace.'
elsif style == :special_inside_parentheses && left_parenthesis
'Indent the right brace the same as the first position ' \
'after the preceding left parenthesis.'
'after the preceding left parenthesis.'
else
'Indent the right brace the same as the start of the line ' \
'where the left brace is.'
'where the left brace is.'
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/layout/first_parameter_indentation.rb
Expand Up @@ -48,7 +48,7 @@ class FirstParameterIndentation < Base
extend AutoCorrector

MSG = 'Use %<configured_indentation_width>d spaces for indentation ' \
'in method args, relative to %<base_description>s.'
'in method args, relative to %<base_description>s.'

def on_def(node)
return if node.arguments.empty?
Expand Down
17 changes: 9 additions & 8 deletions lib/rubocop/cop/layout/hash_alignment.rb
Expand Up @@ -180,14 +180,15 @@ class HashAlignment < Base
include RangeHelp
extend AutoCorrector

MESSAGES = { KeyAlignment => 'Align the keys of a hash literal if ' \
'they span more than one line.',
SeparatorAlignment => 'Align the separators of a hash ' \
'literal if they span more than one line.',
TableAlignment => 'Align the keys and values of a hash ' \
'literal if they span more than one line.',
KeywordSplatAlignment => 'Align keyword splats with the ' \
'rest of the hash if it spans more than one line.' }.freeze
MESSAGES = {
KeyAlignment => 'Align the keys of a hash literal if they span more than one line.',
SeparatorAlignment => 'Align the separators of a hash literal if they span more than ' \
'one line.',
TableAlignment => 'Align the keys and values of a hash literal if they span more than ' \
'one line.',
KeywordSplatAlignment => 'Align keyword splats with the rest of the hash if it spans ' \
'more than one line.'
}.freeze

def on_send(node)
return if double_splat?(node)
Expand Down
Expand Up @@ -55,7 +55,7 @@ class HeredocArgumentClosingParenthesis < Base
extend AutoCorrector

MSG = 'Put the closing parenthesis for a method call with a ' \
'HEREDOC parameter on the same line as the HEREDOC opening.'
'HEREDOC parameter on the same line as the HEREDOC opening.'

def self.autocorrect_incompatible_with
[Style::TrailingCommaInArguments]
Expand Down