Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 350144 - [checker] suppressing the "No break at the end of case" problem with regexp
Summary: [checker] suppressing the "No break at the end of case" problem with regexp
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 9.5.0   Edit
Assignee: Elena Laskavaia CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-23 10:05 EDT by Mikhail Barg CLA
Modified: 2018-05-15 18:25 EDT (History)
6 users (show)

See Also:


Attachments
example fix (2.56 KB, patch)
2011-07-28 13:42 EDT, Tomasz Wesolowski CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Barg CLA 2011-06-23 10:05:17 EDT
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
Comment 1 Tomasz Wesolowski CLA 2011-07-28 13:27:15 EDT
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)?
Comment 2 Tomasz Wesolowski CLA 2011-07-28 13:42:33 EDT
Created attachment 200547 [details]
example fix

this uses .find() and case insensitive matching
Comment 3 Mikhail Barg CLA 2011-07-29 03:42:20 EDT
> 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().
Comment 4 Gil Barash CLA 2011-07-30 10:35:55 EDT
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 :-)
Comment 5 Nobody - feel free to take it CLA 2017-12-23 10:11:24 EST
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.
Comment 6 Eclipse Genie CLA 2017-12-26 15:10:03 EST
New Gerrit change created: https://git.eclipse.org/r/114751
Comment 8 Elena Laskavaia CLA 2017-12-30 11:29:14 EST
fixed on master
Comment 9 Elena Laskavaia CLA 2017-12-30 11:29:51 EST
i.e it is now supports regular expression