Validates the file path of a TexGroup and fixes Texgroup's "Library has been modified by another program"#6586
Conversation
…validationVisualizer
This reverts commit ad11243.
calixtus
left a comment
There was a problem hiding this comment.
Hi @systemoperator , thanks again for this PR and your work here.
I got some remarks about the codestyle and one suggestion with StringUtils.
|
I don't know where to put |
|
@systemoperator We have our own FileUtil class in model or logic, beware of the import. |
|
Checkstyle is failing because of now unused import io.file. |
|
Apparently, this PR also fixes #6394. At least I could not reproduce it so far. I will test it onwards. |
tobiasdiez
left a comment
There was a problem hiding this comment.
Thanks for your PR!
Just to make sure that I understand the changes correctly: the issue is fixed by parsing the groups last?
I have to minor comments concerning the code. It would be nice if you could also add a test so that we don't break it in the future again (especially since this concerns the parser of bib files, which is arguely the most important part of JabRef).
Yes, because the groups access data which need to be defined beforehand. Depending on the sequence in the entry set, this may work once but not every time. |
|
Now without stream.^^ Any suggestion how to test the case mentioned at #6586 (review)? |
|
The code looks good to me! For the test, it should be similar to the following: jabref/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java Lines 1369 to 1389 in 7cc5747 Create the string by hand (with groups before the other setting that makes troubles) and then verify that the groups in the parsed metadata has the valid data. |
|
The test was a bit tricky (access real file, relative, user name, hostname, ...), but it works now. |
koppor
left a comment
There was a problem hiding this comment.
Code looks good; did not test it though.
Have some code nitpicks. Hope, you like these suggestions (moving the code to more modern Java 14).
| default: | ||
| // Keep meta data items that we do not know in the file | ||
| metaData.putUnknownMetaDataItem(entry.getKey(), value); | ||
| } else if (entry.getKey().equals(MetaData.SAVE_ACTIONS)) { |
There was a problem hiding this comment.
Can we keep the switch (entry.getKey) somehow? Maybe nested in an else branch?
You can use the new Java14 switch: https://openjdk.java.net/jeps/361
(File needs to be added to
jabref/config/checkstyle/checkstyle.xml
Line 15 in ca06b71
There was a problem hiding this comment.
This is still a huge p.i.t.a.
Checkstyle really needs to keep up, people start getting tired of these workarounds.
Some background information, if you are interested: checkstyle/checkstyle#6615
There was a problem hiding this comment.
The key problem is here that switch cases are not executed in order. That's the reason for the if else
There was a problem hiding this comment.
Yes, the switch statement could be reintroduced (and simplified). Before this fix, the code was structured really confusing and looked error-prone. So I decided to create this consistent and simplified version, which I find quite acceptable.
There was a problem hiding this comment.
I meant only for the lower part; not with the xxxx continue statements. Just for the endless chain of else if (entry.getKey().equeals(MetaData.X)) chains, where only X is different from the checks.
There is ALWAYS entry.getKey() compared from line 75 to line 92 (or did I see something wrong?).
This is just a matter of taste. Maybe, I'll just do it and open another PR to have the discussions there. Should not be a show stopper for us now.
| input -> { | ||
| if (StringUtil.isBlank(input)) { | ||
| return false; | ||
| } else { |
There was a problem hiding this comment.
@stefan-kolb Would review here: "Fail fast". Not endless nested if/else statements, but just exit early.
Therefore, I proposed:
if (StringUtil.isBlank(input)) {
return false;
}Think, I will start another PR with this and the other code style thing and we can have the discussion there --> we need to get this fix in soon.
* upstream/master: Validates the file path of a TexGroup and fixes Texgroup's "Library has been modified by another program" (#6586) Bump postgresql from 42.2.12 to 42.2.14 (#6610) Add markdown-link-check (#6542) Catch InaccessibleObjectException (#6519) Fix author formatter for unchanged names (#6552) Bump com.simonharrer.modernizer from 1.8.0-1 to 2.1.0-1 Bump org.beryx.jlink from 2.19.0 to 2.20.0 Bump classgraph from 4.8.83 to 4.8.86 Update FileUtilTest.java Update FileUtilTest.java Squashed 'src/main/resources/csl-styles/' changes from c5f14e2..716f635 Update FileUtilTest.java Update MoveFilesCleanupTest.java checkstyle Fix dowmloaded files moved to citaiton key dir


Fixes #6420.
Fixes #6585.