Skip to content

Conversation

@subhramit
Copy link
Member

@subhramit subhramit commented May 27, 2025

  • use strict types throughout the codebase
  • convert multi-ifs to switch
  • remove some unused variables
  • remove some unused exceptions
  • fix indents
  • use toList and List.of at some places where list is not modified
  • use javascript let in PreviewViewer script

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • [/] Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • [/] Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • [/] Screenshots added in PR description (if change is visible to the user)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • [/] Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@trag-bot
Copy link

trag-bot bot commented May 27, 2025

@trag-bot didn't find any issues in the code! ✅✨

@subhramit subhramit 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 May 27, 2025
EasyBind.subscribe(viewModel.selectedEntryTypeProperty(), type -> {
if (type != null) {
var items = type.fields();
ObservableList<FieldViewModel> items = type.fields();
Copy link

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);
Copy link

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);
Copy link

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);
Copy link

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();
Copy link

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() {
Copy link

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);
Copy link

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.

@subhramit
Copy link
Member Author

subhramit commented May 28, 2025

Why are the windows unit tests taking so long?

Update: finished in 33 min

@koppor
Copy link
Member

koppor commented May 28, 2025

Why are the windows unit tests taking so long?

IDK. Maybe a general GitHub actions issue?

Comment on lines +177 to +183
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));
}
Copy link
Member

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.

  1. Rename to currentDirectory (actual is IMHO a false friend)
  2. 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 ^^

@koppor koppor added this pull request to the merge queue May 28, 2025
Merged via the queue into main with commit 4d2fd15 May 28, 2025
2 checks passed
@koppor koppor deleted the strict-types branch May 28, 2025 07:29
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();
Copy link
Member

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

@subhramit subhramit mentioned this pull request May 30, 2025
3 tasks
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 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.

4 participants