Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 317361 - Enhancement request in org.eclipse.cdt.codan.core.param.FileScopeProblemPreference
Summary: Enhancement request in org.eclipse.cdt.codan.core.param.FileScopeProblemPrefe...
Status: RESOLVED WONTFIX
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 7.0   Edit
Hardware: PC All
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-19 11:57 EDT by Meisam CLA
Modified: 2010-06-19 23:38 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Meisam CLA 2010-06-19 11:57:14 EDT
Wouldn't it be a better idea to replace EXCLUSION and INCLUSION static fields with an enum?

Nothing prevents users from calling setAttribute() and getAttribute() methods by an arbitrary string parameter as key. Additionally, these string are compared against the the given key in getAttribute() and setAttribute() methods using the == operand. I reviewed the code carefully and, as far as I know, there is nothing wrong with this class. But it's not a good idea to use String objects as keys and compare them with the == operand instead of the equals() method.
Comment 1 Meisam CLA 2010-06-19 12:07:52 EDT
I digged up the code and realized these fields (EXCLUSION and INCLUSION) are just used inside the FileScopeProblemPreference class. So, why they are public? Am I wrong about something?
Comment 2 Elena Laskavaia CLA 2010-06-19 13:32:59 EDT
I don't understand what is the bug about? It is ok to use ==,
the only acceptable objects are the constants defined in this class. 
Nothing stops user to pass other stuff but it just won't work. They are public because they use by other package (as you mention FileScopeProblemPreference). I don't know why they implemented this way not using regular getter/setter for example, but this was copied from jdt.
Comment 3 Meisam CLA 2010-06-19 23:38:41 EDT
(In reply to comment #2)
> I don't understand what is the bug about? It is ok to use ==,
> the only acceptable objects are the constants defined in this class. 
> Nothing stops user to pass other stuff but it just won't work.

There is absolutely nothing wrong with this class. But if we use an enum, calls to  setAttribute() and getAttribute() methods that use inappropriate parameters can be detected at compile time.

> They are public
> because they use by other package (as you mention FileScopeProblemPreference).
You are right. Sorry, my bad! :(

> I don't know why they implemented this way not using regular getter/setter for
> example, but this was copied from jdt.

Maybe we should ask the original developer why it is like this in jdt.

BTW, this is one of the false positives reported by Findbugs.