Skip to content

Implemented Auto-fix on project source #13

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

Merged
merged 1 commit into from
Jun 11, 2025

Conversation

Anmol202005
Copy link
Collaborator

@Anmol202005 Anmol202005 commented Jun 9, 2025

Fixes: #12
Configured the OpenRewrite plugin to run automatically during the Maven build lifecycle, so code fixes will be applied during project builds.

Additionally, implemented Git diff logic in ci.yml to flag changes detected via git diff.

Copy link
Collaborator

@timurt timurt left a comment

Choose a reason for hiding this comment

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

And one more quick question: have you tried running this updated CI? Is there a link to the executed CI jobs so we can confirm that it does exactly what we expect?

run: |
git diff --exit-code || (
echo "Code changes detected - run 'mvn clean verify' locally"
Copy link
Collaborator

Choose a reason for hiding this comment

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

i guess it is a good place to use GitHub Actions error annotation (::error::), so it can be highlighted in UI

echo "::error::Code changes detected - run 'mvn clean verify' locally"

Code changes detected - run 'mvn clean verify' locally

https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-error-message

btw I've never tried it before :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done.

pom.xml Outdated
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.11.0</version>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we store it as a property and refer to the value here?

similar to https://github.com/checkstyle/checkstyle/blob/91f3e70c6f7d6bd8f3a0a2b4a8dcdf6ca3a582fb/pom.xml#L204

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done.

@Anmol202005
Copy link
Collaborator Author

And one more quick question: have you tried running this updated CI? Is there a link to the executed CI jobs so we can confirm that it does exactly what we expect?

LGTM, when building the project mvn clean verify, the recipes are running on the project.

 <<< rewrite:6.11.0:run (checkstyle-autofix) < process-test-classes @ checkstyle-openrewrite-recipes <<<
[INFO] 
[INFO] 
[INFO] --- rewrite:6.11.0:run (checkstyle-autofix) @ checkstyle-openrewrite-recipes ---
[INFO] Using active recipe(s) [org.checkstyle.autofix.CheckstyleAutoFix]
[INFO] Using active styles(s) []
[INFO] Validating active recipes...
[INFO] Project [checkstyle openrewrite recipes] Resolving Poms...
[INFO] Project [checkstyle openrewrite recipes] Parsing source files
[INFO] Running recipe(s)...

Copy link
Collaborator

@timurt timurt left a comment

Choose a reason for hiding this comment

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

@romani romani assigned rdiachenko and unassigned timurt Jun 10, 2025
Copy link
Collaborator

@rdiachenko rdiachenko left a comment

Choose a reason for hiding this comment

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

lgtm

@rdiachenko rdiachenko merged commit 4f798b8 into checkstyle:main Jun 11, 2025
3 checks passed
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.

Run Auto-fix on project source.
3 participants