-
Notifications
You must be signed in to change notification settings - Fork 731
Open
Task
1 / 11 of 1 issue completed
Copy link
Labels
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:
- 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.
- Scalafmt: The official Scala code formatter, widely used for maintaining consistent code style in Scala projects.
- 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).
- Palantir Java Format: An opinionated Java code formatter from Palantir, often used for a consistent style.
- 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:
- PMD (Java): A static source code analyzer that reports on a range of potential problems, including common programming flaws, dead code, and suboptimal code.
- SpotBugs (Java): A program that uses static analysis to look for bugs in Java code. It's the spiritual successor to FindBugs.
- 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.
- Scalastyle (Scala): A style checker for Scala code, similar to Checkstyle for Java, enforcing coding conventions.
- WartRemover (Scala): A configurable code linting tool for Scala that can detect various "warts" or anti-patterns in code.
- 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:
- 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.
- 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):
- 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.
- ScalaTest (Scala): Similar to JUnit, allowing for quick execution of a subset of Scala tests.
- 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):
- GitLint: Ensures commit messages adhere to a defined format, which is crucial for good commit hygiene and automated changelog generation.
- 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.