Skip to content

Fix CodeQL note-severity alerts: confusable class and method names, and an unused verifier - #849

Merged
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:codeql/naming-and-unused
Aug 5, 2026
Merged

Fix CodeQL note-severity alerts: confusable class and method names, and an unused verifier#849
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:codeql/naming-and-unused

Conversation

@vharseko

@vharseko vharseko commented Aug 4, 2026

Copy link
Copy Markdown
Member

The last four note-severity alerts which are worth acting on: two classes named after their own supertype, two methods a capital letter apart, and a class nobody calls.

Storage implementing Storage (2 × java/class-name-matches-super-class)

org.opends.server.backends.jdbc.Storage and org.opends.server.backends.cassandra.Storage both implement org.opends.server.backends.pluggable.spi.Storage, which is why each of them has to spell the interface out in full in its own implements clause. They are renamed JDBCStorage and CASStorage, after the JEStorage and PDBStorage of the other pluggable backends. Both are constructed in exactly one place — configureStorage() of the Backend next to them — and referenced from their test cases; the configuration definitions name the Backend class, not the storage, so nothing outside the code base refers to either name.

While there, cassandra/Backend.java received the license header it was missing.

removeSubEntry next to removeSubentry (java/confusing-method-name)

SubentryManager has a private removeSubentry(Entry) which drops a subentry from both of its maps by calling a private removeSubEntry(Map, Entry) twice — the two names differ only in the case of one letter, and the call sites read as if the method called itself:

if (!removeSubEntry(dn2SubEntry, entry))
{
  removeSubEntry(dn2CollectiveSubEntry, entry);
}

The helper becomes removeSubentryFrom(Map, Entry), which says what it does and cannot be mistaken for its caller.

A hostname verifier which verifies nothing (java/unused-reference-type)

BlindHostnameVerifier is package-private, is referenced from nowhere, and its verify() returns true for every hostname. Dead code of that shape is worth removing rather than leaving around for someone to wire up: it is deleted.

Testing

  • opendj-server-legacy compiles, main and test sources.
  • SubentryManagerTestCase and SubentryPasswordPolicyTestCase cover the renamed helper.
  • The JDBC and Cassandra backend suites drive their storage through testcontainers and skip without Docker, so the renames there are verified by the compiler and by their call sites; the classes are constructed only from Backend.configureStorage().

…r, and drop a dead verifier

CodeQL java/class-name-matches-super-class, java/confusing-method-name
and java/unused-reference-type.

The JDBC and Cassandra backends each named their storage implementation
Storage, after the org.opends.server.backends.pluggable.spi.Storage they
implement, so each had to spell the interface out in full in its own
implements clause. They become JDBCStorage and CASStorage, matching
JEStorage and PDBStorage. Both are constructed only by the
configureStorage() of the Backend beside them, and the configuration
definitions name that Backend rather than the storage class.

SubentryManager.removeSubentry(Entry) called a helper named
removeSubEntry(Map, Entry) twice, so the call sites read as if the method
recursed. The helper becomes removeSubentryFrom(Map, Entry).

BlindHostnameVerifier is package-private, referenced from nowhere, and
accepts every hostname it is asked about. It is removed rather than left
for someone to wire up.

cassandra/Backend.java, which carried no license header, receives one.
@vharseko
vharseko requested a review from maximthomas August 4, 2026 12:06
@vharseko vharseko added java Pull requests that update java code enhancement jdbc labels Aug 4, 2026
Comment thread opendj-server-legacy/src/main/java/org/opends/server/backends/jdbc/JDBCStorage.java Dismissed
@vharseko
vharseko merged commit 6356883 into OpenIdentityPlatform:master Aug 5, 2026
17 checks passed
@vharseko
vharseko deleted the codeql/naming-and-unused branch August 5, 2026 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement java Pull requests that update java code jdbc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants