Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 329430

Summary: Codan Semantic & Syntax can't be distinguished from compiler errors in the editor
Product: [Tools] CDT Reporter: James Blackburn <jamesblackburn+eclipse>
Component: cdt-codanAssignee: Elena Laskavaia <elaskavaia.cdt>
Status: RESOLVED FIXED QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: normal    
Priority: P3 CC: aegges, cdtdoug, eclipse.sprigogin, malaperle, paedu.hofer, pchuong, sducharme
Version: 8.0   
Target Milestone: 8.0   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:
Attachments:
Description Flags
New icons
none
little bugs
none
little bugs 2 none

Description James Blackburn CLA 2010-11-04 08:04:50 EDT
The Codan defaults for semantic and syntax  issues is error severity. While this is useful from a CDT developer's POV, it upsets users as code, which compiles cleanly, is marked up as having errors.

The parser and fast-indexer suffer from a few limitations which mean that the view of the code isn't perfect (even if the -Is and -Ds are correct). As such some of the syntax and semantic errors should be taken with a pinch of salt. 

Perhaps a default of 'info' for these sytanx / semantic issues -- i.e. bring them to the user's attention but they're not necessarily an 'error'.
Comment 1 Sergey Prigogin CLA 2010-11-04 23:18:09 EDT
(In reply to comment #0)

I disagree. The false positives are pretty rare on my code base. Hopefully the number of false positives can be further reduced by June.
Comment 2 James Blackburn CLA 2010-11-05 04:10:55 EDT
As I recall your code base doesn't do anything evil with the preprocessor?

I'm all for these issues being visible so they can be fixed.  However some of the problems, like only parsing/indexing  a header once, are tough to solve and will result in many false positives for embedded users.

My main issue is that there's no way to visually distinguish between codan error markers and C/C++ toolchain error markers.  The result is users end up very confused...
Comment 3 Elena Laskavaia CLA 2010-11-05 07:38:28 EDT
I disagree as well that they should be turned off (info as good as off).
They have different type in the problems view. You can tell them to turn off the severity or check-in per project settings. The better approach is to fix indexer settings, is this a really indexer limitation or configuration issue?
Comment 4 James Blackburn CLA 2010-11-05 07:47:19 EDT
Right but the user is working in the editor, not the Problems view.  The UI of the markers in the editor does _not_ allow the user to distinguish real compiler errors from codan errors.  I'm not saying it needs to be Info, it just needs to be distinguishable. AFAICS if we ship with this we will get lots of bug reports of non-existent errors...

In this particular project, the issue is definitely parser, not configuration (we're using managedbuild with all settings internal to CDT).  Specifically bug 329425 and bug 197989 both of which are apparently hard to fix and not on the plan to be fixed...
Comment 5 Elena Laskavaia CLA 2010-11-05 08:16:34 EDT
Using different icon in the editor may be possible... I have to check if it can be done from codan of modification of c editor is needed...
Comment 6 Marc-André Laperle CLA 2010-11-05 09:03:10 EDT
I agree with James that compiler errors and codan errors need to be distinguished. I have been confused more that once because of the same color/icon in the editor... and I contributed part of the checker.

(In reply to comment #5)
> Using different icon in the editor may be possible... I have to check if it can
> be done from codan of modification of c editor is needed...

I'm thinking it could be a combination of two smaller icons, like the light bulb + error icon for quick fixes. What image is synonymous to analysis to you? 

Here's some ideas:

-an erlenmeyer flask or something scientific like that. Maybe not "code" enough...
-a little bar chart. Maybe too statistic.
-a magnifying glass. Maybe too synonymous with search.
-a simple "C" letter...

Ideas?
Comment 7 Elena Laskavaia CLA 2010-11-05 19:56:18 EDT
usually static analysis is for finding bugs so it would be bug with error or warning overlay
Comment 8 Sergey Prigogin CLA 2010-11-05 20:52:12 EDT
(In reply to comment #7)

Syntax and semantic problems are not bugs.
Comment 9 Elena Laskavaia CLA 2010-11-07 15:33:18 EST
> Syntax and semantic problems are not bugs.
It is debatable. 
Plus Codan is mostly designed for bugs detection. Having semantics errors and stuff is nice side effect.
Comment 10 Doug Schaefer CLA 2011-03-11 12:37:12 EST
I'm getting way too many false errors, generally due to indexer setup issues. I wonder if we should reduce all Codan errors to warnings instead, at least until we're sure things are in good shape.
Comment 11 Sergey Prigogin CLA 2011-03-11 12:43:02 EST
(In reply to comment #10)
> I'm getting way too many false errors, generally due to indexer setup issues. I
> wonder if we should reduce all Codan errors to warnings instead, at least until
> we're sure things are in good shape.

Isn't it good that indexer setup issues are brought to the user's attention? I don't see any Codan errors on a properly setup project.
Comment 12 James Blackburn CLA 2011-03-11 12:48:47 EST
(In reply to comment #11)
> Isn't it good that indexer setup issues are brought to the user's attention? I
> don't see any Codan errors on a properly setup project.

As per comment 4 we get these in perfectly legitimate pre-processed C code.

I also see this when using boost, for example: BOOST_FOREACH (bug 332278)... 

I populate the -Ds and -Is from Dwarf and/or use the MBS exclusively here, and I'm pretty confident that the include paths + pre-proc defines are correct.  Even with this, for non trivial projects I see loads of these false errors...
Comment 13 Andrew Gvozdev CLA 2011-03-11 14:03:39 EST
Then there is bug 337583 which causes thousands of errors in our codebase which as I understand is not feasible to fix any time soon.

The ideal would be to get different icon in editor as it is not currently possible to have custom icon in Problems View - which bug 260909 comment 16 makes clear. However until it is done IMHO we should not use severity "Error" for that kind of semantic issues. I suggest to downgrade level to at least "Warning" and perhaps to have a quick fix to disable the warning permanently.
Comment 14 Sergey Prigogin CLA 2011-03-11 14:20:02 EST
(In reply to comment #13)

I reluctantly agree. We should revisit the issue of default severity once bug 337583 is fixed.
Comment 15 Elena Laskavaia CLA 2011-03-11 15:26:48 EST
Send another bug. Do we want them off or warnings? Because if you have false positives a lot - warnings are not good either.
Comment 16 Sergey Prigogin CLA 2011-03-11 15:28:38 EST
(In reply to comment #15)
> Send another bug. Do we want them off or warnings? Because if you have false
> positives a lot - warnings are not good either.

I vote for warnings.
Comment 17 James Blackburn CLA 2011-03-11 16:49:36 EST
(In reply to comment #16)
> I vote for warnings.

agreed. It's a good reminder that we should fix the issues...
Comment 18 Patrick Chuong CLA 2011-03-11 17:28:09 EST
We also run into similar issue, the code compiles fine, but there is an error in the editor.

i.e extern cregister volatile unsigned int IFR;

where cregister is a valid keyword for our compiler. We'll like to not have the error show up in the editor. Is there a way to make this error goes away through contribution and/or preference setting?
Comment 19 Axel Mueller CLA 2011-03-12 04:33:04 EST
I vote for warnings and different icons in the editor. At the moment I am bothered with false positives from Codan (see bug #315528 ). I think Codan should assist the user and not confuse him.
Comment 20 Doug Schaefer CLA 2011-03-14 10:30:18 EDT
(In reply to comment #19)
> I vote for warnings and different icons in the editor. At the moment I am
> bothered with false positives from Codan (see bug #315528 ). I think Codan
> should assist the user and not confuse him.

That's exactly my concern. The CDT needs to be usable without having to properly set up the index. Marking things as errors when they aren't errors has many negative impacts (e.g. SVN gives a warning when checking in source that there are errors on your code).
Comment 21 CDT Genie CLA 2011-03-17 22:24:17 EDT
*** cdt cvs genie on behalf of elaskavaia ***
Bug 329430: added extension to replace default icons for codan with custom. Now need the actual icons.

[+] error.gif  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/icons/error.gif?root=Tools_Project&revision=1.1&view=markup
[+] add_bug.gif  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/icons/add_bug.gif?root=Tools_Project&revision=1.1&view=markup
[+] quick_assist_obj.gif  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/icons/quick_assist_obj.gif?root=Tools_Project&revision=1.1&view=markup
[+] quick_fix_warning_obj.gif  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/icons/quick_fix_warning_obj.gif?root=Tools_Project&revision=1.1&view=markup
[+] small_bug.gif  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/icons/small_bug.gif?root=Tools_Project&revision=1.1&view=markup
[+] search_bug.gif  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/icons/search_bug.gif?root=Tools_Project&revision=1.1&view=markup
[+] quick_fix_error_obj.gif  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/icons/quick_fix_error_obj.gif?root=Tools_Project&revision=1.1&view=markup
[+] info.gif  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/icons/info.gif?root=Tools_Project&revision=1.1&view=markup
[+] warning.gif  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/icons/warning.gif?root=Tools_Project&revision=1.1&view=markup
[+] inspect_bug.gif  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/icons/inspect_bug.gif?root=Tools_Project&revision=1.1&view=markup
[+] edit_bug.gif  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/icons/edit_bug.gif?root=Tools_Project&revision=1.1&view=markup
[+] bookmark_bug.gif  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/icons/bookmark_bug.gif?root=Tools_Project&revision=1.1&view=markup

[*] bundle.properties 1.9 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/bundle.properties?root=Tools_Project&r1=1.8&r2=1.9

[*] plugin.xml 1.22 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/plugin.xml?root=Tools_Project&r1=1.21&r2=1.22
Comment 22 Marc-André Laperle CLA 2011-03-20 15:24:47 EDT
Created attachment 191582 [details]
New icons

Alena, what do you think of these icons? They have the C from the logo surround the warning or error. It is a challenge to make this look good in 12 pixel wide...
Comment 23 Andrew Gvozdev CLA 2011-03-21 11:44:56 EDT
(In reply to comment #22)
> Created attachment 191582 [details]
> New icons
> Alena, what do you think of these icons? They have the C from the logo surround
> the warning or error. It is a challenge to make this look good in 12 pixel
> wide...
These do not look quite pretty to me. Did you try the logo as an icon with severity overlays, does it look worse?
Comment 24 Elena Laskavaia CLA 2011-03-21 22:09:21 EDT
sorry they don't look good. Also I am thinking they should not really cdt semantics because they will be in common codan plugin, not that it matters now but I am hoping it can be used for other languages in future...
Comment 25 Marc-André Laperle CLA 2011-03-21 22:33:30 EDT
The logo has too much detail to look good at this size. I'll think of something else and possibly ask Andrée-Anne for help (she did the logo).
Comment 26 Elena Laskavaia CLA 2011-03-21 22:43:02 EDT
Created attachment 191652 [details]
little bugs
Comment 27 Elena Laskavaia CLA 2011-03-21 22:43:47 EDT
I made a screenshots of editor of icons of little bugs of different colors
Comment 28 Elena Laskavaia CLA 2011-03-21 22:46:09 EDT
Created attachment 191653 [details]
little bugs 2
Comment 29 Marc-André Laperle CLA 2011-03-21 22:50:14 EDT
They look good but I agree with Sergey that syntax and semantic problems are not bugs.
Comment 30 James Blackburn CLA 2011-03-22 04:59:20 EDT
(In reply to comment #28)
> Created attachment 191653 [details]
> little bugs 2

+1 I really like these.

I know technically semantic issues aren't bugs. However Codan can be used to detect bugs and having the same theme of icon for _all_ Codan related errors/warnings/info gives strong hints to users what's generating the warnings and how to turn it off.
Comment 31 Axel Mueller CLA 2011-03-22 08:32:04 EDT
(In reply to comment #30)
> > Created attachment 191653 [details] [details]
> > little bugs 2
> 
> +1 I really like these.
> 
> I know technically semantic issues aren't bugs. However Codan can be used to
> detect bugs and having the same theme of icon for _all_ Codan related
> errors/warnings/info gives strong hints to users what's generating the warnings
> and how to turn it off.
These icons are indeed nice. But I think they are misleading. Imagine the following scenario:
Your code has an actual compiler bug and Codan reports a different error/warning in the same file which might not result in an actual compiler bug. Thus, you will see an icon which shows a bug (from Codan) and a red circle with a cross (compiler bug). What will be the first impression? Yes, the user will think the bug icon shows the actual compiler bug!
Comment 32 James Blackburn CLA 2011-03-22 08:41:44 EDT
(In reply to comment #31)
> Your code has an actual compiler bug and Codan reports a different
> error/warning in the same file which might not result in an actual compiler
> bug. Thus, you will see an icon which shows a bug (from Codan) and a red circle
> with a cross (compiler bug).

That's not a 'compiler bug' it's a compiler error.  

>  What will be the first impression? Yes, the user
> will think the bug icon shows the actual compiler bug!

The need is to distinguish between Compiler errors and warnings, and the Codan notification. The icons for the compiler issues have been as they are for a very long time.  
Presumably the whole point of the codan framework is to show useful additional statically analyzed semantic issues (which we might call bugs...).  The fact that it picks up syntactic errors (as well as bugs in the parser...) is a nice to have bonus.

As a framework for discovering semantic bugs, a bug icons is appropriate, no?  Other issues codan discovers should use the same family of icons for consistency.
Comment 33 James Blackburn CLA 2011-03-22 08:43:06 EDT
(In reply to comment #31)
> > +1 I really like these.
> > 
> > I know technically semantic issues aren't bugs. However Codan can be used to

I meant _syntax_ issues.
Comment 34 Axel Mueller CLA 2011-03-22 10:38:11 EDT
(In reply to comment #32)
> That's not a 'compiler bug' it's a compiler error.  
Sorry. Wrong wording. Of course, I meant compiler error.

> >  What will be the first impression? Yes, the user
> > will think the bug icon shows the actual compiler bug!
> 
> The need is to distinguish between Compiler errors and warnings, and the Codan
> notification. The icons for the compiler issues have been as they are for a
> very long time.  
> Presumably the whole point of the codan framework is to show useful additional
> statically analyzed semantic issues (which we might call bugs...).  The fact
> that it picks up syntactic errors (as well as bugs in the parser...) is a nice
> to have bonus.
> 
I know that we cannot change the icons for compiler errors/warnings. And I support the goal of this bug report to use different icons for Codan (see my comment #19 ). I just want to make you aware what impression a new CDT user or somebody you used an old CDT version w/o Codan might get when he sees these icons. I bet most of them will think the bug icon marks a compiler error/warning. And I foresee a lot of messages in the CDT user forum from the kind "..my code compiles w/o errors but Eclipse shows error markers in the editor..".
Comment 35 James Blackburn CLA 2011-03-22 11:16:18 EDT
(In reply to comment #34)
> I just want to make you aware what impression a new CDT user or
> somebody you used an old CDT version w/o Codan might get when he sees these
> icons. I bet most of them will think the bug icon marks a compiler
> error/warning. And I foresee a lot of messages in the CDT user forum from the
> kind "..my code compiles w/o errors but Eclipse shows error markers in the
> editor..".

But this is true irrespective of the icon you choose. If Codan detects an issue it will create a marker and display an icon (configurable by the user as a  preference).  I agree false positives should be addressed.  

Given the primary purpose of Codan is to detect bugs that the compiler will silently ignore, surely a bug icon is appropriate?  After all cleanly compiling code still contains bugs and that's the raison d'etre of Codan.
Comment 36 Sergey Prigogin CLA 2011-03-22 12:08:42 EDT
The bugs look nice, but don't seem to mach the semantics and purpose of at least some of the Codan checkers (syntax errors, stylistic issues). Maybe some other insect, less often associated with software defects would be better. Small caterpillars or moths, perhaps?
Comment 38 Elena Laskavaia CLA 2011-05-01 21:38:52 EDT
Original problem is fixed now.
In problems view codan error have diffrent type,
in the editor they have diffrent icon. 
Cannot do anything about project explorer it is platform limitation
for markers.

If you don't like icons please open another bug report