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

No rule for commented out code #88

Open
charlie-abbott-deltatre opened this issue May 26, 2023 · 5 comments
Open

No rule for commented out code #88

charlie-abbott-deltatre opened this issue May 26, 2023 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@charlie-abbott-deltatre
Copy link
Contributor

There is currently no rule for catching commented out code, single or multiple line that is not a todo-pattern or noop comment.

@TwitchBronBron TwitchBronBron added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Jun 27, 2023
@TwitchBronBron
Copy link
Member

I like this one! It should be fairly easy to implement. There are two AST nodes, CommentStatement and CommentExpression that you'd look for in the walker, then we'd just need to define how you configure this in the bslint.json.

@charlie-abbott-deltatre
Copy link
Contributor Author

charlie-abbott-deltatre commented Jun 28, 2023

Some other things to consider with this change would be to define other allowed comments, like:

'bs:disable-line
'#region and '#endregion

etc

@TwitchBronBron
Copy link
Member

How would you handle comments like this?

sub main()
    ' get from the registry
    username = getFromRegistry()
    ' print it
    print username
end sub

@charlie-abbott-deltatre
Copy link
Contributor Author

For devs that would like to use this feature, they would need to update those comments to work with the todo-pattern.

Also with use of todo-pattern comments like this, over multiple lines:

'NOTE: some comment
'            over 2
'            or more lines

Maybe fun.

@TwitchBronBron
Copy link
Member

TwitchBronBron commented Jun 29, 2023

eslint has an alternative approach, where they actually try to parse the comments, and only show errors for code that will parse without error.

https://github.com/cartant/eslint-plugin-etc/blob/main/docs/rules/no-commented-out-code.md

It's worth at least considering. The eslint approach would cause some unparseable commented-out-code to get missed, but might be way nicer for devs to not have to rewrite every single one of their comments to prefix with 'NOTE:'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants