Skip to content

Fix some spotbugs issues#3060

Merged
Siedlerchr merged 3 commits into
masterfrom
findBugs
Aug 1, 2017
Merged

Fix some spotbugs issues#3060
Siedlerchr merged 3 commits into
masterfrom
findBugs

Conversation

@Siedlerchr

Copy link
Copy Markdown
Member

Some few issues, mostly some issues with equal:
https://spotbugs.github.io/

  • Change in CHANGELOG.md described

  • Tests created for changes

  • Screenshots added (for bigger UI changes)

  • Manually tested changed features in running JabRef

  • Check documentation status (Issue created for outdated help page at help.jabref.org?)

  • If you changed the localization: Did you run gradle localizationUpdate?

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jul 31, 2017

// Key binding preferences
public static KeyBindingRepository getKeyPrefs() {
public static synchronized KeyBindingRepository getKeyPrefs() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why synchronized here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect lazy initialization
https://stackoverflow.com/a/6782690/3450689

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refs item 3 of effective java, doesn't it?

// Check if it is the preamble:
if ((preambleEditor != null) && (focused == preambleEditor.getFieldEditor())) {

FieldEditor f = (FieldEditor) focused;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad variable name

BasePanel basePanel = frame.getBasePanelAt(i);
if ((basePanel.getBibDatabaseContext().getDatabaseFile().isPresent())
&& basePanel.getBibDatabaseContext().getDatabaseFile().get().equals(file)) {
if ((basePanel.getBibDatabaseContext().getDatabasePath().isPresent())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path equals file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the bug I fixed

@Override
public boolean equals(Object other) {
if (this == other) {
public boolean equals(Object o) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other is a pretty good name for the parameter imho

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed it to be consistent with the other implementations we have.
And there other is used as the name of the casted instance, see the line below

@lenhard lenhard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set a better name for the FieldEditor as metioned by Stefan and then this is ready to go.

@Siedlerchr Siedlerchr merged commit 5e04195 into master Aug 1, 2017
@Siedlerchr Siedlerchr deleted the findBugs branch August 1, 2017 18:15
Siedlerchr added a commit that referenced this pull request Aug 6, 2017
* upstream/master:
  Add warning message if group with same name is already present (#3077)
  Fix #3062: Ctrl + F works again
  Fix del/copy/paste key trigger main table action in search bar (#3070)
  Fix markdown
  Update gradle from 4.0.1 to 4.0.2
  Fix #3045 Update Transformer plugin
  Reimplement MappedList using a backigList (#3069)
  Fix importing preferences after resetting without restarting (#3065)
  Fix some spotbugs issues (#3060)
  Import dialog when fetch (#3025)
  Adapt CircleCI build
  Adapt CI script
  Closes #3027 and updates install4j to v7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants