1.5 KiB
1.5 KiB
name, description
| name | description |
|---|---|
| java-best-practices | Use when writing or reviewing Java production code in this plugin, especially HTTP, validation, lifecycle, concurrency, or error handling. |
Java best practices
- Compile with Java 17 (
maven.compiler.release=17), the baseline supported by the target plugin API. - Prefer immutable records for internal DTOs where compatible with JSON parsing; keep collections defensively copied.
- Validate null, length, and format at service boundaries. Use named constants for bounds and timeouts.
- Use try-with-resources for closeable resources;
java.net.http.HttpClientis reusable and immutable. - Do not create static mutable state, swallow exceptions, catch
Throwable, or catch broadExceptionwithout translating a known boundary failure. - Keep errors actionable but never include authorization headers, tokens, or full secret-bearing URLs.
- Use SLF4J host-provided logging; log operation context without credentials.
- Keep packages under
cc.tordais.sonar.bifrost; name types and methods in ASCII English.
Checklist
- Java 17 compilation; immutable data and bounded inputs.
- Exceptions translated at boundaries, not hidden.
- No static mutable state or secret-bearing logs.
- Resources and HTTP timeouts handled.
Sources
- SonarQube API JDK baseline: https://github.com/SonarSource/sonar-plugin-api (consulted 2026-10-28)
- Java 17 API documentation: https://docs.oracle.com/en/java/javase/17/docs/api/ (consulted 2026-10-28)
Not verified
- No project-specific Sonar quality profile has been run yet.