Issue #17036: Variable os is never used#17039
Issue #17036: Variable os is never used#17039Pankraz76 wants to merge 1 commit intocheckstyle:masterfrom
os is never used#17039Conversation
3d55b9a to
6be15aa
Compare
| public void write() throws IOException { | ||
| try (OutputStream os = Files.newOutputStream(null)) { // violation, unused variable 'os' | ||
| return; | ||
| } |
There was a problem hiding this comment.
Check is right,
Maybe be input test code should be a bit more realistic to let us understand a problem.
There was a problem hiding this comment.
yes of course but its 1o1 from real world. We have test and failing production so we can fix it. Thx.
There was a problem hiding this comment.
What happens in real code if we remove unused?
I still don't see problem
6be15aa to
c1ce6f9
Compare
c1ce6f9 to
b6f734f
Compare
| try { | ||
| OutputStream os = Files.newOutputStream(null); // violation, unused variable 'os' | ||
| } catch (IOException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| try (OutputStream os = Files.newOutputStream(null)) { // violation, unused variable 'os' | ||
| System.out.println("os"); |
There was a problem hiding this comment.
[ERROR] Failures:
[ERROR] UnusedLocalVariableCheckTest.testIssue17036:589->AbstractModuleTestSupport.verifyWithInlineConfigParser:260->AbstractModuleTestSupport.verifyViolations:614 Violation lines for /home/vsts/work/1/s/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/unusedlocalvariable/InputUnusedLocalVariableIssue17036.java differ.
missing (1): 25
---
expected : [21, 25]
but was : [21]
do you mean that we missing to report violation on line 25 ? sounds like valid defect in Check , false-negative.
please prove that it missing violation by CLI, to make sure there is no other side effect affects execution
There was a problem hiding this comment.
yes have to check what you mean with CLI. the message output message is not important right?
This here is easy starter to overtake and fix.
If i cant provide maybe someone else can supplement.
There was a problem hiding this comment.
CLI https://checkstyle.sourceforge.io/cmdline.html
if you run it as shown at https://github.com/checkstyle/checkstyle/blob/master/.github/ISSUE_TEMPLATE/bug_report.md you will share all that is requried to avoid any extra conversations
|
reopen if POI |
Issue #17036: Variable
osis never usedpos: test:

neg: test:
