Skip to content

Remove never-read local variables (CodeQL java/local-variable-is-never-read)#248

Open
vharseko wants to merge 2 commits into
OpenIdentityPlatform:masterfrom
vharseko:features/codeql-local-var-never-read
Open

Remove never-read local variables (CodeQL java/local-variable-is-never-read)#248
vharseko wants to merge 2 commits into
OpenIdentityPlatform:masterfrom
vharseko:features/codeql-local-var-never-read

Conversation

@vharseko

@vharseko vharseko commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary

Resolves 16 of the 18 open CodeQL java/local-variable-is-never-read alerts 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)

File Module Removed
ChunkedHtml.java commons/doc-maven-plugin chunkBaseDir (×2)
PngUtils.java commons/doc-maven-plugin absolutePath
AsyncHttpClientProvider.java commons/http-framework proxyStrategy
SyncHttpClientProvider.java commons/http-framework proxyStrategy
AsciiDoc.java commons/rest/api-descriptor symbol (unassigned decl)
IntegrityCheck.java persistit/core _totalPages (shadowing accumulator + its dead update)
AsciiDocIndex.java persistit/doc pSlash, displayText (×2)
FindFile.java persistit/examples model
SimpleDemo.java persistit/examples done
AdminUI.java persistit/ui iconName block
InspectorPanel.java persistit/ui iconName block
ManagementSlidingTableModel.java persistit/ui oldRowCount, lastUpdatedRow

Side-effect handling

  • IntegrityCheck — the local _totalPages shadowed 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.
  • AdminUI / InspectorPanel — the iconName block calls st.nextToken(), but the StringTokenizer is 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 to null inside catch (OutOfMemoryError) to free memory for error reporting; removing it would weaken OOM handling.
  • ManagementTableModel.minWidth — its assignment consumes a StringTokenizer token whose position a later rendererName = 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; plus javac for the AsciiDocIndex, FindFile and SimpleDemo persistit doc/example sources (not part of the Maven reactor).

…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.
@vharseko vharseko requested a review from maximthomas July 8, 2026 16:04
@vharseko vharseko added codeql CodeQL static-analysis findings refactoring Code cleanup / refactoring, no behavior change labels Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codeql CodeQL static-analysis findings refactoring Code cleanup / refactoring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants