Skip to content

Repository files navigation

quench

A fast Java formatter, import organizer, and linter.

Warning

Alpha software — not ready for production use. quench is early and moves fast; expect breaking changes, rough edges, and gaps. I currently use it only on my own internal projects and make no stability or support guarantees. Try it out and file issues, but don't put it in a critical build pipeline yet.

The aim is a complete Java quality gate that needs no JVM: one tool that is the local runner and the CI gate, with identical results. No javac, no embedded JVM — but type-aware where it can be, JVM-free (a lite, deliberately-unsound resolver that stays silent whenever it's unsure). You shouldn't have to run quench and Sonar.

Installation

curl --proto '=https' --tlsv1.2 -LsSf \
  https://github.com/goalves/quench/releases/latest/download/quench-installer.sh | sh

See INSTALL.md for Windows, pinning a version, CI usage, and building from source.

Usage

quench format [paths...]           # rewrite files in place
quench format --check [paths...]   # exit non-zero if any file would change (CI)
quench format --verify-output [paths...]  # re-parse each result as a safety check (slower)

quench check  [paths...]           # run lint rules, report diagnostics
quench check  --fix                # apply safe autofixes (--unsafe also applies behaviour-changing ones)
quench check  --classpath a.jar:b  # let typed rules see external types (bytecode parsed, never run)
quench check  --baseline main      # only report findings on lines changed vs a git ref ("new code")
quench check  --format json|sarif  # machine-readable output (SARIF → GitHub Code Scanning)

quench lsp                         # run as a Language Server over stdio (editor integration)

Editor integration

quench lsp speaks LSP over stdin/stdout: live diagnostics, document formatting, and quick-fixes from the same engine the CLI runs — what you see in the editor is what the gate enforces. Point any LSP client at the quench lsp command for .java files. (Neovim example: vim.lsp.start({ name = "quench", cmd = { "quench", "lsp" }, root_dir = vim.fn.getcwd() }).) It currently serves the per-file rule pass plus the formatter; cross-file/semantic rules are CLI-only for now.

Exit codes: 0 clean · 1 blocking findings (only error-severity fails) · 2 internal/parse error.

Configuration

quench.toml, resolved from the repository root (nearest .git ancestor), so local and CI pick the same config no matter where you run it:

line_width = 100

[format]
indent = 4

[imports]
groups = ["java", "javax", "", "com.mycompany"]  # "" = everything else

[rules]
no-empty-catch = "error"                          # promote to blocking
cognitive-complexity = { level = "warn", threshold = 15 }

Inline // quench:ignore [rule, ...] comments suppress findings on a line.

Documentation

Releasing

The version lives in [workspace.package].version in Cargo.toml, and the git tag must match it. Pushing the tag runs .github/workflows/release.yml, which builds every target and cuts the GitHub Release.

# stable: bump the version in Cargo.toml and commit first, then:
git tag v0.1.0 && git push origin v0.1.0

# pre-release: use a -alpha.N / -beta.N / -rc.N suffix on the version AND the tag.
# dist marks it as a Pre-release, so `releases/latest` still points at the last stable.
git tag v0.1.0-alpha.4 && git push origin v0.1.0-alpha.4

Preview a release locally with dist plan. Full details, including the installer URLs testers use for pre-releases, are in INSTALL.md.

Workspace layout

Crate Purpose
crates/quench-core tree-sitter parsing, CST wrappers, spans, config types
crates/quench-format Wadler/Prettier-style doc IR + width-aware printer
crates/quench-lint rule engine, type resolver, and built-in rules
crates/quench the quench binary: discovery, orchestration, reporting

test-data/ holds sample .java files and golden formatter outputs.

Development

Uses just:

just ci      # everything CI runs: fmt-check, clippy -D warnings, test, cargo-deny
just test    # cargo test --workspace
just bench   # criterion micro-benchmarks

License

MIT © Gabriel Alves

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages