Google style is changing to encourage a different (and more common) form of
TODO, specifically: TODO: link - description. This patch adds support for the
new style, while maintaining backwards compatability with the old style. The
patch adds a configuration option to the check to control which style (V1 or V2)
is checked.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp | ||
---|---|---|
97 | Given this check is part of the google module, doesn't it make sense to have the default as what google now recommends. | |
clang-tools-extra/docs/clang-tidy/checks/google/readability-todo.rst | ||
6 | Maybe update this line to something along with lines of | |
16–18 | This shouldn't appear in the options, as it isn't read from the CheckOptions | |
22 | It would be good to specify the default value of this option(or just the default behaviour of the check) |
Thank you for the very fast review!
clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp | ||
---|---|---|
97 | The style guide hasn't been updated yet. Once that happens, I think we should switch the default. I can add a FIXME -- what do you think? |
I'd be more comfortable reviewing this after it's actually been added to the style guide, it's hard to refer to non-public docs and discussions here.
I don't really understand the rationale for the hard split into two modes, vs always accepting both styles and maybe just making the fixit style configurable.
(OTOH If we *really* want to support exclusive use of the old style, why are we not supporting exclusive use of the new style?)
clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp | ||
---|---|---|
18 | I'd really prefer if we could give these names rather than numbers. Best I can come up with is paren-style/hyphen style though. Either way, we can drop "version" as it's redundant with "style". | |
79 | I find this part very confusing. We have two separate implementations that check whether this is a valid TODO(context): description comment, even though that's acceptable in all modes. Why? It seems like the logic should look either like: if (!isAnyTODOComment) // regex #1 return; if (isValidParenStyleTODO) // regex #2 return; if (allowNewStyle && isValidHyphenStyleTODO) // regex #3 return; diag(...) << Fix; // suggestion based on preferred style and parse from isAnyTODOComment or if (!matchesComplicatedAllEncompassingRegex) return; if (submatchesIndicateValidParenStyleTODO) return; if (submatchesIndicateValidHyphenStyleTODO) return; // diagnose and suggest fix | |
85 | this isn't accurate: TODO(username): description is still valid. | |
clang-tools-extra/docs/clang-tidy/checks/google/readability-todo.rst | ||
16 | This is a confusing option name. It's not clear what "V2Style" is, it's non-descriptive and the style guide won't use that term. Based on the current behavior, I'd suggest "PreferHyphenStyle" | |
32 | I think trying to enforce a new style via a check that doesn't suggest or even describe the style is a mistake. Given TODO: text, text is almost certainly a description - creating an appropriate link is a chore, but IME ~nobody forgets to actually write what they want to do. | |
clang-tools-extra/test/clang-tidy/checkers/google/readability-todo-v2.cpp | ||
21 | (surely this example shows how absurd this style is...) | |
24 | "supported for backwards compatibility" is stronger than the text I've seen, which simply says they're discouraged in new code. But for example if you don't have a bug link, AFAICS TODO(username): is the only possible form. |
I'd really prefer if we could give these names rather than numbers. Best I can come up with is paren-style/hyphen style though.
Either way, we can drop "version" as it's redundant with "style".
(Unless you're using it to refer to the version of the style *guide*/check logic in which case it's confusing to also use it to refer to the style of the comment, as these aren't 1:1)