Skip to content

Code cleanups#2141

Merged
oscargus merged 5 commits into
JabRef:masterfrom
oscargus:codecleanups
Oct 14, 2016
Merged

Code cleanups#2141
oscargus merged 5 commits into
JabRef:masterfrom
oscargus:codecleanups

Conversation

@oscargus

@oscargus oscargus commented Oct 8, 2016

Copy link
Copy Markdown
Contributor

Removed some unused arguments.
Used constants from top level definition.

I also added some comments to consider during the review.

@oscargus oscargus added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers dev: code-quality Issues related to code or architecture decisions labels Oct 8, 2016
// try to avoid ending up with the ugly Metal L&F
Plastic3DLookAndFeel lnf = new Plastic3DLookAndFeel();
Plastic3DLookAndFeel.setCurrentTheme(new SkyBluer());
MetalLookAndFeel.setCurrentTheme(new SkyBluer());

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 did you change that to Metal as we want to avoid it here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Apparently Plastic is inheriting the method from Metal.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can change it back though. Was also a bit surprised.


for (BibEntry entry : bp.getDatabase().getEntries()) {
// Please explain what this line, and therefore the whole method, is doing (if it is doing something)
EntryTypes.getType(entry.getType(), bibDatabaseMode).ifPresent(entry::setType);

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.

I think, it is because the types are objects. If one switches from bibtex to biblatex, the types get different objects even though the string representation is the same. This loop ensures that the type objects match the type of the database.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK! I'll remove the comment.

@koppor

koppor commented Oct 9, 2016

Copy link
Copy Markdown
Member

I just provided the comment on the unclear method - I think, @stefan-kolb can approve that.

The static method for accept feels unusual as we want to avoid static methods. However, I can live with that.

Other than that: LGTM

@tobiasdiez tobiasdiez 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.

LGTM, just a small remark.
Also please remove the other comment before merging.

*/
public void removeChild() {
// NPE if this is ever called
child.setParent(null);

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.

Could you please fix it by wrapping everything in a if( child != null)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Isn't it better that the author of the faulty code fixes it when the implementation is finished? I do not really see how this code was ever approved...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, yes. The problem is actually passing null to a metod with an Objects.requireNonNull as the first call... So clearly that code was never executed.

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.

Isn't it better that the author of the faulty code fixes it

The nice thing about open source code is that there is no "your / mine code", everyone is responsible for all the code. I can't count how many times I already fixed some small bugs which somebody else created and similarly many others (including you) cleaned up my mess.

Please just add the if statement there and then merge this in directly (ready-for-review removed for this reason).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The first comment was not really relevant here. Again, the thing is not that child becomes null, although that will also break the code, but that whenever child.setParent(null) is called there will be an NPE as the code for setParentreads (second comment):

     protected void setParent(T parent) {
         this.parent = Objects.requireNonNull(parent);
}

Hence, yes, I can add the if statement, but that is not really solving the problem I pointed out in the comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

And, no, I have no idea how the code is supposed to actually work, but I can notice that the removeChild was never called as a call to it would throw an NPE in setParent. (And I have also fixed other persons bugs. This one I cannot really see why it was ever merged to begin with though. I would exepect even half finished merged code to not throw NPEs on every possible call to it.)

@tobiasdiez tobiasdiez removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 12, 2016
@oscargus

Copy link
Copy Markdown
Contributor Author

As I added the if-statement (kept the comment though, as described above), I merge this now.

@oscargus oscargus merged commit 955b94d into JabRef:master Oct 14, 2016
@oscargus oscargus deleted the codecleanups branch October 14, 2016 12:01
Siedlerchr added a commit that referenced this pull request Oct 15, 2016
* upstream/master:
  Code cleanups (#2141)
  Remove obsolete string in .mailmap
  Update .mailmap and AUTHORS
  Implementation of autosave & backup feature (#2118)
  Make all files selectable in file chooser dialogs (#2094)
  Fix group drag and drop (#2161)
  Change donation badge and point to https://donations.jabref.org

# Conflicts:
#	src/main/java/net/sf/jabref/logic/util/OptionalUtil.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev: code-quality Issues related to code or architecture decisions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants