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

Layout/DotPosition with EnforcedStyle: trailing false positive #10184

Closed
LelandAM opened this issue Oct 13, 2021 · 7 comments
Closed

Layout/DotPosition with EnforcedStyle: trailing false positive #10184

LelandAM opened this issue Oct 13, 2021 · 7 comments

Comments

@LelandAM
Copy link

This commit that updated support of heredocs does not support our usage of them.

We call a method with a heredoc as an argument and call methods on the result.

For example, prior to this commit this code did not register an offense but after it does.

method_call(
  <<~HEREDOC
    something
  HEREDOC
).method_name

This also has changed behavior for multi-line method calls with non-heredoc arguments

method_call(
  'foo'
).method_name

Expected behavior

When the below spec is added to the "Trailing dots style" context in dot_position_spec.rb we would expect it to pass.

it 'does not register an offense with method calls after the heredoc argument' do
      expect_no_offenses(<<~RUBY)
        something(
          <<~HERE
            something
          HERE
        ).method_name
      RUBY
    end

Actual behavior

The spec fails

Steps to reproduce the problem

Run rubocop on a file containing either of these snippets

method_call(
  <<~HEREDOC
    something
  HEREDOC
).method_name

or

method_call(
  'foo'
).method_name

RuboCop version

$ [bundle exec] rubocop -V
1.22.1 (using Parser 3.0.2.0, rubocop-ast 1.12.0, running on ruby 2.7.2 x86_64-darwin20)
  - rubocop-performance 1.11.5
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.5.0
@dvandersluis
Copy link
Member

This might be fixed by #10168, can you try getting the HEAD of rubocop and running it?

@LelandAM
Copy link
Author

LelandAM commented Oct 13, 2021

Thanks for getting back! I saw that, tried testing on HEAD and still had the problem.

@pfeffer
Copy link

pfeffer commented Oct 22, 2021

We're seeing the same issue - throwing Layout/DotPosition warning on things like:

var = {
   key: 'some', 
   key1: 'other'
}.compact

@dvandersluis
Copy link
Member

#10207 was merged today, all the examples in this issue are fixed now!

mshibuya added a commit to railsadminteam/rails_admin that referenced this issue Oct 23, 2021
@dvandersluis dvandersluis changed the title Layout/DotPosition false positive when style is trailing Layout/DotPosition false positive with EnforcedStyle: trailing Oct 26, 2021
@dvandersluis dvandersluis pinned this issue Oct 26, 2021
@dvandersluis dvandersluis changed the title Layout/DotPosition false positive with EnforcedStyle: trailing Layout/DotPosition with EnforcedStyle: trailing false positive Oct 26, 2021
@hajee
Copy link

hajee commented Oct 27, 2021

Is a release containing this fix planned for shortly? I'd love to use the update instead of changing all Gemfiles.

@koic
Copy link
Member

koic commented Oct 27, 2021

Yeah, the next bugfix release is planned. Please wait a moment. Thank you.

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 27, 2021

I just released 1.22.3.

@koic koic unpinned this issue Oct 27, 2021
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

No branches or pull requests

6 participants