A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/5832 below:

[java] UnnecessaryImport false positive for multiline @see Javadoc · Issue #5832 · pmd/pmd · GitHub

Affects PMD Version: 7.14.0

Rule: UnnecessaryImport

Description:

false positive finding:

[WARNING] PMD Failure: io.quarkus.deployment.configuration.BuildTimeConfigBuilderCustomizer:3 Rule:UnnecessaryImport Priority:4 Unused import 'java.util.List'.
[WARNING] PMD Failure: io.quarkus.deployment.configuration.BuildTimeConfigBuilderCustomizer:4 Rule:UnnecessaryImport Priority:4 Unused import 'java.util.Map'.
[WARNING] PMD Failure: io.quarkus.deployment.configuration.BuildTimeConfigBuilderCustomizer:6 Rule:UnnecessaryImport Priority:4 Unused import 'io.quarkus.runtime.LaunchMode'.

Code Sample demonstrating the issue:

package io.quarkus.deployment.configuration;

import java.util.List;
import java.util.Map;

import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.console.ConsoleRuntimeConfig;
import io.quarkus.runtime.logging.LogBuildTimeConfig;
import io.quarkus.runtime.logging.LogRuntimeConfig;
import io.quarkus.runtime.logging.LoggingSetupRecorder;
import io.smallrye.config.SmallRyeConfigBuilder;
import io.smallrye.config.SmallRyeConfigBuilderCustomizer;

/**
 * Even if the Log and Console mappings are marked as runtime, they are also used during build time.
 * <p>
 * We cannot register the mappings in the core runtime module because {@link io.smallrye.config.SmallRyeConfig}
 * requires ASM to load the mappings. When we run a Quarkus test, Quarkus will generate the bytecode for the mappings,
 * so we don't need ASM. In a non-Quarkus tests, ASM must be present in the classpath, which we want
 * to avoid (even if they are in the test scope). The logging mappings shouldn't be loaded when running a non-Quarkus
 * test because they are not required.
 *
 * @see LoggingSetupRecorder#initializeBuildTimeLogging(LogRuntimeConfig, LogBuildTimeConfig, ConsoleRuntimeConfig, Map, List,
 *      LaunchMode)
 */
public class BuildTimeConfigBuilderCustomizer implements SmallRyeConfigBuilderCustomizer {
    @Override
    public void configBuilder(final SmallRyeConfigBuilder builder) {
        builder.withMapping(LogBuildTimeConfig.class)
                .withMapping(LogRuntimeConfig.class)
                .withMapping(ConsoleRuntimeConfig.class);
    }
}

Expected outcome:

no failure.

PMD reports a violation at line ..., but that's wrong. That's a false positive.

Running PMD through: [CLI]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4