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 #12138] Fix a false positive for Layout/LineContinuationLeadingSpace #12139

Conversation

ymap
Copy link
Contributor

@ymap ymap commented Aug 21, 2023

Fixes #12138.

This PR fixes a false positive for Layout/LineContinuationLeadingSpace when a backslash is part of a multiline string literal.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@ymap ymap marked this pull request as ready for review August 21, 2023 15:49
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you refactor to the below?

lines = raw_lines(node)
lines.each_cons(2).with_index(node.first_line) do |(raw_line_one, raw_line_two), line_num|
  end_of_first_line += raw_line_one.length

  next unless continuation?(raw_line_one, line_num, node)

  investigate(raw_line_one, raw_line_two, end_of_first_line)
end

@@ -0,0 +1 @@
* [#12138](https://github.com/rubocop/rubocop/issues/12138): Fix false positives for `Layout/LineContinuationLeadingSpace`. ([@ymap][])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a little more false positive information?

…LeadingSpace`

Fixes rubocop#12138.

This PR fixes a false positive for `Layout/LineContinuationLeadingSpace`
when a backslash is part of a multiline string literal.
@ymap ymap force-pushed the fix_a_false_positive_for_layout_line_continuation_leading_space branch from d7b1c39 to 5b47705 Compare August 23, 2023 12:55
@ymap
Copy link
Contributor Author

ymap commented Aug 23, 2023

@koic Thanks for the review! I've amended the commit.

@koic koic merged commit 342bbbe into rubocop:master Aug 24, 2023
28 checks passed
@koic
Copy link
Member

koic commented Aug 24, 2023

Thanks!

@ymap ymap deleted the fix_a_false_positive_for_layout_line_continuation_leading_space branch August 24, 2023 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Layout/LineContinuationLeadingSpace false positive
2 participants