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

Improve Empty if/elseif statement filter #17

Closed
looterz opened this issue Jan 9, 2016 · 1 comment
Closed

Improve Empty if/elseif statement filter #17

looterz opened this issue Jan 9, 2016 · 1 comment

Comments

@looterz
Copy link

looterz commented Jan 9, 2016

Would be great if this filter didn't trigger when comments are within the statement, often time's I see or have commented out code in conditionals for debugging or marking areas I need to implement something later. In a large project where these TODOs exist, it can plug up the lint log with lots of non-issues.

@FPtje
Copy link
Owner

FPtje commented Jan 9, 2016

There are several problems I have with this, one technical and one conceptually:

Technically, comments are only stored with a position. To figure out whether a comment "belongs to" an if statement, I'd have to look through all the comments and check whether the position is between the if and end of the if-statement I'm about to give a warning about for being empty.

Secondly, empty if-statements are dead code containing a potentially expensive condition expression. Regardless of whether they contain a comment or not, they are redundant. If you never fill in the -- TODO, you keep the empty if-statement, which is well worth a warning. It would be better to comment out the entire if-statement.

Because of that I don't think any time should be spent on implementing this. An if statement is empty too when contains only comments.

@FPtje FPtje closed this as completed Jan 9, 2016
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