Issue #17501: Add TodoComment Check to the google config#17599
Conversation
|
Github, generate report |
| </module> | ||
| <module name="SingleLineJavadoc"/> | ||
| <module name="TodoComment"> | ||
| <property name="format" value="\b(?!TODO\b)(?i:TODO)\b"/> |
There was a problem hiding this comment.
in style guide there is , a following colon , any ideas on how to make it ?
There was a problem hiding this comment.
@mohitsatr Please use following config:
<module name="TodoComment">
<property name="format" value="^[ \t]*(?!TODO:)(?i:TODO)\b:?"/>
<message key="todo.match" value="Todo comments must use ''TODO:'' in all caps."/>
</module>This regex gives violation only when the "todo" is present at the beginning. Also it ensures that : is present after TODO. I have also modified the violation message a bit and used 'TODO:'
There was a problem hiding this comment.
@romani fyi
The above mentioned regex doesn't violates when there's no whitespace after :, for example:
void myFunc16(int i) {
// TODO:implementing
}this case passes. Style guide doesn't mention anything about enforcing a whitespace after : so I think this should be okay.
There was a problem hiding this comment.
^^^ this should be no violation.
@mohitsatr , please extend test cases
|
Github, generate website |
|
Github, generate report |
Zopsss
left a comment
There was a problem hiding this comment.
Sorry for requesting more changes, last:
Please change the violation message, the current one is:
Todo comments must use 'TODO:' in all caps
This only mentions about TODO being in all caps, it doesn't mention about colon. Please use following or ask AI to generate more professional message.
'TODO:' must be written in all caps and followed by a colon.
| void myFunc31(int i) { | ||
| // tODo:implementing | ||
| // violation above 'Todo comments must use 'TODO:' in all caps' | ||
| } | ||
|
|
||
| void myFunc32(int i) { | ||
| // TODO:implementing | ||
| } |
There was a problem hiding this comment.
Please also add these examples:
void myFunc32(int i) {
// tODo implementing
// violation above 'Todo comments must use 'TODO:' in all caps'
}
void myFunc33(int i) {
// TODO implementing
// violation above 'Todo comments must use 'TODO:' in all caps'
}
void myFunc34(int i) {
// TODO: correct TODO comment
}
void myFunc35(int i) {
// TODO:correct TODO comment
}
Zopsss
left a comment
There was a problem hiding this comment.
All good from my side. Just remove the suppression Roman mentioned.

resolves: #17501
Diff Regression config: https://gist.githubusercontent.com/mohitsatr/f3d0e6d4aa5b6e25a9d3a6b9d5425972/raw/18a7ee9a1016eb7b314e7508a68618a89257170e/master_todo.xml
Diff Regression patch config: https://gist.githubusercontent.com/mohitsatr/b53a185be531c4ac11653a45b478e2a1/raw/9d92392250ec9bcb8b7191ea4d6b9ada0f854e7b/patch_todo.xml