Skip to content

Conversation

@khushikushwah
Copy link

@khushikushwah khushikushwah commented Dec 27, 2025

Closes #149

This PR introduces a new quality checker, WrongEscapeChecker, to detect suspicious escape sequences in journal full names and abbreviations.

The checker flags any backslash (\) that may indicate invalid formatting and reports findings with Severity.ERROR and code ERR_WRONG_ESCAPE. A corresponding unit test WrongEscapeCheckerTest verifies the detection logic. This helps maintain clean abbreviation data and improves quality control.


Steps to test

  1. Run WrongEscapeCheckerTest in the test suite.
  2. Confirm that entries containing suspicious escape sequences are flagged with one finding.
  3. Verify that the finding has severity ERROR and code ERR_WRONG_ESCAPE.
  4. Ensure all tests pass successfully.

✅ Example test result screenshot:
![Test result showing 1 of 1 test passed](
image

)


Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • [/] I described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • [/] I checked the user 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 updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

@github-actions
Copy link
Contributor

Hey @khushikushwah! 👋

Thank you for contributing to JabRef!

We have automated checks in place, based on which you will soon get feedback if any of them are failing. We also use Qodo for review assistance. It will update your pull request description with a review help and offer suggestions to improve the pull request.

After all automated checks pass, a maintainer will also review your contribution. Once that happens, you can go through their comments in the "Files changed" tab and act on them, or reply to the conversation if you have further inputs. You can read about the whole pull request process in our contribution guide.

Please ensure that your pull request is in line with our AI Usage Policy and make necessary disclosures.

@qodo-free-for-open-source-projects
Copy link
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🟡
🎫 #149
🔴 Verify that JabRef builds and runs correctly on Mac OS X
Ensure compatibility with Mac OS X platform before release 2.80
Ensure compatibility with Mac OS X platform before release 2.11
Address the build issues reported by SF.net user on master branch
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Missing null validation: The check method does not validate if entries parameter or individual entry fields
(full(), abbr()) are null before processing

Referred Code
public List<Finding> check(List<AbbreviationEntry> entries){
    List<Finding> findings = new ArrayList<>();
    for (AbbreviationEntry entry : entries) {
        if (ESCAPE_PATTERN.matcher(entry.full()).matches() || ESCAPE_PATTERN.matcher(entry.abbr()).matches()) {
            findings.add(new Finding(
                    Severity.ERROR,
                    code(),
                    "Suspicious escape sequence found",
                    entry

            ));
        }
    }
    return findings;

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Missing input validation: The check method accepts external data through entries parameter without validating for
null values or empty strings before regex matching

Referred Code
public List<Finding> check(List<AbbreviationEntry> entries){
    List<Finding> findings = new ArrayList<>();
    for (AbbreviationEntry entry : entries) {
        if (ESCAPE_PATTERN.matcher(entry.full()).matches() || ESCAPE_PATTERN.matcher(entry.abbr()).matches()) {

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-free-for-open-source-projects
Copy link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Remove empty, non-functional test methods

Remove the empty test methods from AbbreviationsTest.java as they serve no
purpose and reduce test suite quality.

jablib/src/test/java/org/jabref/logic/journals/AbbreviationsTest.java [27-65]

-@Test
-void getName() {
-}
+// All the empty test methods should be removed.
 
-@Test
-void getAbbreviation() {
-}
-
-@Test
-void getShortestUniqueAbbreviation() {
-}
-
-@Test
-void isDefaultShortestUniqueAbbreviation() {
-}
-
-@Test
-void getDotlessAbbreviation() {
-}
-
-@Test
-void compareTo() {
-}
-
-@Test
-void getNext() {
-}
-
-@Test
-void testToString() {
-}
-
-@Test
-void testEquals() {
-}
-
-@Test
-void testHashCode() {
-}
-
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies multiple empty test methods added in the PR, which are likely placeholders and should be removed to improve test suite quality.

Medium
Correct regex comment to match implementation

Update the comment for ESCAPE_PATTERN to accurately describe that the regex
matches any string containing a backslash, not just one followed by a
non-alphanumeric character.

jablib/src/main/java/org/jabref/logic/journals/quality/checkers/WrongEscapeChecker.java [18-19]

-//    Regex: matches any backslash followed by a non-alphanumeric character
+//    Regex: matches any string containing a backslash
 private static final Pattern ESCAPE_PATTERN = Pattern.compile(".*\\\\.*");
  • Apply / Chat
Suggestion importance[1-10]: 4

__

Why: The suggestion correctly identifies a misleading comment that misrepresents the logic of the regular expression, improving code clarity and maintainability.

Low
Learned
best practice
Remove empty test method stubs

Remove the empty test method stubs or implement them with actual test logic.
Empty test methods provide no value and can give a false sense of test coverage.

jablib/src/test/java/org/jabref/logic/quality/consistency/BibliographyConsistencyCheckResultCsvWriterTest.java [181-199]

-@Test
-void getSeverity() {
-}
+// Remove all empty test methods, or implement them with actual assertions
 
-@Test
-void getMessage() {
-}
-
-@Test
-void getFullTitle() {
-}
-
-@Test
-void getAbbreviation() {
-}
-
-@Test
-void testToString() {
-}
-
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why:
Relevant best practice - Remove empty test method stubs that have no implementation. Test methods should contain actual test logic and assertions, not be placeholders.

Low
  • More

Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be a draft PR

this(name,
abbreviation,
// "L. N." becomes "L N ", we need to remove the double spaces inbetween
// "L. N." becomes "L N ", we need to remove the double spaces in between
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the code is not necessary any more if the comment is changed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please tell me what I should do next with this code. Do I need to redo it.

Comment on lines 264 to 267
requires kotlin.stdlib;
requires mslinks;
requires org.antlr.antlr4.runtime;
requires org.jooq.jool;
requires org.libreoffice.uno;
requires transitive org.jspecify;
requires org.junit.jupiter.api;
requires kotlin.stdlib;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Which AI did you use?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's my first time to contribute to the open-source projects, as a beginner I used to learn how I work on this. I used Microsoft copilot to assist me to writing the code and commit messages


@BeforeEach
void setUp() {
void setUp() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Comment on lines +27 to +65
@Test
void getName() {
}

@Test
void getAbbreviation() {
}

@Test
void getShortestUniqueAbbreviation() {
}

@Test
void isDefaultShortestUniqueAbbreviation() {
}

@Test
void getDotlessAbbreviation() {
}

@Test
void compareTo() {
}

@Test
void getNext() {
}

@Test
void testToString() {
}

@Test
void testEquals() {
}

@Test
void testHashCode() {
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfinished?

@koppor koppor marked this pull request as draft December 27, 2025 14:17
@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 27, 2025
@koppor
Copy link
Member

koppor commented Dec 27, 2025

@khushikushwah UI?

Maybe guide your AI more. Thank you.

- Implemented WrongEscapeChecker to flag suspicious backslashes in journal names/abbreviations
- Added WrongEscapeCheckerTest to verify detection logic
- Introduced supporting classes: AbbreviationEntry, Checker, Finding, Severity
- Integrated checker into quality checking framework
@khushikushwah khushikushwah force-pushed the add-wrong-escape-checker branch from dcad84c to 721fc78 Compare December 29, 2025 10:16
@khushikushwah
Copy link
Author

I reformate the code. but it still shown some error. how I solve these errors please tell me.

khushikushwah and others added 5 commits December 30, 2025 15:50
- Implemented WrongEscapeChecker to flag suspicious backslashes in journal names/abbreviations
- Added WrongEscapeCheckerTest to verify detection logic
- Introduced supporting classes: AbbreviationEntry, Checker, Finding, Severity
- Integrated checker into quality checking framework
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 30, 2025
@jabref-machine
Copy link
Collaborator

Your code currently does not meet JabRef's code guidelines. IntelliJ auto format covers some cases. There seem to be issues with your code style and autoformat configuration. Please reformat your code (Ctrl+Alt+L) and commit, then push.

In special cases, consider using // formatter:off and // formatter:on annotations to allow deviation from the code style.

@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Currently broken on Mac OS X?

3 participants