Skip to content

Add JavaDoc for IpFilter - #136

Closed
HerrKanin wants to merge 1 commit into
mainfrom
docs/ip-filter-javadoc
Closed

Add JavaDoc for IpFilter#136
HerrKanin wants to merge 1 commit into
mainfrom
docs/ip-filter-javadoc

Conversation

@HerrKanin

@HerrKanin HerrKanin commented Feb 25, 2026

Copy link
Copy Markdown

Adds JavaDoc describing the IP filter decision rules and configuration source.
No functional changes.

Summary by CodeRabbit

  • New Features
    • Added configurable IP whitelist and blacklist support with customizable default access policy for enhanced access control.

@coderabbitai

coderabbitai Bot commented Feb 25, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The PR enhances the IpFilter class with IP access control functionality. It adds a parameterized constructor accepting explicit whitelist and blacklist sets, a no-argument constructor loading from configuration, and an isAllowed method implementing precedence-based access logic.

Changes

Cohort / File(s) Summary
IP Filter Enhancement
src/main/java/org/juv25d/filter/IpFilter.java
Added parameterized constructor for explicit whitelist/blacklist initialization with null-safe handling; added no-argument constructor loading from IpFilterConfig; added isAllowed(String ip) method implementing three-tier precedence: both lists → fallback, whitelist only → allow, blacklist only → deny, otherwise → fallback.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • jesperlarsson1910
  • SandraNelj

Poem

🐰 A filter most fine, now controls access with care,
Whitelists and blacklists with logic so fair,
IPs checked at the gate with precedence true,
Allow or deny—the firewall's debut! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title claims to add JavaDoc, but the changeset includes significant functional additions: two new constructors and a new public isAllowed() method with 37 lines added. Update the title to reflect the primary functional changes, such as 'Add IpFilter constructors and isAllowed method' or 'Implement IP filter with whitelist/blacklist logic and JavaDoc'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs/ip-filter-javadoc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/org/juv25d/filter/IpFilter.java`:
- Around line 37-45: The Javadoc comments for the IpFilter constructors and
isAllowed method are detached by stray blank lines; remove the empty line
immediately following each closing */ so the Javadoc block directly precedes the
corresponding declaration (apply to the parameterized constructor
IpFilter(Set<String> whitelist, Set<String> blacklist, boolean allowByDefault),
the no-arg constructor IpFilter(), and the isAllowed(...) method) to ensure
javadoc associates the comments with those members.
- Around line 19-25: Update the JavaDoc in class IpFilter to reflect actual
precedence used in the isAllowed method: list the "present in both lists" rule
before the individual whitelist/blacklist rules so readers see that the
both-case is evaluated first and falls back to allowByDefault; reference the
isAllowed method and the allowByDefault flag when rewording the bullets to
ensure the Javadoc matches code behavior.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5321d2 and e9ff8ee.

📒 Files selected for processing (1)
  • src/main/java/org/juv25d/filter/IpFilter.java

Comment on lines +19 to +25
* <p>Decision rules:</p>
* <ul>
* <li>If an IP is present in the whitelist, it is allowed.</li>
* <li>If an IP is present in the blacklist, it is denied.</li>
* <li>If an IP is present in both lists, {@code allowByDefault} is used.</li>
* <li>If an IP is present in neither list, {@code allowByDefault} is used.</li>
* </ul>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

JavaDoc rule ordering does not match actual precedence in isAllowed.

The list implies whitelist unconditionally takes priority (rule 1), but isAllowed checks "in both" before the pure-whitelist check (line 87 vs. line 89). A developer reading only the Javadoc would expect that a whitelisted IP is always allowed, which is incorrect when the IP also appears in the blacklist. The "both lists" case should be listed first to reflect actual code precedence.

📝 Proposed fix
  * <p>Decision rules:</p>
  * <ul>
- *     <li>If an IP is present in the whitelist, it is allowed.</li>
- *     <li>If an IP is present in the blacklist, it is denied.</li>
  *     <li>If an IP is present in both lists, {`@code` allowByDefault} is used.</li>
+ *     <li>If an IP is present in the whitelist only, it is allowed.</li>
+ *     <li>If an IP is present in the blacklist only, it is denied.</li>
  *     <li>If an IP is present in neither list, {`@code` allowByDefault} is used.</li>
  * </ul>
📝 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
* <p>Decision rules:</p>
* <ul>
* <li>If an IP is present in the whitelist, it is allowed.</li>
* <li>If an IP is present in the blacklist, it is denied.</li>
* <li>If an IP is present in both lists, {@code allowByDefault} is used.</li>
* <li>If an IP is present in neither list, {@code allowByDefault} is used.</li>
* </ul>
* <p>Decision rules:</p>
* <ul>
* <li>If an IP is present in both lists, {`@code` allowByDefault} is used.</li>
* <li>If an IP is present in the whitelist only, it is allowed.</li>
* <li>If an IP is present in the blacklist only, it is denied.</li>
* <li>If an IP is present in neither list, {`@code` allowByDefault} is used.</li>
* </ul>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/juv25d/filter/IpFilter.java` around lines 19 - 25, Update
the JavaDoc in class IpFilter to reflect actual precedence used in the isAllowed
method: list the "present in both lists" rule before the individual
whitelist/blacklist rules so readers see that the both-case is evaluated first
and falls back to allowByDefault; reference the isAllowed method and the
allowByDefault flag when rewording the bullets to ensure the Javadoc matches
code behavior.

Comment on lines +37 to 45
/**
* Creates an {@code IpFilter} with explicit configuration.
*
* @param whitelist IP addresses that should be allowed (may be {@code null})
* @param blacklist IP addresses that should be denied (may be {@code null})
* @param allowByDefault fallback decision when an IP is not listed, or listed in both sets
*/

public IpFilter(Set<String> whitelist, Set<String> blacklist, boolean allowByDefault) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Blank lines between Javadoc blocks and their declarations detach the docs from generated output.

Lines 44, 58, and 83 each introduce a blank line between the closing */ and the corresponding constructor/method declaration. The standard javadoc tool requires the comment to immediately precede the element it documents; a blank line causes the association to be silently dropped, so the generated HTML will show these members as undocumented.

📝 Proposed fix (shown for parameterized constructor; apply the same to the no-arg constructor and `isAllowed`)
     * `@param` allowByDefault fallback decision when an IP is not listed, or listed in both sets
     */
-
     public IpFilter(Set<String> whitelist, Set<String> blacklist, boolean allowByDefault) {

Also applies to: 55-59, 77-84

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/juv25d/filter/IpFilter.java` around lines 37 - 45, The
Javadoc comments for the IpFilter constructors and isAllowed method are detached
by stray blank lines; remove the empty line immediately following each closing
*/ so the Javadoc block directly precedes the corresponding declaration (apply
to the parameterized constructor IpFilter(Set<String> whitelist, Set<String>
blacklist, boolean allowByDefault), the no-arg constructor IpFilter(), and the
isAllowed(...) method) to ensure javadoc associates the comments with those
members.

@jesperlarsson1910 jesperlarsson1910 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I was under the impression that we weren't using comments, that the code "should explain" itself which is why I didn't add any javadocs in #79.

Since I'm currently working on #98 is it maybe better that I add them there? They would reflect the newest implimentation and avoids merge conflicts.

@HerrKanin

Copy link
Copy Markdown
Author

Ahaa good point i'll close this one 👍

@HerrKanin HerrKanin closed this Feb 25, 2026
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.

2 participants