8000 feat: report Java deep nesting from PMD by renanfranca · Pull Request #161 · habit-hooks/habit-hooks · GitHub
[go: up one dir, main page]

Skip to content

feat: report Java deep nesting from PMD - #161

Closed
renanfranca wants to merge 1 commit into
habit-hooks:mainfrom
renanfranca:java-nesting-160
Closed

renanfranca wants to merge 1 commit into
habit-hooks:mainfrom
renanfranca:java-nesting-160

Conversation

@renanfranca
Copy link
Copy Markdown
Contributor

What this changes

Java projects can now report the existing deep-nesting smell through PMD's
AvoidDeeplyNestedIfStmts
rule.

Projects without their own PMD ruleset receive the rule from the bundled
fallback. A project-owned ruleset remains authoritative and is never combined
with the bundled one.

Why problemDepth=3

The bundled ruleset pins problemDepth=3: the first and second nested if
statements are accepted, and the third is reported.

Although 3 is currently PMD's default, keeping it explicit prevents a future
PMD release from silently changing Habit Hooks behavior.

This deliberately does not try to match TypeScript's max-depth: 4
numerically. PMD counts nested if statements specifically; for, while,
try, and other blocks do not increase this depth. The two plugins therefore
keep deterministic contracts that reflect what their underlying tools measure.

Why the documentation and tests changed

The smell vocabulary previously described deep-nesting as TypeScript-only.
It now records Java support and the PMD rule-to-smell mapping.

The Java plugin specification is also executable documentation: its examples
run the real habit-sensors → Java sensor → PMD path. It now demonstrates the
depth boundary and confirms that project-owned rulesets still take precedence.

Finally, the installed-plugin test includes a nested Java fixture so the built
wheel proves that the bundled ruleset is packaged, active, and able to produce
the canonical finding without access to the source tree.

Verification

  • Java acceptance and focused tests: 36 passed
  • Installed-plugin packaging tests: 3 passed, 1 PHP-only skip
  • Non-PHP suite: 958 passed, 5 skipped
  • Ruff and Habit checks: clean

Any feedback is very welcome, especially on the problemDepth=3 choice and how
this Java-specific boundary is described.

Closes #160

@devill
devill commented Sep 5, 2026
Copy link
Copy Markdown
Collaborator

PR merged! Thanks for making the review easy :)

@devill devill closed this Sep 5, 2026
@renanfranca
Copy link
Copy Markdown
Contributor Author

PR merged! Thanks for making the review easy :)

I am glad that you enjoyed, I'll keep that way. Thank you 😀👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Java deep-nesting detection using PMD AvoidDeeplyNestedIfStmts

2 participants

0