[S1128] SonarLint pugin for IntelliJ - false report for unused imports in Java records

Hello,

Most probably you’re already aware about this issue, but I failed to find a report for it.

SonarLint plugin for IntelliJ marks any imports used as property type by JDK16 records as unused.

Versions used:

  • InteliJ: IntelliJ IDEA 2021.1 (Ultimate Edition) Build #IU-211.6693.111
  • SonarLint plugin for InteliJ: 4.14.2.28348
  • JDK 16 (AdoptOpenJDK 16.0.0.j9)

Minimal code sample to reproduce:

import java.time.LocalDate; //SonarLint: Remove this unused import 'java.time.LocalDate'. 

public record Test(LocalDate localDate) { }

These are the details on the warning:

Unnecessary imports should be removed
 
Code smell
 
Minor
java:S1128

The imports part of a file should be handled by the Integrated Development Environment (IDE), not manually by the developer.
Unused and useless imports should not occur if that is the case.
Leaving them in reduces the code's readability, since their presence can be confusing.

Hey there.

A very similar reseponse here as to your other post:

Except the specific ticket this time is SONARJAVA-3799 :slight_smile:

Thanks for both of your detailed reports.

2 Likes

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