Issue #146: Add recipe for UnusedImports#151
Issue #146: Add recipe for UnusedImports#151Aman-Baliyan wants to merge 1 commit intocheckstyle:mainfrom
Conversation
5eca39d to
2fe7bd1
Compare
|
@romani sir, please review |
|
I don't see test for suppressed violation, we should not remove import |
okay i will add them |
|
Our philosophy is: user have full right to suppression violations anywhere for any reason. We aupfix what is market as violation, we do not touch what user do not want to be changed |
Done added example with suppression |
| public J.CompilationUnit visitCompilationUnit(J.CompilationUnit cu, | ||
| ExecutionContext executionContext) { | ||
|
|
||
| this.sourcePath = cu.getSourcePath(); |
There was a problem hiding this comment.
cu --> compileUnit, compilationUnit
|
|
||
| private boolean isAtViolationLocation(J.Import literal) { | ||
|
|
||
| final String message = createMessage(literal); |
There was a problem hiding this comment.
strange that we rely on message ....
it can be changed by user or be in non English.
why you isAtViolationLocation is so different from:
There was a problem hiding this comment.
i think to not match the violation on the basis of line and column basically what i did is extract each import from lst and match that import with violation message import but as suggested by you that the language is a problem.
so i will try to implement by line or column number
There was a problem hiding this comment.
Let's do as all other for now, ones we get better model, we will refactor all at ones
There was a problem hiding this comment.
my exams are going on i will continue this after my exams
Issue: #146
Check: https://checkstyle.sourceforge.io/checks/imports/unusedimports.html#UnusedImports
This pr implements a new Recipe for UnusedImportCheck of checkstyle.