Skip to content

Commit cca1422

Browse files
authored
Remove never-read local variables (CodeQL java/local-variable-is-never-read) (#248)
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.
1 parent 138bd7a commit cca1422

11 files changed

Lines changed: 5 additions & 25 deletions

File tree

commons/doc-maven-plugin/src/main/java/org/forgerock/doc/maven/build/ChunkedHtml.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* information: "Portions copyright [year] [name of copyright owner]".
1313
*
1414
* Copyright 2012-2015 ForgeRock AS.
15+
* Portions Copyrighted 2026 3A Systems, LLC
1516
*/
1617

1718
package org.forgerock.doc.maven.build;
@@ -110,8 +111,6 @@ void prepareOlinkDB() throws MojoExecutionException {
110111
cfg.add(element(name("targetsFilename"), m.getDocumentSrcName() + ".html.target.db"));
111112

112113
final String base = FilenameUtils.getBaseName(m.getDocumentSrcName());
113-
final String chunkBaseDir = m.path(m.getDocbkxOutputDirectory())
114-
+ "/html/" + docName + "/" + base + "/";
115114
//cfg.add(element(name("chunkBaseDir"), chunkBaseDir));
116115

117116
executeMojo(
@@ -150,8 +149,6 @@ void build() throws MojoExecutionException {
150149
cfg.add(element(name("includes"), docName + "/" + m.getDocumentSrcName()));
151150

152151
final String base = FilenameUtils.getBaseName(m.getDocumentSrcName());
153-
final String chunkBaseDir = m.path(m.getDocbkxOutputDirectory())
154-
+ "/html/" + docName + "/" + base + "/";
155152
//cfg.add(element(name("chunkBaseDir"), chunkBaseDir));
156153

157154
cfg.add(element(name("manifest"),

commons/doc-maven-plugin/src/main/java/org/forgerock/doc/maven/utils/PngUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* information: "Portions copyright [year] [name of copyright owner]".
1313
*
1414
* Copyright 2013-2015 ForgeRock AS.
15+
* Portions Copyrighted 2026 3A Systems, LLC
1516
*/
1617

1718
package org.forgerock.doc.maven.utils;
@@ -76,7 +77,6 @@ public static void resizePng(final File image)
7677
final int imageHeight = getHeight(image);
7778
final int newWidth = 700;
7879

79-
String absolutePath = image.getAbsolutePath();
8080

8181
/** File thumbFile = new File(absolutePath.substring(0, absolutePath
8282
.lastIndexOf(File.separator)) + File.separator + "thumb_"

commons/http-framework/client-apache-async/src/main/java/org/forgerock/http/apache/async/AsyncHttpClientProvider.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ public HttpClient newHttpClient(final Options options) throws HttpApplicationExc
200200
}
201201

202202
// Apply proxy settings if necessary
203-
AuthenticationStrategy proxyStrategy = NoAuthenticationStrategy.INSTANCE;
204203
ProxyAuthenticationStrategy proxyAuthenticationStrategy = null;
205204

206205
// Read the proxy info from options

commons/http-framework/client-apache-sync/src/main/java/org/forgerock/http/apache/sync/SyncHttpClientProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Copyright 2009 Sun Microsystems Inc.
1515
* Portions Copyright 2010–2011 ApexIdentity Inc.
1616
* Portions Copyright 2011-2015 ForgeRock AS.
17+
* Portions Copyrighted 2026 3A Systems, LLC
1718
*/
1819

1920
package org.forgerock.http.apache.sync;
@@ -132,7 +133,6 @@ public HttpClient newHttpClient(final Options options) throws HttpApplicationExc
132133
asArrayOrNull(ciphers), hostnameVerifier));
133134

134135
// Apply proxy settings if necessary
135-
AuthenticationStrategy proxyStrategy = NoAuthenticationStrategy.INSTANCE;
136136
ProxyAuthenticationStrategy proxyAuthenticationStrategy = null;
137137

138138
// Read the proxy info from options

commons/rest/api-descriptor/src/main/java/org/forgerock/api/markup/asciidoc/AsciiDoc.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ public AsciiDoc blockTitle(final String title) {
281281
* @return Doc builder
282282
*/
283283
public AsciiDoc sectionTitle(final String title, final int level) {
284-
final AsciiDocSymbols symbol;
285284
// @Checkstyle:off
286285
switch (level) {
287286
case 1:

persistit/doc/build/src/AsciiDocIndex.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ private void indexOneTerm(final String wholeTag, String href, final String url,
170170
String category = "Class";
171171
if (title.startsWith("interface"))
172172
category = "Interface";
173-
final int pSlash = href.lastIndexOf('/', pHtml - 1);
174173
// String className = href.substring(pSlash + 1, pHtml);
175174
final String className = href.substring(0, pHtml).replace('/', '.');
176175
saveTerm(category, className, url);
@@ -189,7 +188,6 @@ private void indexOneTerm(final String wholeTag, String href, final String url,
189188
//
190189
final String uCaseName = name.toUpperCase();
191190
final String category = name.equals(uCaseName) ? "Constant" : "Field";
192-
final String displayText = name + " in " + className;
193191
saveTerm(category, name, url);
194192
return;
195193
} else {
@@ -208,7 +206,6 @@ private void indexOneTerm(final String wholeTag, String href, final String url,
208206
// String term = name.substring(0, pLeftParen);
209207
String term = (href.substring(0, pHtml) + href.substring(pHtml + 5)).replace('/', '.');
210208
saveTerm("Method", term, url);
211-
final String displayText = name + " in " + className;
212209
if (name.startsWith("get") && paramList.length() == 0 || name.startsWith("is")
213210
&& paramList.length() == 0 || name.startsWith("set") && paramList.length() > 0
214211
&& paramList.indexOf(',') == -1) {

persistit/examples/FindFile/FindFile.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ private void doSearch() {
209209
sb.append("$");
210210
final Pattern pattern = Pattern.compile(sb.toString());
211211

212-
final DefaultListModel model = (DefaultListModel) list.getModel();
213212
//
214213
// Substring that precedes the first wildcard character. For example,
215214
// if the input is "/opt/*java", the prefix is "/opt/".

persistit/examples/SimpleDemo/SimpleDemo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
15+
* Portions Copyrighted 2026 3A Systems, LLC
1516
*/
1617

1718
import java.io.BufferedReader;
@@ -65,7 +66,6 @@ public static void main(String[] args) throws Exception {
6566
System.out.println();
6667
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
6768

68-
boolean done = false;
6969
int count = 0;
7070
while (true) {
7171
System.out.print("Name: ");

persistit/ui/src/main/java/com/persistit/ui/AdminUI.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,10 +586,6 @@ private void setupTabbedPanes() {
586586
final StringTokenizer st = new StringTokenizer(paneSpecification, ":");
587587
final String className = st.nextToken();
588588
final String caption = st.nextToken();
589-
String iconName = null;
590-
if (st.hasMoreTokens()) {
591-
iconName = st.nextToken();
592-
}
593589
try {
594590
final Class cl = Class.forName(className);
595591
final AdminPanel panel = (AdminPanel) cl.newInstance();

persistit/ui/src/main/java/com/persistit/ui/InspectorPanel.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
16+
* Portions Copyrighted 2026 3A Systems, LLC
1617
*/
1718

1819
package com.persistit.ui;
@@ -82,10 +83,6 @@ private void setupTabbedPanes() {
8283
final StringTokenizer st = new StringTokenizer(paneSpecification, ":");
8384
final String className = st.nextToken();
8485
final String caption = st.nextToken();
85-
String iconName = null;
86-
if (st.hasMoreTokens()) {
87-
iconName = st.nextToken();
88-
}
8986
try {
9087
final Class cl = Class.forName(className);
9188
final AbstractInspector panel = (AbstractInspector) cl.newInstance();

0 commit comments

Comments
 (0)