Skip to content
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

Implement spotless gradle pre-commit hook #105

Merged
merged 12 commits into from
Oct 17, 2024

Conversation

QU3B1M
Copy link
Member

@QU3B1M QU3B1M commented Oct 15, 2024

Description

Implementation of the spotless tool to lint and format the code and a pre-commit hook to execute a spotlessCheck automatically.

Important

The pre-commit hook is applied to our local .git dir on the first run of the ./gradlew build command.

This PR also includes the generation of a root Gradle project to handle generic processes for the plugins avoiding code duplication, for now it only handles the spotless actions.

The formatting options included in this spotless implementations are:

  • License header validation
  • Google Java format conventions
  • Remove unused imports
  • Order imports following the Wazuh-indexer format
  • Trim trailing whitespaces
  • Add new lines at EOF

All these format options can be applied by running ./gradlew spotlessApply from the project's root directory.

Issues Resolved

@QU3B1M QU3B1M self-assigned this Oct 15, 2024
@QU3B1M QU3B1M linked an issue Oct 15, 2024 that may be closed by this pull request
@QU3B1M QU3B1M force-pushed the ci/104-spotless-gradle-precommit branch from 4ddd9ef to b781a96 Compare October 15, 2024 19:05
- Order build.gradle blocks
- Add spotless plugin to build.gradle
- Update formatting.gradle for both plugins
- Add license-header.txt file with the expected content of the headers
- Update formatting.gradle on both plugins to validate the license header
- Rename buildSrc directory to formatter
@QU3B1M QU3B1M force-pushed the ci/104-spotless-gradle-precommit branch from 574156a to 1f439d1 Compare October 16, 2024 18:21
…subprojects

- Move spotless-related configuration to main project directory
- Add pre-commit hook script to run spotlessCheck
- Add block on build.gradle to automatically apply pre-commit script into local .git dir
- Remove duplicated spotless-related code
@QU3B1M QU3B1M marked this pull request as ready for review October 16, 2024 21:12
@QU3B1M QU3B1M requested a review from a team as a code owner October 16, 2024 21:12
@QU3B1M QU3B1M requested a review from AlexRuiz7 October 16, 2024 22:16
Copy link
Member

@AlexRuiz7 AlexRuiz7 left a comment

Choose a reason for hiding this comment

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

LGTM

@AlexRuiz7 AlexRuiz7 merged commit c38c054 into master Oct 17, 2024
2 checks passed
@AlexRuiz7 AlexRuiz7 deleted the ci/104-spotless-gradle-precommit branch October 17, 2024 12:35
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.

Include Spotless Gradle precommit hook
2 participants