$ show nbadal/ktlint-intellij-plugin
This repository is an IntelliJ Platform plugin that integrates ktlint, the Kotlin linter, into JetBrains IDEs. It runs ktlint automatically on Kotlin files, highlights violations in the editor, provides quick fixes, and supports custom rulesets and baseline files. The plugin is built as a Gradle multi-module project with a dedicated ktlint-lib module that bundles the ktlint engine, and a ktlint-plugin module containing the IntelliJ-specific integration. It uses the IntelliJ Platform Gradle Plugin, convention plugins in build-logic, and a set of shell scripts for release and IDE compatibility checks. Architecturally, the plugin is a standard IntelliJ plugin: it registers an external annotator for real-time diagnostics, a local inspection for batch analysis, and persistent settings components for application and project configuration. It caches baseline violations to avoid re-reporting known issues and loads external ruleset JARs at runtime. The build is automated with GitHub Actions for build verification, UI tests, IDE release checks, and Gradle wrapper updates. The code is written in Kotlin and follows IntelliJ plugin best practices, with JUnit4 tests and a release pipeline that generates plugin descriptions from the README.
The LLM identified 3 files worth highlighting for reuse:
Parses and caches ktlint baseline files so violations already present in the baseline are not reported again. The class is pure Kotlin with no IntelliJ SDK dependencies, making it extractable into any ktlint tooling. It demonstrates a clean separation between file I/O, XML parsing, and in-memory caching.
Loads external ktlint ruleset JARs at runtime using a URLClassLoader, isolating third-party rules from the plugin classpath. This is a reusable pattern for any JVM application that needs to dynamically load plugins or rules. It handles classloader isolation and resource loading in a self-contained way.
A Gradle convention plugin that configures IntelliJ plugin builds, extracts the plugin description and change notes from README.md, and wires release metadata. It encapsulates non-trivial build logic that would otherwise be copy-pasted across IntelliJ plugin projects, and can be extracted into a standalone plugin for reuse.