@SuppressWarnings being ignored

Running Sonarqube in Docker

  • Developer Edition Version 10.4.1 (build 88267)

We use @Suppressions like this to suppress certain warnings:

@SuppressWarnings({"java:S116", "java:S117"})

This used to work fine but I think it was broken when we updated to 10.4. See the big spike:

We also use SonarLint and the warnings are suppressed correctly there and not reported. If I remove the @SuppressWarnings, then SonarLint reports them.

So with the suppressions we don’t see them in Sonarlint, but the builds still report them in Sonarqube:

Did something change in 10.4 that would affect this?

In addition, we use @SuppressWarnings(“deprecation”) to get rid of some deprecation warnings. Here is an example of where Sonarlint returns no issues in IntelliJ, but Sonarqube reports issues.

@SuppressWarnings("deprecation")
public class HiSpecialStudyDao extends SpecialStudyDao {

    /**
     * Given a <code>Record</code>, finds all the corresponding MEC records using
     * criteria defined in the HI queries file.
     * <p>
     * Created on Jan 16, 2008 by depryf
     * @param rec <code>Record</code>
     * @return list of <code>Record</code>'s, maybe empty but never null
     */
    @SuppressWarnings("unchecked")
    public List<Record> findCorrespondingMecRecords(Record rec) {
        boolean deathCert = Long.valueOf(LookupConstants.RECORD_MAJOR_SUBTYPE_DEATH_CERT).equals(rec.getMajorSubtypeId());
        String queryName = deathCert ? "query.hi.mec.dc" : "query.hi.mec";

        try {
            Query<Record> query = HibernateUtils.getLocalSession().getNamedQuery(queryName);

            query.setLong("recId", rec.getRecordId());
            query.setString("nameLast", rec.getNameLast());
            query.setString("nameFirst", rec.getNameFirst());
            query.setString("sex", rec.getSex());
            query.setString("birthDateYear", rec.getBirthDateYear());

            if (deathCert) {
                query.setString("nameBirthSurname", rec.getNameBirthSurname());
                query.setString("birthDateMonth", rec.getBirthDateMonth());
                query.setString("birthDateDay", rec.getBirthDateDay());
            }
            else
                query.setString("socialSecurityNumber", rec.getSocialSecurityNumber());

            return query.list();
        }
        catch (HibernateException he) {
            throw new DAOException("Unable to run '" + queryName + "'", he);
        }
    }
}

Here is what Sonarqube reports:

I found this

So I am closing this issue. Sorry!

1 Like

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