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 `ProcessedSource#commented?` for multi-line ranges. Add `ProcessedSource#commented_line?` #55

Merged
merged 2 commits into from Jul 12, 2020

Conversation

@marcandre
Copy link
Contributor

@marcandre marcandre commented Jul 4, 2020

ProcessedSource#commented? was only considering the beginning line of the given range

@marcandre marcandre force-pushed the marcandre:comment branch 2 times, most recently from 86bf60c to e3f08dc Jul 5, 2020
@@ -95,8 +95,16 @@ def blank?
ast.nil?
end

# @return [Boolean] if the given line number has a comment.
def commented_line?(line)

This comment has been minimized.

@bbatsov

bbatsov Jul 6, 2020
Contributor

I think the name is a bit misleading (it sounds like a line that was commented out), but it's a good change. I guess you just tried to mimic the commented? name we've employed before. Perhaps it should have been something like contains_comments? or whatever.

This comment has been minimized.

@marcandre

marcandre Jul 6, 2020
Author Contributor

I agree, I should have thought of a better name, especially that util.rb in rubocop has comment_line? which is true only for full lines.
So which is best: contains_comment?, or line_with_comment?.

This comment has been minimized.

@bbatsov

bbatsov Jul 6, 2020
Contributor

You can make a method contains_comment? that acts differently on line numbers and source ranges. 😉 If not - I'd go with line_with_comment?, as I suggested contains_comment? as an alternative name for commented?.

This comment has been minimized.

@marcandre

marcandre Jul 9, 2020
Author Contributor

Updated with line_with_comment? and contains_comment? (with deprecated alias commented?)

@marcandre marcandre force-pushed the marcandre:comment branch 2 times, most recently from d31430f to dc52ee7 Jul 8, 2020
@marcandre marcandre force-pushed the marcandre:comment branch from dc52ee7 to 2a31ceb Jul 9, 2020
@bbatsov bbatsov merged commit ac40528 into rubocop-hq:master Jul 12, 2020
14 checks passed
14 checks passed
AST | master | 2.4 (ubuntu)
Details
AST | master | 2.5 (ubuntu)
Details
AST | master | 2.6 (ubuntu)
Details
AST | master | 2.7 (ubuntu)
Details
AST | master | head (ubuntu)
Details
AST | master | mingw (windows)
Details
AST | 0.84.0 | 2.4 (ubuntu)
Details
AST | 0.84.0 | head (ubuntu)
Details
Cov | 0.84.0 | 2.4 (ubuntu)
Details
Modern | master | 2.7 (ubuntu)
Details
Main | 0.84.0 | 2.4 (ubuntu)
Details
Main | master | 2.4 (ubuntu)
Details
Main | 0.84.0 | 2.7 (ubuntu)
Details
Main | master | 2.7 (ubuntu)
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.