Skip to content

feat(plugins): incremental linter with Hibernate eager bootstrap and JSON metrics reporting - #95

Merged
yannickebongue merged 3 commits into
mainfrom
feature/missing-parameter-linter-task
Oct 22, 2026
Merged

yannickebongue merged 3 commits into
mainfrom
feature/missing-parameter-linter-task

Conversation

@yannickebongue

Copy link
Copy Markdown
Contributor

Summary

Refactor the lintNamedQueries Gradle task to delegate deep JPQL/HQL semantic validation to
Hibernate's eager SessionFactory bootstrap, introduce incremental compilation support via
source-level delta tracking, and produce a structured JSON execution metrics report.

This PR modifies 11 files in the plugins module across three focused commits.


Changes

Hibernate Eager Bootstrap Delegation (0b4e90d)

  • LintNamedQueriesWorker no longer manually iterates over discovered queries/procedures
    for ANTLR4 validation inline. Instead, semantic query validation is delegated to Hibernate's
    eager query validation observer during SessionFactory bootstrap.
  • Extracted Helper.validateDiscoveredQueries() and Helper.validateDiscoveredStoredProcedures()
    static methods to encapsulate query and stored procedure validation loops with proper error
    counting and parameter naming style governance.
  • The NamedObjectParser is wrapped in a withCloseable block to ensure proper Hibernate
    SessionFactory resource cleanup and prevent classloader leaks on TestKit daemons.
  • Functional tests updated to use regex-based stacktrace extraction for asserting
    NamedQueryValidationException type and error attribute matrix size.

Incremental Source Tracking Refactoring (c36f253)

  • LintNamedQueries task replaces the ConfigurableFileTree (compiledClasses) input with
    a DirectoryProperty (compiledClassesDir) and introduces a dedicated ConfigurableFileCollection
    (sourceFiles) annotated with @Incremental for source-level .java file change tracking.
  • Source-level file changes are translated to their corresponding .class bytecode counterparts
    during incremental passes, so only affected classes are routed through the ASM sweep.
  • Added @OutputFile lintReportFile property for a JSON execution metrics report
    (timestamp, incremental status, detected files, error count), routed to
    build/reports/lintNamedQueries/validation-report.json for Gradle cache compatibility.
  • Plugin registration updated: wires sourceFiles from java.sourceSets.main with build
    directory exclusion filter; replaces dependsOn(compileJava) with mustRunAfter(compileJava).
  • Functional tests simplified by reusing a shared GradleRunner instance.

Tenant Profile Token Assertion (9efc65e)

  • SchemaValidationWorker adds a precondition assertion verifying that the parsed tenant
    profile token array contains more than 3 elements before accessing individual fields,
    preventing a potential ArrayIndexOutOfBoundsException on malformed input.

Documentation

  • plugins/README.md updated: version bump to 1.7.0, plugin description reflects incremental
    linting and JSON metrics, architecture tree updated.
  • jakarta-plugin.adoc updated with incremental compilation details, new task properties
    (compiledClasses, lintReportFile), and withCloseable resource management notes.
  • overview.html release notes added for v1.7.0 features.
  • Package-level Javadoc updated across plugin, task, and worker packages.

How to Verify

  1. Run the functional test suite:
    ./gradlew :plugins:persistence-gradle-plugin-functional-test:functionalTest
  2. Apply the plugin to a sample project, run lintNamedQueries twice, and confirm the second
    run performs an incremental pass (check console output and the generated JSON report).
  3. Verify that no Hibernate SessionFactory leak warnings appear in daemon logs.

…ootstrap

- Refactor `JakartaNamedObjectParser` to instantiate the Hibernate `SessionFactory`
  exactly once during the `from()` factory bootstrap phase.
- Streamline `LintNamedQueriesWorker` to delegate deep JPQL syntax and placeholder
  checks to Hibernate's eager query validation observer.
- Focus the worker task's responsibility exclusively on bytecode annotation sweeping,
  parameter name style governance, and task coordination.
- Update the Spock functional testing suite to utilize regex stacktrace extraction
  for asserting the root `NamedQueryValidationException` type and error attribute matrix size.
- Ensure all resources are cleanly disposed of via try-with-resources blocks to prevent
  persistent classloader leaks on TestKit daemons.
…nd separate incremental source tracking

Replace the compiled classes input from a ConfigurableFileTree
(compiledClasses) to a DirectoryProperty (compiledClassesDir) and
introduce a dedicated ConfigurableFileCollection (sourceFiles) for
incremental source file change tracking.

- Switch @incremental annotation from compiled classes to source files
  so delta tracking operates on .java inputs instead of .class outputs
- Translate source-level file changes to their bytecode counterparts
  during incremental passes
- Add build directory exclusion filter when wiring source files in the
  plugin registration
- Remove explicit dependsOn for compileJava in favor of mustRunAfter
- Simplify functional test runner setup by reusing shared GradleRunner
  instance
…xing

Add a precondition assertion in SchemaValidationWorker to verify that
the parsed tenant profile token array contains more than 3 elements
before accessing individual fields, preventing potential
ArrayIndexOutOfBoundsException on malformed input.
@yannickebongue yannickebongue self-assigned this Oct 22, 2026
@yannickebongue yannickebongue added bug Something isn't working performance Improves build execution speeds, task caching, and incremental processing velocity. plugins Gradle plugin wrappers (Gradle Plugin Portal artifacts) labels Oct 22, 2026
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'persistence-plugins'

Failed conditions
70.1% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@yannickebongue yannickebongue linked an issue Oct 22, 2026 that may be closed by this pull request
1 task
@yannickebongue
yannickebongue merged commit c01c6a5 into main Oct 22, 2026
3 of 4 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in JPersist Core Roadmap Oct 22, 2026
@yannickebongue
yannickebongue deleted the feature/missing-parameter-linter-task branch October 22, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working performance Improves build execution speeds, task caching, and incremental processing velocity. plugins Gradle plugin wrappers (Gradle Plugin Portal artifacts)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEAT] Automated @NamedQuery Missing Parameter Scanner

1 participant