Skip to content

Issue #14121: removed inner Handlers reference to Check itself#19704

Open
Anushreebasics wants to merge 1 commit into
checkstyle:masterfrom
Anushreebasics:handler
Open

Issue #14121: removed inner Handlers reference to Check itself#19704
Anushreebasics wants to merge 1 commit into
checkstyle:masterfrom
Anushreebasics:handler

Conversation

@Anushreebasics

Copy link
Copy Markdown
Contributor

fixes #14121
The issue’s requirement was to remove handler dependence on public [IndentationCheck]helpers, and that has been done by making those helper methods package-private in [IndentationCheck.java]. I also updated the one cross-package test that was using the internal tab-width getter, and the focused indentation tests passed.

@Anushreebasics Anushreebasics force-pushed the handler branch 2 times, most recently from f967c02 to d0bddbc Compare April 15, 2026 15:31
@Anushreebasics

Copy link
Copy Markdown
Contributor Author

@smita1078 @romani please review

@romani

romani commented Apr 18, 2026

Copy link
Copy Markdown
Member

@vivek-0509 , what do you think about this update?

@vivek-0509

Copy link
Copy Markdown
Member

@romani As we discussed before the core problem in this issue that we need to solve is a cyclic dependency between IndentationCheck and its handler classes. Currently every handler, AbstractExpressionHandler and all its subclasses, as well as LineWrappingHandler and DetailAstSet holds a private final IndentationCheck indentCheck field and actively calls back into the Check to read configuration values (getBasicOffset(), getBraceAdjustment() etc..), to access source lines (getLine(lineNo)), to report violations (indentationLog()). At the same time IndentationCheck creates, owns, and orchestrates all these handlers. So both sides know about each other, the Check knows handlers and handlers know the Check, which is the cycle we need to break. The same cycle exists in LineWrappingHandler and DetailAstSet ,LineWrappingHandler holds IndentationCheck directly and calls getLineWrappingIndentation(), isForceStrictCondition(), getLine(), etc on it, while DetailAstSet
calls getLine() and getIndentationTabWidth() on it.

Before we write a single line of code we need to agree on a proper solution for this, since it is a big refactoring work of the most complex check we have.

@Anushreebasics if you are interested about solving this issue i would suggest you to understand the working of the indentation check then you can propose you solution and we can than discuss from there. you can also take reference from the discussion we had earlier here

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.

IndentationCheck: inner Handlers should not have reference to Check itself.

3 participants