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

False positive of Style/IfUnlessModifier with tabs indentation #7885

Closed
AlexWayfer opened this issue Apr 17, 2020 · 2 comments
Closed

False positive of Style/IfUnlessModifier with tabs indentation #7885

AlexWayfer opened this issue Apr 17, 2020 · 2 comments

Comments

@AlexWayfer
Copy link
Contributor

Hello.

I'm trying to update RuboCop to version 0.82.0 for Flame.

I'm using tabs in this project.

And there is a condition which does not fit in one line.

Probably related to #5785


Expected behavior

No offenses.

Actual behavior

Offense from Style/IfUnlessModifier.

Steps to reproduce the problem

					if !@controller.actions.include?(action) || find_reverse_route(action)
						next
					end

image

RuboCop version

0.82.0 (using Parser 2.7.1.1, running on ruby 2.7.1 x86_64-linux)

/cc @DracoAter

@rrosenblum
Copy link
Contributor

@AlexWayfer can you please provide some extra information on this.

And there is a condition which does not fit in one line.

Why does this not fit on one line? Does the correction exceed your configured max line length? I'm not sure how this is related to tab indentation.

@AlexWayfer
Copy link
Contributor Author

Why does this not fit on one line? Does the correction exceed your configured max line length?

Because the text is larger than max length of line. I don't know how to answer.

Look at the right red arrow, it's wrap guide, 80 chars.

You can copy pasted text and calculate a size.

I'm not sure how this is related to tab indentation.

Did you see a note about #5785 in the issue description?

Tab is single character, but its size is configurable, and size of tab is not equal size of indentation.

For example: Layout/IndentationWidth: Width: 1 means "1 tab/space for indentation", and Layout/IndentationStyle: IndentationWidth: 2 means "tab's size is 2 chars (spaces)".

jonas054 added a commit to jonas054/rubocop that referenced this issue May 1, 2020
When calculating how wide the indentation is, we must look at the
`EnforcedStyle` of the `Layout/IndentationStyle` cop. If it's `spaces`, then
the indentation multiplier is 1. If it's `tabs` it's a bit more complicated,
but that part was already handled correctly.

The specs needed to be updated with correct configuration for all cases with
`tabs` indentation.

Whether or not we should consider the `Enabled` parameter is debatable. I've
chosen to not care about `Enabled`, and to use the other parameter settings in
any case.
jonas054 added a commit that referenced this issue May 7, 2020
…_indentation

[Fix #7885] Re-use LineLengthHelp for statement modifiers
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

2 participants