squid:UselessImportCheck false positive for constants used in @NamedQuery annotation

The following code:

import static SomeEntity.FIND_BY_NAME;

import javax.persistence.Entity;
import javax.persistence.NamedQuery;

@NamedQuery( name = FIND_BY_NAME, query = "select se from SomeEntity where name = :name" )
@Entity
public class SomeEntity
{
    public static final String FIND_BY_NAME = "SomeEntity.findByName";
    private String name;
}

triggers squid:UselessImportCheck rule for import static SomeEntity.FIND_BY_NAME although the import is used in @NamedQuery annotation.

SonarQube version: Community Edition 7.9.1 (build 27448)

Hello @Pawel_Osak,

Thanks for the feedback and the reproducer!

This is indeed a wrong behavior of the rule, I created a ticket to track this issue!

Best,
Quentin

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