-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tabular UI for naming linked files #12624
base: main
Are you sure you want to change the base?
Conversation
I have try to add but I am very unclear about how preference migration works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output.
You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.
Not sure how to help. Example method: org.jabref.migrations.PreferencesMigrations#upgradeImportFileAndDirePatterns It first checks if a prefernce is there. If yes, it checks the content. Then, it check whether the current content is an old content. Then it updates to the new content. Then it wirtes the new string. Similar at org.jabref.migrations.PreferencesMigrations#upgradeKeyBindingsToJavaFX - and all other migrations. |
src/main/java/org/jabref/gui/linkedfile/LinkedFileNamePatternsPanel.java
Show resolved
Hide resolved
src/main/java/org/jabref/logic/citationkeypattern/CitationKeyGenerator.java
Show resolved
Hide resolved
src/main/java/org/jabref/logic/linkedfile/AbstractLinkedFileNamePatterns.java
Show resolved
Hide resolved
src/main/java/org/jabref/logic/linkedfile/AbstractLinkedFileNamePatterns.java
Show resolved
Hide resolved
src/main/java/org/jabref/logic/linkedfile/GlobalLinkedFileNamePatterns.java
Show resolved
Hide resolved
…emModel to PatternsItemModel
…ggestionCell to PatternsSuggestionCell
@trag-bot didn't find any issues in the code! ✅✨ |
if ((initialNamePattern.getDefaultValue() == null) || initialNamePattern.getDefaultValue().equals(Pattern.NULL_PATTERN)) { | ||
defaultPattern = ""; | ||
} else { | ||
defaultPattern = initialNamePattern.getDefaultValue().stringRepresentation(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code violates the fail-fast principle by nesting logic inside else branch. Should check for valid state first and return/assign early.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is OK in this context.
@Override | ||
public void setValues() { | ||
viewModel.setValues(); | ||
BibEntryTypesManager entryTypesManager = Injector.instantiateModelOrService(BibEntryTypesManager.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Direct instantiation through Injector in method body violates separation of concerns. The dependency should be injected through constructor or setter method.
@@ -48,7 +48,7 @@ public static Optional<MetaDataDiff> compare(MetaData originalMetaData, MetaData | |||
return Optional.empty(); | |||
} else { | |||
MetaDataDiff diff = new MetaDataDiff(originalMetaData, newMetaData); | |||
List<Difference> differences = diff.getDifferences(new GlobalCitationKeyPatterns(CitationKeyPattern.NULL_CITATION_KEY_PATTERN)); | |||
List<Difference> differences = diff.getDifferences(new GlobalCitationKeyPatterns(Pattern.NULL_PATTERN)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same GlobalCitationKeyPatterns object is created twice in the class - in compare() and toString(). This violates DRY principle and creates redundant object allocations.
@@ -14,12 +14,12 @@ | |||
*/ | |||
public abstract class AbstractCitationKeyPatterns { | |||
|
|||
protected CitationKeyPattern defaultPattern = CitationKeyPattern.NULL_CITATION_KEY_PATTERN; | |||
protected Pattern defaultPattern = Pattern.NULL_PATTERN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Public methods should not return null values. Consider using Optional instead of allowing null patterns, even for internal representation.
public static List<Pattern> getAllPatterns() { | ||
return Arrays.stream(Pattern.class.getDeclaredFields()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method lacks JavaDoc despite being a complex public method that uses reflection and handles exceptions. Documentation would help explain its purpose and behavior.
} | ||
|
||
/** | ||
* Gets an object for a desired key from this LinkedFileNamePattern or one of it's parents (in the case of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaDoc contains grammatical error ('it's' should be 'its') and references Hashtable in description while code uses HashMap, making documentation misleading.
} | ||
|
||
public static GlobalLinkedFileNamePatterns fromPattern(String pattern) { | ||
return new GlobalLinkedFileNamePatterns(new Pattern(pattern)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing validation for the pattern parameter before creating new Pattern object. Input parameters should be validated to fail fast.
if (preferenceFileNamePattern != null) { | ||
mainPrefsNode.put(JabRefCliPreferences.LINKED_FILE_NAME_PATTERNS_NODE, "[auth_year]"); | ||
if (prefs.hasKey(JabRefCliPreferences.IMPORT_FILENAMEPATTERN)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code violates the fail-fast principle by nesting logic inside conditional blocks instead of returning early. The nested if condition should be restructured.
@@ -68,6 +68,7 @@ public static void runMigrations(JabRefGuiPreferences preferences) { | |||
upgradeCleanups(preferences); | |||
moveApiKeysToKeyring(preferences); | |||
removeCommentsFromCustomEditorTabs(preferences); | |||
upgradeFileImportPatternToLinkedFileNamePattern(preferences, mainPrefsNode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method lacks proper JavaDoc documentation explaining the migration process, parameters, and potential side effects, which is important for complex migration operations.
To remove code duplication , The thing I am not sure about is whether the preference migration is correct or not. |
Closes #11368
This PR adds a tabular construct similar to "Key patterns" for "Linked files name" in the Linked files tab in preferences.
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)