Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

False Unused "private" methods should be removed

Tags:

java

sonarqube

I think we have false positive in our Sonar's installation (5.6 and java plugin 4.0). An Unused "private" method should be removed issue is raised for the following code :

public boolean orderLineHasDetails(OrderLine orderLine) {

        boolean result = orderLine.getContractDevices() != null && orderLine.getContractDevices().size() > 0;

        if (result) {

            result = asLeastOneUniqueId(orderLine.getContractDevices());

        }

        return result;

    }


    private boolean asLeastOneUniqueId(List<ContractDevice> contractDeviceList) {


        Iterator<ContractDevice> contractDeviceIterator = contractDeviceList.iterator();

        boolean result = false;

        while (!result && contractDeviceIterator.hasNext()) {

            result = StringUtils.isNotBlank(contractDeviceIterator.next().getDeviceUniqueId());

        }

        return result;

    }

Is this a known bug ?

Thanks for your help.

Edit:
A new false positive inner a method : enter image description here

Regards,

Stephane

like image 863
Wilda Avatar asked Jul 27 '16 15:07

Wilda


1 Answers

This was a bug in the previous sonar installations. But recently it is fixed and working fine. Try using sonar Lint from eclipse market place (I hope you are using eclipse) which is the latest release of sonar in eclipse.

I tried this code in my code base and the message is not displayed. So try updating sonar or sonarqube to sonar Lint.

like image 100
Kalyan Pradhan Avatar answered Nov 24 '22 12:11

Kalyan Pradhan