Java Rule S1943 should take into account if a FileWriter or FileReader is created with a charset

java
sonarjava
java11

(Thomas Schindler) #1

I’m using a FileWriter in order to write some analysis information of my application in a text file. The rule S1943 raises an issue even if the FileWriter is created with a CharSet - value like this:

BufferedWriter bw = new BufferedWriter(new FileWriter(resourcedFile, StandardCharsets.UTF_8));

Results in the following Sonar Issue:

I assume, that this rule doesn’t take into account the new FileWriter and FileReader constructors with the charset argument.

We are using SonarQube Version 7.5.0.20543 with SonarJava 5.11 (build 17289).


(Michael Gumowski) #2

Hey Thomas,

Thanks for the feedback! I realized with this that the rule squid:S1943 has yet to be updated to cover methods which would have been introduced with Java 11. I created the following ticket to fix it: SONARJAVA-3057

Cheers,
Michael