Skip to content

Remove teamscale findings in the database package#1577

Merged
stefan-kolb merged 11 commits into
JabRef:masterfrom
tschechlovdev:TeamscaleFindingsModelDatabasePackage
Sep 3, 2016
Merged

Remove teamscale findings in the database package#1577
stefan-kolb merged 11 commits into
JabRef:masterfrom
tschechlovdev:TeamscaleFindingsModelDatabasePackage

Conversation

@tschechlovdev

Copy link
Copy Markdown
Contributor

Remove the teamscale finding in the database package, that is in the model package. This means refactoring of methods, that are too long, adding comments to public method/classes and used streams in some situations for better readability (and reducing code).

}

/**
* Creates a KeyCollisionException with a given message and a given cause.

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 don't think, it necessary to document trivial cases. Maybe, this teamscale finding should be ignored?

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 removed the unnecessary comments.

@tschechlovdev tschechlovdev force-pushed the TeamscaleFindingsModelDatabasePackage branch 2 times, most recently from 982c239 to 72fae1a Compare July 12, 2016 16:19
// note: there is a good reason why we should not use a hashset but use hashmap instead
//========================================================
public void removeKeyFromSet(String key) {
protected void removeKeyFromSet(String key) {

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.

Still not consistent with addKeyToSet

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.

But then I have to set addKeyToSet protected, or public, although it can be declared private. Shouldn't it have the lowest possible visibility level?


private final EventBus eventBus = new EventBus();


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.

Bitte keine obsoelten Leerzeilen

@koppor koppor changed the title [WIP]remove teamscale findings in the database package [WIP] Remove teamscale findings in the database package Jul 18, 2016
/**
*
* @param key
* @return list of entries that contains the given key

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.

Please rework comment. "Collects entries having the specified BibTeX key and returns these entries as list. The order of the entries is the order they appear in the database"

*
* This class handles the instantiations of {@link BibDatabase}.
*
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove the empty lines in the comment

import net.sf.jabref.model.entry.EntryType;

/**
* In this class the detection of the {@link BibDatabaseMode} is handled.

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.

Either remove this comment or expand it by explaining, what the intention of the mode is etc. What is the idea of the detection etc.

@koppor koppor removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 12, 2016
…chechlovdev/jabref into TeamscaleFindingsModelDatabasePackage

# Conflicts:
#	src/main/java/net/sf/jabref/model/database/BibDatabase.java
#	src/main/java/net/sf/jabref/model/database/DuplicationChecker.java
entry.setCiteKey(key);
}
return duplicationChecker.checkForDuplicateKeyAndAdd(oldKey, key);
return duplicationChecker.checkForDuplicateKeyAndAdd(entry.getCiteKeyOptional(), Optional.ofNullable(key));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

entry.getCiteKeyOptional() will not contain the old key now. Both arguments will be identical so will break the function of the call.

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.

Thanks a lot! I've searched at the wrong place for the failure ....

…ModelDatabasePackage

# Conflicts:
#	src/main/java/net/sf/jabref/model/database/BibDatabase.java
@tschechlovdev tschechlovdev added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 21, 2016
*
* @return true, if there is a duplicate key, else false
*/
public boolean checkForDuplicateKeyAndAdd(Optional<String> oldKey, Optional<String> newKey) {

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 don't like Optionals as parameters here.

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.

If I remember correctly, the caller may pass null for both oldKey and newKey. As JabRef moves away from null towards Optional, we thought, it would be a good idea to use Optional here, too.

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.

Personnaly I think Optional is only a good thing for return types. I also posted an article some time ago.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Independent of Optional or not, wouldn't it be possible to write the code like:

boolean duplicate = false;
if (!oldKey.equals(newKey)) {  // If keys are not the same
if (!oldKey.isPresent()) { // No old key
duplicate = addKeyToSet(newKey.get());
} else {
 removeKeyFromSet(oldKey.get());  // Get rid of old key
 if (newKey.isPresent()) { // Add new key if any
  duplicate = addKeyToSet(newKey.get());          
 } 
}
}

if (duplicate) {
...
}

(Replace with corresponding non-optional calls (Objects.equals() for the first call).

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.

@stefan-kolb Do you have a deep link for the article? I checked https://github.com/JabRef/jabref/wiki/Code-Howtos, which points to https://github.com/cxxr/better-java#avoid-nulls, which uses Optional also in the parameters.

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.

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.

Related discussion:
http://stackoverflow.com/questions/31922866/why-should-java-8s-optional-not-be-used-in-arguments

2016-08-26 8:25 GMT+02:00 Stefan Kolb notifications@github.com:

In src/main/java/net/sf/jabref/model/database/DuplicationChecker.java
#1577 (comment):

  • //############################################
  • // if the newkey already exists and is not the same as oldkey it will give a warning
  • // else it will add the newkey to the to set and remove the oldkey
  • public boolean checkForDuplicateKeyAndAdd(String oldKey, String newKey) {
  •    // LOGGER.debug(" checkForDuplicateKeyAndAdd [oldKey = " + oldKey + "] [newKey = " + newKey + "]");
    
  • /**
  • \* Usage:
    
  • \* <br>
    
  • \* isDuplicate=checkForDuplicateKeyAndAdd( null, b.getKey() , issueDuplicateWarning);
    
  • *
    
  • \* If the newkey already exists and is not the same as oldkey it will give a warning
    
  • \* else it will add the newkey to the to set and remove the oldkey
    
  • *
    
  • \* @return true, if there is a duplicate key, else false
    
  • */
    
  • public boolean checkForDuplicateKeyAndAdd(Optional oldKey, Optional newKey) {

Not the exacr one but what about these: https://dzone.com/articles/
use-of-optional-is-optional, https://dzone.com/articles/
java-8-optional-how-use-it


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub
https://github.com/JabRef/jabref/pull/1577/files/f9d6a1943a7bc023d8042f02c3c3922c38f34a66#r76369435,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AATi5Fj7w1jmaRe-PdgqNDMDsD1MeDS2ks5qjobDgaJpZM4JKeSe
.

@stefan-kolb

Copy link
Copy Markdown
Member

Just two small changes and I'm OK with it 👍

@koppor koppor removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 25, 2016
@stefan-kolb

Copy link
Copy Markdown
Member

LGTM 👍

@stefan-kolb stefan-kolb added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Sep 2, 2016
@stefan-kolb stefan-kolb merged commit 357be5c into JabRef:master Sep 3, 2016
@tschechlovdev tschechlovdev deleted the TeamscaleFindingsModelDatabasePackage branch September 3, 2016 13:35
Siedlerchr added a commit to Siedlerchr/jabref that referenced this pull request Sep 4, 2016
* master:
  Remove teamscale findings in the database package (JabRef#1577)
  French localization: Jabref_fr: empty strings translated + removal of unused header (JabRef#1911)
tobiasdiez pushed a commit that referenced this pull request Sep 5, 2016
* Check integrity edition check

* Conflict in Jabref_fr

* Changed order Biblatex/Bibtex condition

* Create own object

* Rename variable

* Extract checker to own file

* Improved comment

* French localization: Jabref_fr: empty strings translated + removal of unused header (#1911)

* Remove teamscale findings in the database package (#1577)

* Check integrity edition check

* Changed order Biblatex/Bibtex condition

* Create own object

* Rename variable

* Mark some methods as deprecated in BibEntry and BibDatabase (#1913)

* Mark some methods as deprecated in BibEntry and BibDatabase

* Rename getResolvedFieldOrAlias

* Use flatmap

* Fix location field not exported correctly to office 2007 xml (#1909)

* Fix location field not exported to office 2007 xml
* Add some test for exporting location and address field
Address in xml field is now imported as location
add some javadoc

* Add possibility to remember password for shared databases. (#1846)

* Add possibility to remember password.
- Add checkbox to the open shared database dialog
- Add SharedDatabasePreferences
- Add password encrypting and decrypting methods
- Update localization entries
- Reorganize clearing methods for Preferences

* Change prefs node and add class comment.

* Relativate node path for password storage.

* Fix LOGGER factory.

* Improve password encryption using XOR.

- Use username as one operand
- Add new parameter to the constructor

* Extract method.

* Improve exception handling.

* Improve password encryption and decryption.

- Use CBC and padding
- Hash the key before using
- Simplify conversion

* Fix modifier. Fix conflicts.

* Extract checker to own file

* Improved comment

* Translation of shared (#1919)

* Add missing entries in german localization

* Resolved conflicts

* Some more conflicts de sv

* Expressions changed
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.

7 participants