Skip to content

Conversation

abhijeetw035
Copy link
Contributor

@abhijeetw035 abhijeetw035 commented May 16, 2025

📋 Description

JIRA ID:

Previously, we were using a binary tool (xmllint) via package.json to handle XML validation. Based on feedback from the maintainer, I've replaced that setup with a Maven-based approach that integrates better with the existing project tooling.

What’s changed:

  • Added a new checkstyle.yml workflow that runs on pull requests.
  • Set up the workflow to use Java 17.
  • Removed the old xmllint configuration from package.json.
  • The workflow detects modified Java and XML files and checks them using the project’s existing checkstyle.xml.
  • It only analyzes changed files for efficiency.
  • If style violations are found, the PR is blocked from being merged.

This update removes the need for binary executables in the repo and keeps everything within the Maven ecosystem, making it cleaner and easier to maintain.


✅ Type of Change

  • 🐞 Bug fix
  • New feature
  • 🔥 Breaking change
  • 🛠 Refactor
  • ⚙️ Config change
  • 📚 Documentation
  • 🧪 Tests
  • 🎨 UI/UX
  • 🚀 Performance
  • 🧹 Chore

ℹ️ Additional Information

Summary by CodeRabbit

  • Chores
    • Updated the Checkstyle workflow to provide more detailed checks, improved caching, and clearer failure reporting.
    • Adjusted the commit lint workflow for improved dependency installation and enhanced readability.
    • Modified lint-staged configuration to run ESLint auto-fixes on TypeScript and JavaScript files only, removing CSS and HTML files from this process.

Copy link

coderabbitai bot commented May 16, 2025

Walkthrough

This update restructures the Checkstyle GitHub Actions workflow, making it self-contained with detailed steps for Java setup, file change detection, Maven caching, and explicit Checkstyle execution. The commit lint workflow now runs both npm ci and npm i with legacy peer dependencies. Lint-staged configuration in package.json now targets TypeScript and JavaScript files for ESLint auto-fixing.

Changes

File(s) Change Summary
.github/workflows/checkstyle.yml Refactored from a reusable workflow call to a detailed, self-contained job. Added explicit steps for repository checkout, JDK setup, changed file detection, Maven caching, dependency installation, targeted Checkstyle execution, and failure blocking. Updated triggers and introduced workflow_call input for Java version.
.github/workflows/commit-lint.yml Modified dependency installation to run both npm ci --legacy-peer-deps and npm i --legacy-peer-deps. Reformatted commitlint execution command for readability using line continuations.
package.json Updated lint-staged configuration: changed ESLint auto-fix targeting from src/**/*.{ts,css,html} to src/**/*.{ts,js}—removing CSS and HTML, adding JavaScript files. No other configuration changes.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub PR
    participant Checkstyle Workflow
    participant Runner (ubuntu-latest)
    participant Maven
    participant Checkstyle

    GitHub PR->>Checkstyle Workflow: PR event (opened/synchronize/reopened) or workflow_call
    Checkstyle Workflow->>Runner (ubuntu-latest): Start job
    Runner (ubuntu-latest)->>Runner (ubuntu-latest): Checkout repo, setup JDK 17
    Runner (ubuntu-latest)->>Runner (ubuntu-latest): Detect changed Java/XML files
    Runner (ubuntu-latest)->>Runner (ubuntu-latest): Cache Maven dependencies
    Runner (ubuntu-latest)->>Maven: Install dependencies (skip tests)
    alt Changed files exist
        Runner (ubuntu-latest)->>Checkstyle: Run Checkstyle on changed files
        Checkstyle-->>Runner (ubuntu-latest): Report results
        alt Checkstyle fails
            Runner (ubuntu-latest)->>Checkstyle Workflow: Mark workflow as failed, block PR
        end
    end
Loading

Poem

Hopping through workflows, a rabbit so spry,
Now Checkstyle’s sharper—on each PR we try!
Lint-staged finds JS and TS with ease,
While commit-lint installs with double the cheese.
With every hop, our code grows neat—
A garden of style, so tidy and sweet!
🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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 the configuration 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 our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Copy link

@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: 0

🧹 Nitpick comments (7)
.github/workflows/commit-lint.yml (2)

26-29: Avoid redundant dependency installation commands.

The workflow runs both npm ci --legacy-peer-deps and npm i --legacy-peer-deps. Typically npm ci is sufficient for installing locked dependencies; running npm install immediately after may be redundant and slows down CI. Consider consolidating to a single command or documenting why both are needed.


34-34: Add newline at end of file.

YAML workflows conventionally end with a newline to satisfy linters and maintain clean diffs.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 34-34: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/checkstyle.yml (5)

24-25: Remove trailing whitespace.

YAML lint flags trailing spaces on these lines; please delete the extra spaces to keep the file clean.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 24-24: trailing spaces

(trailing-spaces)


[error] 25-25: trailing spaces

(trailing-spaces)


26-31: Pin Java distribution to Temurin (optional).

Using distribution: 'adopt' still works, but the recommended alias upstream is now 'temurin'. You may future-proof this by switching to:

distribution: 'temurin'
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 31-31: trailing spaces

(trailing-spaces)


37-44: Consider a lighter Maven goal for style checks.

Running mvn install -DskipTests populates the local repo but may not be necessary for Checkstyle. A quicker alternative is:

mvn validate

or

mvn compile

which still loads Checkstyle without installing artifacts.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 37-37: trailing spaces

(trailing-spaces)


[error] 44-44: trailing spaces

(trailing-spaces)


31-31: Remove trailing whitespace.

Several lines have trailing spaces flagged by YAMLlint. Please strip these to satisfy linting rules.

Also applies to: 37-37, 44-44, 47-47

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 31-31: trailing spaces

(trailing-spaces)


63-63: Add newline at end of file.

Ensure the workflow file ends with a newline character to comply with POSIX and YAML best practices.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 63-63: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 69721e5 and 823936c.

📒 Files selected for processing (3)
  • .github/workflows/checkstyle.yml (1 hunks)
  • .github/workflows/commit-lint.yml (1 hunks)
  • package.json (2 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/commit-lint.yml

[error] 34-34: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/checkstyle.yml

[error] 12-12: trailing spaces

(trailing-spaces)


[error] 19-19: trailing spaces

(trailing-spaces)


[error] 24-24: trailing spaces

(trailing-spaces)


[error] 25-25: trailing spaces

(trailing-spaces)


[error] 31-31: trailing spaces

(trailing-spaces)


[error] 37-37: trailing spaces

(trailing-spaces)


[error] 44-44: trailing spaces

(trailing-spaces)


[error] 47-47: trailing spaces

(trailing-spaces)


[error] 63-63: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (9)
package.json (1)

15-18: Verify lint-staged patterns cover all intended file types.

The update restricts lint-staged to src/**/*.{ts,js}, removing CSS and HTML from auto-fix. Ensure CSS/HTML files are still linted or formatted elsewhere; otherwise consider adding separate patterns or workflows to cover them.

.github/workflows/commit-lint.yml (1)

32-34: Approve commitlint invocation formatting.

Splitting the --from, --to, and --verbose flags across lines increases readability and reduces risk of syntax errors. Good improvement.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 34-34: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/checkstyle.yml (7)

1-1: Clarify workflow name.

Renaming to Checkstyle makes its purpose crystal-clear in the GitHub Actions UI.


5-6: Broaden PR trigger events.

Switching to opened, synchronize, and reopened ensures style checks run on initial and updated PRs. This aligns with typical development workflows.


6-11: Enable external invocation with Java version input.

Introducing a workflow_call input (java-version) adds flexibility for downstream workflows to specify alternate JDK versions.


14-19: Enforce least-privilege permissions.

Specifying contents: read and pull-requests: write follows security best practices by limiting token scope to only what the job requires.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 19-19: trailing spaces

(trailing-spaces)


32-34: Efficient changed-file detection.

Leveraging tj-actions/changed-files@v39 with a **/*.java,**/*.xml filter ensures only relevant files are checked, speeding up CI.


48-57: Verify Checkstyle include-file syntax.

Passing -Dcheckstyle.includes=@changed_files.txt depends on the plugin’s support for @-prefixed file lists. Please confirm that this approach correctly picks up modified files; if not, you may need to read the file into a property or expand the includes on the command line.


58-63: Explicit PR blocking on failure.

Using actions/github-script to call core.setFailed with a clear message ensures that style violations halt the PR. This explicit failure handling improves developer feedback.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 63-63: no new line character at the end of file

(new-line-at-end-of-file)

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.

1 participant