Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issues with Strings being compared with either == or != #206

Open
scuniff opened this issue Mar 2, 2023 · 0 comments
Open

issues with Strings being compared with either == or != #206

scuniff opened this issue Mar 2, 2023 · 0 comments

Comments

@scuniff
Copy link

scuniff commented Mar 2, 2023

The Static Code Analyzer Spot Bugs found the following issues with Strings being compared with either == or != and should be using equals().

From Spot Bugs:

Comparison of String objects using == or !=

(https://spotbugs.readthedocs.io/en/latest/bugDescriptions.html#ES_COMPARING_STRINGS_WITH_EQ)
This code compares java.lang.String objects for reference equality using the == or != operators. Unless both strings are either
constants in a source file, or have been interned using the String.intern() method, the same string value may be represented by two
different String objects. Consider using the equals(Object) method instead.

Bug kind and pattern: ES - ES_COMPARING_STRINGS_WITH_EQ

Occurrences:

https://github.com/imagej/ImageJ/blob/master/ij/gui/PlotContentsDialog.java

if (allTableNames[i] == previousTableName)

https://github.com/imagej/ImageJ/blob/master/ij/plugin/SimpleCommands.java

if (label2!=label) {

https://github.com/imagej/ImageJ/blob/master/ij/macro/FunctionFinder.java

if (exists=="0") {

https://github.com/imagej/ImageJ/blob/master/ij/plugin/frame/Recorder.java

if (commandOptions==null || commandOptions==" ")

occurs twice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant