Skip to content

Remove second "Citation key" column from the Consistency check results table.#12699

Merged
subhramit merged 10 commits into
JabRef:mainfrom
Paras-Gupta16:fix-consistency-check
Mar 16, 2025
Merged

Remove second "Citation key" column from the Consistency check results table.#12699
subhramit merged 10 commits into
JabRef:mainfrom
Paras-Gupta16:fix-consistency-check

Conversation

@Paras-Gupta16

@Paras-Gupta16 Paras-Gupta16 commented Mar 12, 2025

Copy link
Copy Markdown
Contributor

Closes #12697

This PR remove the second "Citation key" column from the Consistency check results table.

Mandatory checks

  • I own the copyright of the code submitted and I licence 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 (for UI changes)
  • 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.

@Paras-Gupta16 Paras-Gupta16 changed the title fix-consistency-check Remove second "Citation key" column from the Consistency check results table. Mar 12, 2025

@github-actions github-actions Bot left a comment

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.

Your code currently does not meet JabRef's code guidelines. We use Checkstyle to identify issues. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues.
In case of issues with the import order, double check that you activated Auto Import. You can trigger fixing imports by pressing Ctrl+Alt+O to trigger Optimize Imports.

Comment on lines +146 to +147

removeColumnByTitle(InternalField.KEY_FIELD.getName());

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.

At least, there should be a Java comment why this can be removed. (You can say that this is already displayed in the first column. But then, you need to somehow point in the coude where it is added)

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.

Maybe, this column should be removed from the viewModel in the first place?

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.

Yes, this is more of a hotfix. @Paras-Gupta16 please investigate the cause and fix the bug there.

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.

On debugging the viewmodel class the getColumnNames() method returns a string. This can be done by deleting the column by manipulating the string.

Another thing is code is already written 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.

I took a look. Some hints:
The function you mention returns a list of strings. If by "deleting the column by manipulating the string" you mean removing result.add("Citation Key");, that will not work as it will remove the first Citation key column. One way is either making the second one functional and removing the first, or keeping the first and putting a filter such that in the section:

allReportedFields.forEach(field -> {
            result.add(field.getDisplayName());
        });

field.getDisplayName() is added only if it is not equal to Citation Key.
Not letting the column be generated is better than generating it and then removing it - the latter is more expensive - so the current solution has to be changed to one of the above.
What do you think would be better? @priyanshu16095

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.

Not letting the column be generated is better than generating it and then removing it - the latter is more expensive - so the current solution has to be changed to one of the above.

Yeah, I also learned from this point.
Firstly, as he commented, "the code is already there," I thought this was more appropriate.

A simple check can be added, and tableData and writeBibEntry should also be checked.

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.

Removed it in class before creating the table.

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.

Why is this line still needed then?

@koppor

koppor commented Mar 12, 2025

Copy link
Copy Markdown
Member

@priyanshu16095 Can you review, too, please?

@priyanshu16095

Copy link
Copy Markdown
Contributor

Sure, I will.

@priyanshu16095

Copy link
Copy Markdown
Contributor

I have a thought after this task: the results from the GUI and CLI will be different? Should this also be done for the CLI

@koppor

koppor commented Mar 12, 2025

Copy link
Copy Markdown
Member

I have a thought after this task: the results from the GUI and CLI will be different? Should this also be done for the CLI

If it is about the citatoin key column removal: Yes, please. Then, the CLI is also wrong. -- Which means, the input data is wrong?


Regarding the other columns (#12696), my thoughts are (but you haven'T ask for it)

The CLI has a complete table of all types - and one cannot filter.

The GUI shows a single type - and not all types together. The GUI should be compact. Thus, removing columns is OK there.

});
return result;
allReportedFields.forEach(field-> result.add(field.getDisplayName().trim()));
return new ArrayList<>(result);

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.

The new ArrayList should not be returned. Modify the methods to use the set instead.

Also fix the check.

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.

Done

public Set<String> getColumnNames() {
Set<String> result = new LinkedHashSet<>(columnCount + EXTRA_COLUMNS_COUNT);
result.add("Entry Type");
result.add("Citation Key");

@priyanshu16095 priyanshu16095 Mar 14, 2025

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 rename it to "CitationKey" as it is used in InternalField. Otherwise the column will not be removed.

@priyanshu16095

Copy link
Copy Markdown
Contributor

@trag-bot

trag-bot Bot commented Mar 15, 2025

Copy link
Copy Markdown

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

@priyanshu16095

Copy link
Copy Markdown
Contributor

Tried it, works fine!

Comment on lines +98 to +99
public Set<String> getColumnNames() {
Set<String> result = new LinkedHashSet<>(columnCount + EXTRA_COLUMNS_COUNT);

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.

Neat

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.

@subhramit

Copy link
Copy Markdown
Member

@priyanshu16095 Thank you for reviewing!

@subhramit subhramit added this pull request to the merge queue Mar 16, 2025
Merged via the queue into JabRef:main with commit f8f5a38 Mar 16, 2025
GuilhermeRibeiroPereira pushed a commit to GuilhermeRibeiroPereira/jabref that referenced this pull request Apr 1, 2025
…s table. (JabRef#12699)

* fix-consistency-check

* Add import statement

* Remove 'CitationKey' column from table

* Use set

* Update Checkstyle

* Update checkstyle check

* rename variable

* Correct checkstyle

* Correct checkstyle

* Fix fail fast principle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix double citation key in "Check consistency"

4 participants