Remove never-read local variables (CodeQL java/local-variable-is-never-read)#248
Open
vharseko wants to merge 2 commits into
Open
Remove never-read local variables (CodeQL java/local-variable-is-never-read)#248vharseko wants to merge 2 commits into
vharseko wants to merge 2 commits into
Conversation
…r-read) Resolve 16 of the 18 alerts by removing local variables that are assigned but never read, across 12 files. Side effects are preserved: in IntegrityCheck both the shadowing _totalPages accumulator and its update are dropped (pure getter, result unused); the AdminUI and InspectorPanel blocks consumed no tokens read afterwards. Two alerts are intentionally left: BufferPool's reserve (a deliberate 1 MB allocation released under OutOfMemoryError) and ManagementTableModel's minWidth (its assignment consumes a StringTokenizer token a later read depends on). Verified by compiling every affected Maven module plus javac for the persistit doc and example sources.
maximthomas
approved these changes
Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves 16 of the 18 open CodeQL
java/local-variable-is-never-readalerts by removing local variables that are assigned but never read. All removals are behavior-preserving — assignments whose right-hand side has an observable side effect are handled explicitly rather than dropped blindly.Changes (12 files)
ChunkedHtml.javachunkBaseDir(×2)PngUtils.javaabsolutePathAsyncHttpClientProvider.javaproxyStrategySyncHttpClientProvider.javaproxyStrategyAsciiDoc.javasymbol(unassigned decl)IntegrityCheck.java_totalPages(shadowing accumulator + its dead update)AsciiDocIndex.javapSlash,displayText(×2)FindFile.javamodelSimpleDemo.javadoneAdminUI.javaiconNameblockInspectorPanel.javaiconNameblockManagementSlidingTableModel.javaoldRowCount,lastUpdatedRowSide-effect handling
_totalPagesshadowed a field of the same name; both the declaration and its+= …getNextAvailablePage()update are removed (the getter is pure and the field is managed separately), so the field's behaviour is unchanged.iconNameblock callsst.nextToken(), but theStringTokenizeris discarded immediately afterwards, so removing the block is unobservable.Intentionally left in place (2 alerts)
BufferPool.reserve— a deliberate 1 MB allocation that is set tonullinsidecatch (OutOfMemoryError)to free memory for error reporting; removing it would weaken OOM handling.ManagementTableModel.minWidth— its assignment consumes aStringTokenizertoken whose position a laterrendererName = st.nextToken()read depends on; removing it would shift token consumption.Verification
Compiled
commons/doc-maven-plugin,commons/http-framework/client-apache-async,commons/http-framework/client-apache-sync,commons/rest/api-descriptor,persistit/core,persistit/ui; plusjavacfor theAsciiDocIndex,FindFileandSimpleDemopersistit doc/example sources (not part of the Maven reactor).