A list of the top Java and / or Scala tools that can be wrapped as pre-commit hooks. Gemini can make mistakes, so double-check it
- Dominant language
- Java
- Stars
- 2.4k
- Forks
- 784
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 58
Description
Here are 18 top Java and/or Scala tools that can be wrapped as pre-commit hooks, categorized by their primary function:
**I. Code Formatting & Style:**
1. **Spotless:** A universal formatter that can integrate with many language-specific formatters (including Java and Scala ones). It's highly configurable and can automatically fix issues.
2. **Scalafmt:** The official Scala code formatter, widely used for maintaining consistent code style in Scala projects.
3. **Checkstyle (Java):** A highly configurable static code analysis tool used to check Java source code for adherence to coding standards (e.g., Google Java Style Guide, Sun Code Conventions).
4. **Palantir Java Format:** An opinionated Java code formatter from Palantir, often used for a consistent style.
5. **Ktlint (Kotlin, JVM Ecosystem):** While primarily for Kotlin, it's relevant in the JVM ecosystem for projects with mixed Kotlin and Java/Scala code, ensuring consistent formatting.
**II. Linting & Static Analysis:**
6. **PMD (Java):** A static source code analyzer that reports on a range of potential problems, including common programming flaws, dead code, and suboptimal code.
7. **SpotBugs (Java):** A program that uses static analysis to look for bugs in Java code. It's the spiritual successor to FindBugs.
8. **SonarLint (Java/Scala):** The IDE extension of SonarQube, providing real-time feedback on code quality and security issues. While it typically runs in the IDE, its underlying analysis engine can be leveraged for pre-commit checks.
9. **Scalastyle (Scala):** A style checker for Scala code, similar to Checkstyle for Java, enforcing coding conventions.
10. **WartRemover (Scala):** A configurable code linting tool for Scala that can detect various "warts" or anti-patterns in code.
11. **Scalafix (Scala):** A rewrite and linting tool for Scala that can perform intelligent analysis and automatically fix many issues, including refactorings.
**III. Dependency Management & Security:**
12. **OWASP Dependency-Check (Java/Scala):** A Software Composition Analysis (SCA) tool that identifies known vulnerabilities in project dependencies by analyzing their Common Platform Enumeration (CPE) identifiers.
13. **Maven Enforcer Plugin (Maven projects):** A Maven plugin that allows you to enforce various environmental constraints and best practices, including dependency convergence and banning undesirable dependencies. It can be integrated into pre-commit setups.
**IV. Testing & Code Coverage (for quick checks):**
14. **JUnit (Java):** While full test suites are usually run in CI, simple unit tests critical to the committed changes can be run via a pre-commit hook to catch immediate regressions.
15. **ScalaTest (Scala):** Similar to JUnit, allowing for quick execution of a subset of Scala tests.
16. **JaCoCo (Java):** A code coverage library for Java. A pre-commit hook could enforce a minimum coverage percentage for modified files.
**V. Other Useful Tools (General, but applicable to Java/Scala projects):**
17. **GitLint:** Ensures commit messages adhere to a defined format, which is crucial for good commit hygiene and automated changelog generation.
18. **TruffleHog/Gitleaks:** Tools for finding secrets (e.g., API keys, passwords) accidentally committed to the repository. Highly recommended as a pre-commit hook for security.
Contributor guide
Assessment
This issue has not been assessed yet.