Closed zaneduffield closed 11 months ago
In addition, SonarDelphi never discards the user's provided encoding - even when there's a BOM clearly indicating the encoding of the file.
Another detail that's inconsistent with sonar-scanner-engine
and should be changed.
Prerequisites
SonarDelphi version
1.0.0
SonarQube version
No response
Issue description
Currently, sonar-delphi simply uses the filesystem-level encoding provided by the sonar-scanner engine. However, the sonar-scanner engine actually determines file encodings at the file level, using heuristics:
https://github.com/SonarSource/sonarqube/blob/f50873318397d4bf7ba6a5c2b194dfa02492bdae/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/MetadataGenerator.java#L53 https://github.com/SonarSource/sonarqube/blob/f50873318397d4bf7ba6a5c2b194dfa02492bdae/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ByteCharsetDetector.java#L48
This encoding is then saved on the
InputFile
which can be accessed viaInputFile::charset
This can lead to errors in file offsets, when sonar-delphi is decoding the file using a different charset than the sonar-scanner engine.
Steps to reproduce
Scan the following (utf-8 encoded) source file
with
sonar.sourceEncoding
set to windows-1252.Minimal Delphi code exhibiting the issue
No response