imagej / imagej/ImageJ

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

Open
#206 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
786
Forks
267
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Review the reported comparisons in ij/gui/PlotContentsDialog.java, ij/plugin/SimpleCommands.java, ij/macro/FunctionFinder.java, and ij/plugin/frame/Recorder.java. Start with the listed SpotBugs ES_COMPARING_STRINGS_WITH_EQ warning and verify each occurrence's intended string-value comparison. Done means the affected comparisons are corrected and the SpotBugs warning no longer reports these occurrences.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.