Skip to content

Conversation

russelmrcl
Copy link
Collaborator

@russelmrcl russelmrcl commented Oct 10, 2025

Summary by CodeRabbit

  • New Features
    • Stricter validation for enum-based configuration properties: enum constants must be uppercase. Misconfigurations now fail fast with clear error messages, helping catch issues early during configuration and build-time processing.

@russelmrcl russelmrcl requested a review from rrayst October 10, 2025 10:54
Copy link
Contributor

coderabbitai bot commented Oct 10, 2025

Walkthrough

Introduces enum validation within the annotation processor: during attribute scanning, if a setter parameter is an enum, the processor checks that all enum constants are uppercase and throws IllegalArgumentException on violations.

Changes

Cohort / File(s) Summary of Changes
Annotation Processor Enum Validation
annot/src/main/java/com/predic8/membrane/annot/SpringConfigurationXSDGeneratingAnnotationProcessor.java
Added validateEnumAttribute(AttributeInfo) and validateEnumConstantsUppercase(TypeElement) and integrated enum-constant uppercase checks into attribute scanning with IllegalArgumentException on failures.

Sequence Diagram(s)

sequenceDiagram
    actor Dev as Developer Code
    participant AP as SpringConfigurationXSDGeneratingAnnotationProcessor
    participant Scan as Attribute Scanner
    participant Val as Enum Validator

    Dev->>AP: Compile/Process annotations
    AP->>Scan: Scan attributes
    loop For each attribute
        Scan->>Val: validateEnumAttribute(ai)
        alt Setter param is enum
            Val->>Val: validateEnumConstantsUppercase(enumType)
            alt All constants uppercase
                Val-->>Scan: OK
            else Non-uppercase found
                Val-->>AP: throw IllegalArgumentException
                AP-->>Dev: Fail with error
            end
        else Not an enum
            Val-->>Scan: Skip
        end
    end
    AP-->>Dev: Processing continues/succeeds
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump my feet in tidy cheer,
Enums march in uppercase gear.
If one dips low, I raise an ear—
“Up you hop!” I squeak, sincere.
Now the code meadow’s crisp and clear. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the core purpose of the changeset, which adds validation to ensure enum values use uppercase, and it clearly matches the main change without unnecessary detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch validate-enum-uppercase

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4a991b and a322ef5.

📒 Files selected for processing (1)
  • annot/src/main/java/com/predic8/membrane/annot/SpringConfigurationXSDGeneratingAnnotationProcessor.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • annot/src/main/java/com/predic8/membrane/annot/SpringConfigurationXSDGeneratingAnnotationProcessor.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (java)

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.

@membrane-ci-server
Copy link

This pull request needs "/ok-to-test" from an authorized committer.

Copy link
Contributor

@coderabbitai coderabbitai bot 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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ebfcf2 and f4a991b.

📒 Files selected for processing (4)
  • annot/src/main/java/com/predic8/membrane/annot/SpringConfigurationXSDGeneratingAnnotationProcessor.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/oauth2/authorizationservice/AuthorizationService.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/oauth2/authorizationservice/ClientAuthorization.java (1 hunks)
  • core/src/test/java/com/predic8/membrane/core/interceptor/oauth2/client/b2c/B2CMembrane.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (java)
🔇 Additional comments (6)
core/src/main/java/com/predic8/membrane/core/interceptor/oauth2/authorizationservice/ClientAuthorization.java (1)

23-24: LGTM! Enum constants now follow Java naming conventions.

The renaming from client_secret_basic and client_secret_post to uppercase follows standard Java enum naming conventions. All usages across the codebase have been updated consistently.

annot/src/main/java/com/predic8/membrane/annot/SpringConfigurationXSDGeneratingAnnotationProcessor.java (2)

438-438: LGTM! Enum validation integrated into attribute scanning.

The validation call is appropriately placed during attribute scanning to enforce uppercase enum constants at compile time.


519-531: LGTM! Proper detection of enum-typed attributes.

The logic correctly identifies when an attribute setter accepts an enum parameter by checking the parameter type and its superclass against java.lang.Enum.

core/src/test/java/com/predic8/membrane/core/interceptor/oauth2/client/b2c/B2CMembrane.java (1)

162-162: LGTM! Test updated to use the renamed enum constant.

The usage correctly references ClientAuthorization.CLIENT_SECRET_POST, aligning with the enum constant renaming.

core/src/main/java/com/predic8/membrane/core/interceptor/oauth2/authorizationservice/AuthorizationService.java (2)

78-78: LGTM! Default value updated to use the renamed enum constant.

The default initialization correctly uses ClientAuthorization.CLIENT_SECRET_BASIC, maintaining the same default behavior with the new enum naming.


258-258: LGTM! Comparison updated to use the renamed enum constant.

The conditional check correctly compares against ClientAuthorization.CLIENT_SECRET_BASIC, consistent with the enum renaming.

@russelmrcl russelmrcl merged commit 367ba34 into master Oct 10, 2025
4 of 5 checks passed
@russelmrcl russelmrcl deleted the validate-enum-uppercase branch October 10, 2025 12:46
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