rewrite
rewrite copied to clipboard
Unused assignments should be removed
see: https://rules.sonarsource.com/java/tag/unused/RSPEC-1854
A dead store happens when a local variable is assigned a value that is not read by any subsequent instruction. Calculating or retrieving a value only to then overwrite it or throw it away, could indicate a serious error in the code. Even if it’s not an error, it is at best a waste of resources. Therefore all calculated values should be used.
Note, that this problem, "dead code analysis", among others, is one of the posterchild problems solved by representing the tree as a Control Flow Graph.
See also: https://www.cs.utexas.edu/~pingali/CS380C/2020/lectures/CFG.pdf
Going to close this for now. While we could hack something together now, a more thorough treatment requires support for dataflow analysis that we haven't yet begun to design.
Dataflow analysis is in development.