Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature: URL checking#3716

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
infeo wants to merge2 commits intodevelop
base:develop
Choose a base branch
Loading
fromfeature/hyperlink-resource
Draft

Conversation

@infeo
Copy link
Member

@infeoinfeo commentedFeb 3, 2025
edited
Loading

This PR improves maintainability of the app.

Links can get stale/unreachable without the developers to notice. There are url-checker tools for this task, but we have the links cluttered all over the project, which would require to either scan the whole project (might take a long time) or to specify directories/single files, which would just move the maintenance to the ci script.

In order to reduce the number of files, this PR moves all non-api URLs to a single resource file, which is loaded during app startup. The parsing fails, if a URL is missing.

TODO:

@coderabbitai
Copy link

Walkthrough

The changes integrate URL validation and dynamic hyperlink configuration into the application. A new GitHub Actions step is added to the release-check workflow to verify URL validity across markdown and JSON files. In the codebase, a new Java record is implemented to represent hyperlinks, including methods for JSON deserialization from a dedicated JSON file containing URL mappings. A provider method in the module initializes this record, making it available as a dependency. Additionally, the controller is updated to replace a hardcoded URL with a dynamically retrieved value from the injected hyperlinks record. These modifications introduce static analysis in the CI workflow and enable the application to manage external URLs through a configuration file without altering existing functionalities.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat withCodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag@coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag@coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings togenerate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add@coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add@coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add@coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a.coderabbit.yaml file to the root of your repository.
  • Please see theconfiguration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit ourDocumentation for detailed information on how to use CodeRabbit.
  • Join ourDiscord Community to get help, request features, and share feedback.
  • Follow us onX/Twitter for updates and announcements.

Copy link

@coderabbitaicoderabbitaibot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/main/java/org/cryptomator/ui/sharevault/ShareVaultController.java (1)

24-24:Make VISIT_HUB_URL final.

Since this field is initialized in the constructor and never modified, it should be marked as final.

-private final String VISIT_HUB_URL;+private final String VISIT_HUB_URL;
.github/workflows/release-check.yml (1)

61-64:Enhance URL validation configuration.

Several improvements can be made to the URL validation step:

  1. Fix YAML syntax (extra spaces after colon)
  2. Consider adding.xml files to catch URLs in metainfo files
  3. Add retry mechanism for transient failures
-        uses:  urlstechie/urlchecker-action@0.0.34+        uses: urlstechie/urlchecker-action@0.0.34         with:-          file_types: .md,.json+          file_types: .md,.json,.xml           include_files: README.md,src/main/resources/hyperlinks.json+          retry_count: 3+          timeout: 10
🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 61-61: too many spaces after colon

(colons)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and betweencd830f2 and5d521c3.

📒 Files selected for processing (5)
  • .github/workflows/release-check.yml (1 hunks)
  • src/main/java/org/cryptomator/common/Hyperlinks.java (1 hunks)
  • src/main/java/org/cryptomator/launcher/CryptomatorModule.java (2 hunks)
  • src/main/java/org/cryptomator/ui/sharevault/ShareVaultController.java (3 hunks)
  • src/main/resources/hyperlinks.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/main/resources/hyperlinks.json
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/release-check.yml

[warning] 61-61: too many spaces after colon

(colons)

🔇 Additional comments (2)
src/main/java/org/cryptomator/common/Hyperlinks.java (1)

11-20:Consider implementing the commented-out URLs.

The commented code suggests additional URLs that might be needed. Consider implementing these URLs now to avoid future technical debt.

Would you like me to help implement these additional URL fields and update the corresponding JSON file?

src/main/java/org/cryptomator/launcher/CryptomatorModule.java (1)

27-31:LGTM!

The provider method is correctly implemented with appropriate scoping and follows dependency injection best practices.

Comment on lines +23 to +29
publicstaticHyperlinksload() {
try {
returnJSON_DESERIALIZER.readValue(Hyperlinks.class.getResource("/hyperlinks.json"),Hyperlinks.class);
}catch (IOExceptione) {
thrownewRuntimeException(e);
}
}

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve error handling and resource loading.

The current implementation has several areas for improvement:

  1. The genericRuntimeException doesn't provide enough context about the failure.
  2. Missing null check forgetResource() result.
  3. No validation of loaded URLs.

Consider this improved implementation:

 public static Hyperlinks load() {+    var resource = Hyperlinks.class.getResource("/hyperlinks.json");+    if (resource == null) {+        throw new IllegalStateException("hyperlinks.json not found in classpath");+    }     try {-        return JSON_DESERIALIZER.readValue(Hyperlinks.class.getResource("/hyperlinks.json"), Hyperlinks.class);+        var hyperlinks = JSON_DESERIALIZER.readValue(resource, Hyperlinks.class);+        validateUrls(hyperlinks);+        return hyperlinks;     } catch (IOException e) {-        throw new RuntimeException(e);+        throw new IllegalStateException("Failed to load hyperlinks.json: " + e.getMessage(), e);     } }+private static void validateUrls(Hyperlinks hyperlinks) {+    validateUrl(hyperlinks.docsVolumeType(), "docsVolumeType");+    validateUrl(hyperlinks.docsGettingStarted(), "docsGettingStarted");+    validateUrl(hyperlinks.homepageHub(), "homepageHub");+}++private static void validateUrl(String url, String field) {+    try {+        new URI(url);+    } catch (URISyntaxException e) {+        throw new IllegalArgumentException("Invalid URL in " + field + ": " + url, e);+    }+}
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
publicstaticHyperlinksload() {
try {
returnJSON_DESERIALIZER.readValue(Hyperlinks.class.getResource("/hyperlinks.json"),Hyperlinks.class);
}catch (IOExceptione) {
thrownewRuntimeException(e);
}
}
publicstaticHyperlinksload() {
+varresource =Hyperlinks.class.getResource("/hyperlinks.json");
+if (resource ==null) {
+thrownewIllegalStateException("hyperlinks.json not found in classpath");
+ }
try {
-returnJSON_DESERIALIZER.readValue(Hyperlinks.class.getResource("/hyperlinks.json"),Hyperlinks.class);
+varhyperlinks =JSON_DESERIALIZER.readValue(resource,Hyperlinks.class);
+validateUrls(hyperlinks);
+returnhyperlinks;
}catch (IOExceptione) {
-thrownewRuntimeException(e);
+thrownewIllegalStateException("Failed to load hyperlinks.json: " +e.getMessage(),e);
}
}
+privatestaticvoidvalidateUrls(Hyperlinkshyperlinks) {
+validateUrl(hyperlinks.docsVolumeType(),"docsVolumeType");
+validateUrl(hyperlinks.docsGettingStarted(),"docsGettingStarted");
+validateUrl(hyperlinks.homepageHub(),"homepageHub");
+}
+
+privatestaticvoidvalidateUrl(Stringurl,Stringfield) {
+try {
+newURI(url);
+ }catch (URISyntaxExceptione) {
+thrownewIllegalArgumentException("Invalid URL in " +field +": " +url,e);
+ }
+}

Comment on lines 21 to 22
privatestaticfinalStringSCHEME_PREFIX ="hub+";
privatestaticfinalStringVISIT_HUB_URL ="https://cryptomator.org/hub/";
privatestaticfinalStringBEST_PRACTICES_URL ="https://docs.cryptomator.org/en/latest/security/best-practices/#sharing-of-vaults";

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Move BEST_PRACTICES_URL to Hyperlinks.

For consistency with the URL management strategy, consider moving the hardcoded BEST_PRACTICES_URL to the Hyperlinks record.

Apply this change to maintain all URLs in a single location:

-private static final String BEST_PRACTICES_URL = "https://docs.cryptomator.org/en/latest/security/best-practices/#sharing-of-vaults";

And update thevisitBestPractices() method:

 @FXML public void visitBestPractices() {-    application.get().getHostServices().showDocument(BEST_PRACTICES_URL);+    application.get().getHostServices().showDocument(links.docsBestPractices()); }
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
privatestaticfinalStringSCHEME_PREFIX ="hub+";
privatestaticfinalStringVISIT_HUB_URL ="https://cryptomator.org/hub/";
privatestaticfinalStringBEST_PRACTICES_URL ="https://docs.cryptomator.org/en/latest/security/best-practices/#sharing-of-vaults";
privatestaticfinalStringSCHEME_PREFIX ="hub+";
-privatestaticfinalStringBEST_PRACTICES_URL ="https://docs.cryptomator.org/en/latest/security/best-practices/#sharing-of-vaults";
// BEST_PRACTICES_URL has been moved to the Hyperlinks dependency
// ... other class members ...
@FXML
publicvoidvisitBestPractices() {
-application.get().getHostServices().showDocument(BEST_PRACTICES_URL);
+application.get().getHostServices().showDocument(links.docsBestPractices());
}

@infeoinfeo marked this pull request as draftFebruary 3, 2025 16:30
Copy link
Member

@overheadhunteroverheadhunter left a comment

Choose a reason for hiding this comment

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

This would be a fair approach, if we had to maintain dozens of links.

However I don't think that the 2 (TWO!) links justify the added complexity. Especially given that the sheer number of different workflows and highly specific jobs is already kind of confusing.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@overheadhunteroverheadhunteroverheadhunter left review comments

@coderabbitaicoderabbitai[bot]coderabbitai[bot] left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@infeo@overheadhunter

[8]ページ先頭

©2009-2025 Movatter.jp