-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Miscellaneous refactoring #13178
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
Miscellaneous refactoring #13178
Conversation
…les and exceptions, convert ifs to switch, etc. Signed-off-by: subhramit <[email protected]>
|
@trag-bot didn't find any issues in the code! ✅✨ |
| EasyBind.subscribe(viewModel.selectedEntryTypeProperty(), type -> { | ||
| if (type != null) { | ||
| var items = type.fields(); | ||
| ObservableList<FieldViewModel> items = type.fields(); |
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 patch replaces 'var' with 'ObservableList', which is correct for type safety, but it should also consider using modern Java data structures as per best practices.
|
|
||
| public static FileFilter toFileFilter(List<String> extensions) { | ||
| var filter = toDirFilter(extensions); | ||
| Filter<Path> filter = toDirFilter(extensions); |
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 explicit type declaration 'Filter' is preferred over 'var' for clarity and type safety, aligning with modern Java best practices.
| jsonObject.put("doi", "test_doi"); | ||
|
|
||
| var dto = SciteTallyModel.fromJSONObject(jsonObject); | ||
| SciteTallyModel dto = SciteTallyModel.fromJSONObject(jsonObject); |
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 variable name 'dto' is not descriptive enough. It should include meaning or intention to improve code readability and maintainability.
| @Test | ||
| void fetchTallies() throws FetcherException { | ||
| var viewModel = new SciteTabViewModel(preferences, taskExecutor); | ||
| SciteTabViewModel viewModel = new SciteTabViewModel(preferences, taskExecutor); |
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 variable name 'viewModel' is not descriptive enough. It should include meaning or intention to improve code readability and maintainability.
|
|
||
| ConstantsPropertiesViewModel model = new ConstantsPropertiesViewModel(context, service, externalApplicationsPreferences); | ||
| var stringsList = model.stringsListProperty(); | ||
| ListProperty<ConstantsItemModel> stringsList = model.stringsListProperty(); |
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 patch replaces var with ListProperty, but the special instructions suggest using modern Java data structures, which might include using more specific types or methods like List.of().
|
|
||
| @BeforeEach | ||
| void setup() throws ParseException { | ||
| void setup() { |
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 signature should use 'throws Exception' instead of removing the exception handling to align with best practices for test methods.
|
|
||
| // The focus is on searchField node, as we click on the search box | ||
| var searchFieldRoboto = robot.clickOn(searchField); | ||
| FxRobotInterface searchFieldRoboto = robot.clickOn(searchField); |
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 variable name 'searchFieldRoboto' does not follow camel-case naming convention. It should be 'searchFieldRobot' to maintain consistency with naming standards.
|
Why are the windows unit tests taking so long? Update: finished in 33 min |
IDK. Maybe a general GitHub actions issue? |
| File[] subDirs = actualDirectory.toFile().listFiles(); | ||
| if (subDirs != null) { | ||
| String restOfFileString = StringUtil.join(fileParts, "/", index + 1, fileParts.length); | ||
| for (File subDir : subDirs) { | ||
| if (subDir.isDirectory()) { | ||
| resultFiles.addAll(findFile(entry, subDir.toPath(), restOfFileString, extensionRegExp)); | ||
| } |
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.
In a follow-up, this could be modernized, too.
- Rename to
currentDirectory(actualis IMHO a false friend) - Try to use
walkFileTree-> https://docs.oracle.com/javase/tutorial/essential/io/walk.html
Can't be done be Java newcomers as reviewing of the resulting code is too hard ^^
| LOGGER.info("Downloading LTWA file from {}.", LtwaListMvGenerator.LTWA_URL); | ||
| var in = new URI(LTWA_URL).toURL().openStream(); | ||
| var path = Files.writeString( | ||
| InputStream inputStream = new URI(LTWA_URL).toURL().openStream(); |
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.
Follow up for future: Use try with resources statement
toListandList.ofat some places where list is not modifiedletinPreviewViewerscriptMandatory checks
CHANGELOG.mddescribed in a way that is understandable for the average user (if change is visible to the user)