Fix CodeQL note-severity alerts: dead parameters of private methods - #834
Open
vharseko wants to merge 1 commit into
Open
Fix CodeQL note-severity alerts: dead parameters of private methods#834vharseko wants to merge 1 commit into
vharseko wants to merge 1 commit into
Conversation
The java/unused-parameter alerts fall into three groups. Most of them are on interface declarations, on the no-op default implementations of abstract classes and on public methods, where the parameter is part of a contract and cannot be removed. The rest are private methods and enum constructors which really do ignore an argument, and one of them was hiding a defect: * LDAPConnectionConsoleInteraction dropped the 'obfuscated' flag: an argument added through addObfuscatedArgToCommandBuilder() was registered with CommandBuilder.addArgument() instead of addObfuscatedArgument(), so the trust store and key store passwords were printed in clear in the equivalent command line instead of being masked. The flag is now honoured. * CommonAudit.addJsonHandlerBufferingConfig() built an EventBufferingConfiguration and dropped it, ignoring both of its parameters. The configuration of a JSON audit handler carries no buffering settings at all, so the method was vestigial: it is removed together with its call, which also clears the alert about the local variable which is never read. * The dead parameters of the private methods of SchemaBuilder, Rest2LdapJsonConfigurator, DeleteIndexTask, ConfigFromConnection, ZipExtractor, ConfigureDS, LDAPAuthenticationHandler, StopDS and UpgradeCli are removed, along with their javadoc, and the private notifyAuthDataChanged(url) overload of BrowserController, which was only ever called with null, is merged into the public method. * The four ACI enumerations passed a value to a constructor which discarded it; the parameter, the values of the 21 constants and the empty constructors are removed. The remaining private methods are left alone: removing their parameter would only move the alert to the public method which passes it (ClickTooltipDisplayer, FileTag, SequentialTag, UpgradeCli.run), or the parameter is needed as a type witness (SubResourceImpl.adaptLdapException), or the method is a documented no-op (SASLContext.realmCallback) or a stub with a FIXME (LocalBackend.isIndexed).
maximthomas
approved these changes
Aug 3, 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.
Addresses the
java/unused-parameteralerts, the largest remaining group of note-severity code scanning alerts. They turned out not to be uniform noise: one of them was hiding a defect.A dropped flag which leaked passwords into the printed command line
LDAPConnectionConsoleInteractionbuilds the "equivalent command line" the tools display. It has two entry points:CommandBuilderhas a dedicatedaddObfuscatedArgument()for values which must be masked, and the obfuscated entry point is used for--trustStorePasswordand--keyStorePassword. Because the flag was dropped, those passwords were rendered in clear instead of******. The flag is now honoured.Dead code
CommonAudit.addJsonHandlerBufferingConfig()created anEventBufferingConfigurationand dropped it on the floor, ignoring both of its parameters. The OpenDJ configuration of a JSON audit handler carries no buffering settings at all —JsonConfigDataonly holds the log directory and the rotation/retention policies — so the method could never configure anything. It is removed together with its call, which also clears thejava/local-variable-is-never-readalert on the same lines. Behaviour is unchanged: the handler keeps the library defaults it already used.Dead parameters
Removed from the private methods of
SchemaBuilder,Rest2LdapJsonConfigurator,DeleteIndexTask,ConfigFromConnection,ZipExtractor,ConfigureDS,LDAPAuthenticationHandler(two),StopDSandUpgradeCli, together with their@paramjavadoc; every call site is compiler-checked. The privateBrowserController.notifyAuthDataChanged(url)overload was only ever called withnull, so it is merged into the public method, keeping its TODO.The four ACI enumerations (
EnumEvalResult,EnumUserDNType,EnumEvalReason,EnumAuthMethod) passed a value to a constructor which discarded it; the parameter, the values of the 21 constants and the resulting empty constructors are removed. The javadoc of each constant already documents what the value meant.Alerts deliberately left open
InternalSearchListener), on the no-op default implementations of abstract classes (AccessLogPublisher.logSearchResultEntry— "The default implementation is to not log anything") and on public methods. There the parameter is part of a contract and cannot be dropped.ClickTooltipDisplayer.hideToolTip→mouseExited,FileTag/SequentialTag.initializeInternal→ the parameters of theTaginterface,UpgradeCli.run→ the publicmain), or where the parameter is needed:SubResourceImpl.adaptLdapException(Class<R>)uses it as a type witness,SASLContext.realmCallback()is a documented no-op callback handler, andLocalBackend.isIndexed()is a stub carrying a FIXME about being overridden by the backends.Testing
opendj-core8173 tests,opendj-config547,opendj-rest2ldap531,opendj-cli46,opendj-server3 — all passing.opendj-server-legacy(-Pprecommit), covering the ACI enumerations, the SASL handlers and the access log publisher:PlainSASLMechanismHandlerTestCase(67),IPTestCase(58),AbstractTextAccessLogPublisherTest(27),DigestMD5SASLMechanismHandlerTestCase(25),EnumRightTest(16),BindRuleOperandTest(13),ExternalSASLMechanismHandlerTestCase(13),AciBodyTest(8) — all passing.GetEffectiveRightsTestCase(7) passes as well; its first run had failed to bind the embedded server to the fixed administration connector port because another test JVM held it.