-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Support RFC links in Quick Import functionality (#11949) #12043
Support RFC links in Quick Import functionality (#11949) #12043
Conversation
return Optional.empty(); | ||
} | ||
|
||
public boolean isValid() { |
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.
Why only plain and not with URL?
Add JavaDoc comment!
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.
Hi, maybe I understand something wrong, so I don't need to match plain in this part, but only need to match URLs in this format("https://www.rfc-editor.org/rfc/" + rfc7276.html#section-2.2.2)?
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.
Can the modified part meet your requirements?
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.
Hi, maybe I understand something wrong, so I don't need to match plain in this part, but only need to match URLs in this format("https://www.rfc-editor.org/rfc/" + rfc7276.html#section-2.2.2)?
You do nlt match the URL at all there. therefore I wondered.
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.
Because I was worried that there might be other formats of URLs, I considered just matching the format of rfc****.
My mistake. I am really sorry for causing you trouble.
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 is nowhere used. REmove.
If you would implement it correctly, you need to have to check both the URL and just the ID.
} | ||
} | ||
|
||
@Override |
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.
I think, neither equals nor hashCode need to be overriden.
Just remove that code.
There is also a logic error, because Id is stored lower case and the equals also converts loeer case (unnecessarily)
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.
Thank you for pointing this out! I have removed the overridden equals
and hashCode
methods as suggested. Please let me know if there's anything else you'd like me to adjust.
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.
Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
You can check review dog's comments at the tab "Files changed" of your pull request.
Add JavaDoc comments Remove unnecessary lowercase
Add JavaDoc comments Remove unnecessary lowercase
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.
Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
You can check review dog's comments at the tab "Files changed" of your pull request.
Hello, I have modified my code style, I think there should be no problem, can you test my PR again? |
- Removed RFC entry from identifier list(StandardField.java) - Modified RfcId class to extend EprintIdentifier
…link' into Issue11949-quick-import-for-RFC-link
According to CI test feedback:
|
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.
Tests for RfcId class missing.
Both rfc7276
and URLs ´https://www.rfc-editor.org/rfc/rfc7276.html` need to be supported
* Represents an RFC identifier, which can be used to fetch bibliographic information about the RFC document. | ||
* This class supports both plain RFC IDs (e.g., "rfc7276") and full URLs (e.g., "https://www.rfc-editor.org/rfc/" + rfc****.html). | ||
*/ | ||
public class RfcId extends EprintIdentifier { |
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.
Name this class RFC
- to be consistent with the other classes in that package.
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.
-
Thank you for the feedback. I have renamed the class to RFC for consistency with the other classes in the package. The class now follows the naming conventions as requested.
-
I have removed the unused method(isValid) as suggested.
-
I have implemented additional test cases in RFCTest.java to verify that the new RFC class handles both plain RFC IDs (e.g., rfc7276) and URLs (e.g., https://www.rfc-editor.org/rfc/rfc7276.html).
return Optional.empty(); | ||
} | ||
|
||
public boolean isValid() { |
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 is nowhere used. REmove.
If you would implement it correctly, you need to have to check both the URL and just the ID.
- Replaced RfcId name with RFC class for consistency and clarity. - Updated RFC parsing logic to support both plain RFC IDs (e.g., "rfc7276") and full URLs (e.g., "https://www.rfc-editor.org/rfc/rfc7276.html"). - Added tests in RFCTest to validate proper parsing of RFC identifiers from both formats. - Removed unnecessary method (isValid) improved code clarity. - Adjusted the CompositeIdFetcher to integrate the new RFC class functionalities.
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.
Some small comments on the test.
class RFCTest { | ||
|
||
@Test | ||
void testParsePlainRfcId() { |
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.
Convert to @ParameterizedTest
.You can use @CsvSource
. Left: excpected
, right: input.
Use assertEquals(expected, new RFC(input).getNormlized()
.
Also the next test case.
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.
Converted testParsePlainRfcId
to a @ParameterizedTest
using @CsvSource
(done)
- Updated
testGetExternalUri
to verify the URI usingOptional.of()
for consistent checks.
@Test | ||
void testInvalidRfc() { | ||
Optional<RFC> rfc = RFC.parse("invalidRfc"); | ||
assertFalse(rfc.isPresent()); |
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.
assertFalse(rfc.isPresent()); | |
assertEquals(Optional.empty, rfc); |
If something is wrong, the diff can be investigated.
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.
Adjusted testInvalidRfc
to use assertEquals(Optional.empty(), rfc)
.(done)
Optional<URI> uri = rfc.getExternalURI(); | ||
assertTrue(uri.isPresent()); | ||
assertEquals("https://www.rfc-editor.org/rfc/rfc7276", uri.get().toString()); |
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.
Optional<URI> uri = rfc.getExternalURI(); | |
assertTrue(uri.isPresent()); | |
assertEquals("https://www.rfc-editor.org/rfc/rfc7276", uri.get().toString()); | |
assertEquals(Optional.of("https://www.rfc-editor.org/rfc/rfc7276"), rfc.getExternalURI()); |
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.
Updated testGetExternalUri
to verify the URI using Optional.of()
for consistent checks.(done)
- Converted `testParsePlainRfcId` to a `@ParameterizedTest` using `@CsvSource`. - Adjusted `testInvalidRfc` to use `assertEquals(Optional.empty(), rfc)`. - Updated `testGetExternalUri` to verify the URI using `Optional.of()` for consistent checks.
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.
Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
You can check review dog's comments at the tab "Files changed" of your pull request.
"rfc7276, rfc7276", | ||
"https://www.rfc-editor.org/rfc/rfc7276.html, rfc7276" | ||
}) | ||
void testParseValidRfcIdAndUrl(String input, String expected) { |
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.
Please be consistent.
assertEquals first gets expected, thus please, first expected
then input
I fix it for myself. Too much context switches.
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.
OK for me now.
…link' into Issue11949-quick-import-for-RFC-link
@ChengPuPu Thank you for the follow up. I was about to open the PR in my IDE and fix it for myself. |
BTW: No need to disable automerge. Automerge happens if the required workflows run successfully. |
@koppor Thank you very much for your patience and guidance. I have learned a lot about code management through this experience. Thank you very much. |
Purpose
See #11949
This PR addresses Issue #11949, which requested support for importing RFC using url links in the quick import feature of JabRef.
Changes Made
Enhanced CompositeIdFetcher to Recognize Rfc URL Links:
CompositeIdFetcher
class to support RFC document URLs.https://www.rfc-editor.org/rfc/rfc7276.html
) and extract the RFC ID correctly, even if the URL contains a section fragment (e.g.,#section-2.2.2
).Updated Identifier Handling:
CompositeIdFetcher
to detect URLs containing "rfc" and extract relevant RFC identifiers.performSearchById
method to correctly identify and handle RFC URLs without needing a separate importer.How the Issue is Solved
CompositeIdFetcher
class to include logic that can extract RFC identifiers from URLs and proceed with the import. This allows users to directly paste RFC URLs into the quick import field, and JabRef will successfully parse and import the relevant RFC entry.Notes
https://www.rfc-editor.org
. If users encounter other RFC sources, further enhancement might be needed.Please review these changes, and let me know if there are any adjustments or additional enhancements required. Feedback is highly appreciated to ensure the solution meets user expectations effectively.