Problem handling of Sonar Unable to read and import

Sonar is an open source but very useful code quality control tool. It integrates common static code inspection tools such as PMD, FindBugs and Checkstyle, as well as code coverage inspection. It provides some very useful features, its dashboard and timemachine are very simple but very prominently showing some of the most important features code coverage, code violations, code complexity

 

I encountered a very strange problem when running, it reported an exception similar to the following:

Exception in thread "main" org.sonar.batch.bootstrapper.BootstrapException: org.sonar.api.utils.SonarException: Unable to read and import the source file : '/home/marc/projects/MyProject/srcs/LATEST/fw/tiny_mq/src/mp_transport.c' with the charset : 'UTF-8'.
    at org.sonar.runner.Runner.delegateExecution(Runner.java:189)
    at org.sonar.runner.Runner.execute(Runner.java:78)
    at org.sonar.runner.Main.main(Main.java:61)
Caused by: org.sonar.api.utils.SonarException: Unable to read and import the source file : '/home/marc/projects/MyProject/srcs/LATEST/fw/tiny_mq/src/mp_transport.c' with the charset : 'UTF-8'.
    at org.sonar.api.batch.AbstractSourceImporter.parseDirs(AbstractSourceImporter.java:84)
    at org.sonar.api.batch.AbstractSourceImporter.analyse(AbstractSourceImporter.java:69)
    at org.sonar.api.batch.AbstractSourceImporter.analyse(AbstractSourceImporter.java:60)
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:64)

 There are actually two possibilities for this:

    1. It is really a file encoding problem. Sonar defaults to UTF-8 encoding;

    2. There are two file names with the same problem in the same project. The problem I found in the project is that the developer put two identical files under the same namespace under the main/test directory causing the problem.

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326979800&siteId=291194637