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 checking if token with large offset begins its line #11583

Merged
merged 1 commit into from
Feb 22, 2023

Conversation

fatkodima
Copy link
Contributor

Fixes #11582.

50 is pretty reasonable number, I think. For bigger offsets we just fallback to the previous behavior.

@koic
Copy link
Member

koic commented Feb 17, 2023

Can you add a repro test case?

@fatkodima
Copy link
Contributor Author

Added a repro test case.

@@ -93,12 +94,17 @@ def on_node(syms, sexp, excludes = [], &block)
end

LINE_BEGINS_REGEX_CACHE = Hash.new do |hash, index|
hash[index] = /^\s{#{index}}\S/
max_allowed_index = 50
Copy link
Member

Choose a reason for hiding this comment

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

It can be a constant instead of a variable. Also, can you leave a source comment as to why 50 was chosen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted into a constant with a comment.

@bbatsov bbatsov merged commit 52e8e4f into rubocop:master Feb 22, 2023
@bbatsov
Copy link
Collaborator

bbatsov commented Feb 22, 2023

Thanks!

@fatkodima fatkodima deleted the begins_its_line-large-offset branch February 22, 2023 19:17
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/ClosingParenthesisIndentation fails after optimizations
3 participants