Issue #18843: Indentation Check Handlers should not have reference to…#18754
Conversation
a18a792 to
d4074df
Compare
| <mutator>org.pitest.mutationtest.engine.gregor.mutators.VoidMethodCallMutator</mutator> | ||
| <description>removed call to java/util/Set::clear</description> | ||
| <lineContent>incorrectIndentationLines.clear();</lineContent> | ||
| </mutation> |
There was a problem hiding this comment.
Please do not add the pitest suppression. Instead, you can move the incorrectIndentationLines.clear() call into the clearState() method, since it serves the same purpose as the other method calls inside that method, clearState() is excluded from pitest so the mutation will not be generated and no suppression is needed.
44fb36a to
631fcca
Compare
| <param>clearState</param> | ||
| <param>logOncePerLine</param> | ||
| </excludedMethods> |
There was a problem hiding this comment.
why do we need to add logOncePerLine in the excludedMethods, i think its not needed , what pitest mutation made you do so ??
There was a problem hiding this comment.
We can not simply exclude from pitest, we need to cover by tests.
There was a problem hiding this comment.
Yes removed, from previous run VoidMethodCallMutator was there, now its not coming anymore
631fcca to
09d342e
Compare
|
@vivek-0509 , please finish review, I will review after you. |
|
@romani |
|
Goal is to avoid cycle dependencies between classes. |
|
Currently, this PR addresses the SpotBugs warning but does not remove the cyclic dependency between IndentationCheck From my overview, I think we could create an immutable context record containing all the configuration details that handlers need (basicOffset, caseIndent, throwsIndent, etc.). Handlers would use this config to perform their indentation checks. Additionally, we can have a violation context where handlers log violations into a list, then return that list. The Check would then collect these violations and log them. However, I need to think more about how to achieve this properly. |
@vivek-0509 |
|
Ok, sounds like this issue is epic, and will not be easy, but doable. Let's split it in few issues and make sure we can reliably do refactoring. For this PR, let's make special issue to describe small goal and merge this update, as step forward. |
|
@smita1078 Please create an issue for this PR (the current SpotBugs fix) so we can merge it as a step forward. We need to decide on the approach before proceding with refactoring ,will continue the discussion at #14121. |
09d342e to
9fe3060
Compare
@vivek-0509 Created issue for this PR. #18843 |
|
@vivek-0509 , please finish review |
| * <p>For use by indentation handlers in this package.</p> | ||
| * | ||
| * @see java.text.MessageFormat | ||
| * @param ast the AST node for which the error is logged | ||
| * @param key the message key describing the violation | ||
| * @param args optional arguments for the message | ||
| */ | ||
| public void indentationLog(DetailAST ast, String key, Object... args) { | ||
| if (!incorrectIndentationLines.contains(ast.getLineNo())) { | ||
| incorrectIndentationLines.add(ast.getLineNo()); | ||
| /* package */ void logOncePerLine(DetailAST ast, String key, Object... args) { | ||
| if (incorrectIndentationLines.add(ast.getLineNo())) { |
There was a problem hiding this comment.
Please revert the visibility/rename changes to indentationLog method. This PR should only fix the SpotBugs warning for the scope of issue #18843. Refctoring changes will be done separately once we agree on the approach.
ff698e1 to
3cfdf29
Compare
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
please revert any unrelated change
There was a problem hiding this comment.
Done, Sry! missed it earlier
…ference to check itself
3cfdf29 to
2d99490
Compare
|
@romani PR looks good ok to merge |
|
@vivek-0509 , please finish review |
|
@romani Already done #18754 (comment) |
|
Github, generate report for Indentation/all-examples-in-one |
|
Report for Indentation/all-examples-in-one: |
Fixes #18843
Part of #14121
Changes
UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTORwarningprivate final Set<Integer> incorrectIndentationLines = new HashSet<>()beginTree()to use clear() instead of reassignment