Skip to content

Add rule for tracking all the conventional comments in code like FIXME, TODO, HACK #2039

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

Open
IVNSTN opened this issue Oct 22, 2024 · 5 comments

Comments

@IVNSTN
Copy link

IVNSTN commented Oct 22, 2024

Summary of the new feature

I'd like to see notifications/warnings/info messages about conventional comments detected in code, e.g.

# FIXME : something that does not work properly in some conditions
# TODO - unfinished work
# HACK bad place, dirty trick

Also we export code analysis results to SonarQube and since there is no such rule, I cant see all the technical debt mentioned in the whole codebase.

Proposed technical implementation details (optional)

A rule needs to be created. TODO comments should have info/hint status, FIXME and others may have warning status.

Here is what I see in SonarQube for C# repo
image
I'd like to have the same information for Powershell repo.

Related links

What is the latest version of PSScriptAnalyzer at the point of writing

1.23.0

@HeyItsGilbert
Copy link

What level would it make sense to make this alert? I feel like Warning might be too high. Been working on something similar for my team since we use TODO Tree to highlight these in vscode.

@SydneyhSmith does the up-for-grabs tag indicate that you're open to contributors?

@bergmeister
Copy link
Collaborator

I'd actually say, that this sort of things is better for Editors and its extensions to handle. There is already a lot out there: https://medium.com/@EclecticCoder/manage-todo-list-in-vscode-beb53774d776

@IVNSTN
Copy link
Author

IVNSTN commented Mar 14, 2025

Thank you for your suggestions, but I'm afraid this topic is about static code analysis and codebase management, code-smell detection, source code metrics. Not about primitive personal task management or getting-things-done-handy-tools.

@HeyItsGilbert
Copy link

HeyItsGilbert commented Mar 15, 2025

This could easily be a custom script analyzer rule. I'm not necessarily sold that it should be an out of the box rule. If it was, I wouldn't want it to be enabled by default (I have a lot of TODO's lol). By if your group/org/etc. wants to warn on these, it's doable.

This is the regex I use to detect these kinds of things with the "ToDo Tree" VSCode extension:

((\/\/|#|<!--|;|\*|^)((\s+(!|\?|\*|\-))?(\s+\[ \])?|(\s+(!|\?|\*)\s+\[.\])?)\s*(fix|todo|bug|mark|\[.\])\s*\:?)

For each AST passing through the custom rule you would just inspect the Extent for anything that matches that regex.

@HeyItsGilbert
Copy link

I decided to give it a shot. I created Measure-TODOComment rule in a new module where I'm gonna toss these custom rules I decide to throw together.

In a future version I'd like to make the types configurable. Maybe folks will care only about FIX or TODO, etc.

https://github.com/HeyItsGilbert/GoodEnoughRules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants