False "Remove this unused import java:S1128" issues after update to version 8.7.1

We updated our SonarQube Server to 8.7.1 on 15.3.2021

  • SonarQube ID information
    Server ID: A7EE8CF2-AWNfJ7jrUMoe9cI1imbB

Now there are 14 new issues “Remove this unused import” but all of them are false, because the removal would result in a compilation error.

This java class produces : Remove this unused import ‘com.example.client.common.editor.view.BaseEditorPart.TRANSIENT_PARAMETER_READONLY’.

package com.example.client.selection.handler;

import static com.example.client.common.editor.view.BaseEditorPart.TRANSIENT_PARAMETER_READONLY;
import static java.util.Objects.nonNull;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.example.client.common.part.PartManager;
import com.example.shared.dto.DataSetVersionIdDTO;

public abstract class BasePartHandler {

    private static final Logger LOGGER = LoggerFactory.getLogger(BasePartHandler.class);

    protected final PartManager partManager;

    protected BasePartHandler(PartManager partManager) {
        this.partManager = partManager;

    protected void displayPart(String partId) {
        displayPartInternal(partId, null, null, null);

    protected void displayPart(String partId, String parameterName, DataSetVersionIdDTO id) {
        displayPartInternal(partId, parameterName, id, null);

    protected void displayPartEditable(String partId) {
        displayPartInternal(partId, null, null, false);

    protected void displayPartEditable(String partId, String parameterName, DataSetVersionIdDTO id) {
        displayPartInternal(partId, parameterName, id, false);

    protected void displayPartReadOnly(String partId) {
        displayPartInternal(partId, null, null, true);

    protected void displayPartReadOnly(String partId, String parameterName, DataSetVersionIdDTO id) {
        displayPartInternal(partId, parameterName, id, true);

    private void displayPartInternal(String partId, String parameterName, DataSetVersionIdDTO id, Boolean readOnly) {
        try {
            partManager.displayPart(partId, partManager.createElementId(partId, id, readOnly),
                    part -> {
                        if (nonNull(parameterName) && nonNull(id)) {
                            part.getTransientData().put(parameterName, id);
                        if (nonNull(readOnly)) {
                            part.getTransientData().put(TRANSIENT_PARAMETER_READONLY, readOnly);
        } catch (Exception ex) {
            LOGGER.error(getErrorMessage(), ex);

    protected void hidePart(String elementId) {

    protected abstract String getErrorMessage();

Hello @MarcelRueedi

Indeed, this rule is subject to few false positives and the situation you are reporting is one of them. The good news is that we identify a way to greatly improve the precision of this rule, see SONARJAVA-3777. Once implemented, it should most probably solve your problem.


1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.