Follow up on fixing Java Rule S1943 FileWriter or FileReader

Hi SonarSourcers,

I’ve been closely following the discussion on the Java Rule S1943 changes for 11 FileWriter or FileReaders as discussed here: Java Rule S1943 should take into account if a FileWriter or FileReader is created with a charset - #3 by Adam_Lu. Jira ticket: SONARJAVA-3772.

I believe the new rule is effective already. But I’m only seeing that the FileWriter or FileReader constructors are no longer being reported as an issue, but whenever I declare a variable of type FileWriter or FileReader the report still complains. I believe this should also be fixed.

versions used: SonarQube
For example:
FileReader fileReader = new FileReader(file, StandardCharsets.ISO_8859_1);
SonarQube now would not complain about the usages of the FileReader constructor, but it still complains about the variable fileReader by reporting Remove this use of "java.io.FileReader".
@Quentin

I created a new topic because the old topic is closed.

Hello @Adam_Lu

The issue you are facing seems to be the same as the one described in the ticket.
The ticket is fixed in version 6.15 of the analyzer, version not yet included in any version of SonarQube, explaining why you are still facing the issue.

It will be included in SonarQube 8.9 though.

Best,
Quentin

Hi Quentin,
So we are currently using SonarQube 7.8, and I don’t think we want to upgrade it anytime soon because we want a SonarQube version that can support both Java 8 and Java 11. Is there any way we can still use the new rule implemented for that ticket?

Best,
Adam

I’m afraid the only way to benefit from this change is to upgrade the SonarQube version.

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