| Summary: | [checker] suppressing the "No break at the end of case" problem with regexp | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Mikhail Barg <mikhail.barg> | ||||
| Component: | cdt-codan | Assignee: | Elena Laskavaia <elaskavaia.cdt> | ||||
| Status: | RESOLVED FIXED | QA Contact: | Elena Laskavaia <elaskavaia.cdt> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | cdtdoug, nobody, scobido1984, waste.manager, yevshif, zeratul976 | ||||
| Version: | 8.0 | ||||||
| Target Milestone: | 9.5.0 | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| See Also: |
https://git.eclipse.org/r/114751 https://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=ce18aad766e9a947679a3daf33966bba75406fdf |
||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
org.eclipse.cdt.codan.internal.checkers.CaseBreakChecker:113:
> if (str.equalsIgnoreCase(_noBreakComment))
That's how it's done right now, good catch.
What's the plan here? I can change it to regex easily, got the fix already in a branch, but how exactly do we want it to work? Should it be case-insensitive by default? Do we want .find() (pattern present in comment) or .match() (pattern exactly matching comment)?
Created attachment 200547 [details]
example fix
this uses .find() and case insensitive matching
> Do we want .find() (pattern present in comment) or .match() (pattern
> exactly matching comment)?
Hm, match() is more universal, but find() will be easier to user for most cases. I'm voting for find().
In bug 352221 I supplied a patch for adding quick-fix support for this checker. For the quick fix to be able to add a comment automatically, I used non-case-sensitive "beginsWith" (because a reg-ex like "no break.*" is a really ugly comment :-) It possible also check comment with regex ".*falls?[ \t-]*thr(ough|u).*" for this warning? Or allow use regular expression in additional field? https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html One string comment is not enough. New Gerrit change created: https://git.eclipse.org/r/114751 Gerrit change https://git.eclipse.org/r/114751 was merged to [master]. Commit: http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=ce18aad766e9a947679a3daf33966bba75406fdf fixed on master i.e it is now supports regular expression |
Build Identifier: 20110615-0604 While the label "Comment text to suppress the problem (regular expression)" says that there could be a regular expression, I am unable to make it work. I'm trying to suppress the problem with the comment "//no break here" switch (1) { case 1: //no break here } and the regexp "no break.*" but it keeps being reported. Some more investigation shows that the text seem to be used as is (regexp "no break.*" suppresses the "//no break.*" comment). Reproducible: Always