Skip to content

Issue #17501: Add TodoComment Check to the google config#17599

Merged
romani merged 1 commit into
checkstyle:masterfrom
mohitsatr:add-todo
Aug 16, 2025
Merged

Issue #17501: Add TodoComment Check to the google config#17599
romani merged 1 commit into
checkstyle:masterfrom
mohitsatr:add-todo

Conversation

@mohitsatr

@mohitsatr mohitsatr commented Aug 11, 2025

Copy link
Copy Markdown
Member

@mohitsatr

Copy link
Copy Markdown
Member Author

Github, generate report

@github-actions

Copy link
Copy Markdown
Contributor

Comment thread src/main/resources/google_checks.xml Outdated
</module>
<module name="SingleLineJavadoc"/>
<module name="TodoComment">
<property name="format" value="\b(?!TODO\b)(?i:TODO)\b"/>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from 101regexp:
image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in style guide there is , a following colon , any ideas on how to make it ?

@Zopsss Zopsss Aug 12, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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:'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^^ this should be no violation.
@mohitsatr , please extend test cases

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved.

@mohitsatr

Copy link
Copy Markdown
Member Author

Github, generate website

@mohitsatr

Copy link
Copy Markdown
Member Author

Github, generate report

@github-actions

Copy link
Copy Markdown
Contributor

@Zopsss Zopsss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +155 to +162
void myFunc31(int i) {
// tODo:implementing
// violation above 'Todo comments must use 'TODO:' in all caps'
}

void myFunc32(int i) {
// TODO:implementing
}

@Zopsss Zopsss Aug 13, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
  }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved.

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

items:

Comment thread config/linkcheck-suppressions.txt Outdated

@Zopsss Zopsss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good from my side. Just remove the suppression Roman mentioned.

@romani romani merged commit 89aca7f into checkstyle:master Aug 16, 2025
118 of 163 checks passed
@mohitsatr mohitsatr deleted the add-todo branch August 18, 2025 03:37
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

Successfully merging this pull request may close these issues.

Google style: Word TODO of Todo comment must be in all caps

3 participants