uartois / sonar-golang

Sonarqube plugin for the golang language.
GNU Lesser General Public License v3.0
245 stars 32 forks source link

Getting Issues Report in Preview Mode #5

Closed goz closed 7 years ago

goz commented 7 years ago

Actually this is not an issue but more like a question. I'm trying to running an analysis in preview mode but somehow I didn't get anything. Is preview mode not supported yet?

Thanks

thibaultfalque commented 7 years ago

Hi, Thanks for your feedback.

I have tried to execute in preview mode with this parameter:

sonar.analysis.mode=preview
sonar.issuesReport.console.enable=true

I hope will help you. Regards.

goz commented 7 years ago

I didn't get any issues, but when I run golint manually it reports some issues, and also report.xml showing some errors.

Here is my environment :

my sonar-project.properties file :

sonar.projectKey=key
sonar.projectName=Service
sonar.projectVersion=1.0
sonar.sources=./
sonar.exclusions=./vendor/**,./src/github.com/alecthomas/**
sonar.analysis.mode=preview
sonar.golint.reportPath=./report.xml
sonar.issuesReport.console.enable=true
sonar.github.oauth=xxx
sonar.github.repository=x/y
sonar.github.pullRequest={ghprbPullId}

report.xml

<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="5.0">
<file name="digital.go">
<error column="2" line="16" message="exported const ConfigName should have comment (or a comment on this block) or be unexported" severity="warning" source="golint"></error>
<error column="9" line="8" message="could not import github.com/spf13/viper (can&#39;t find import: github.com/mataharimall/digital/vendor/github.com/spf13/viper)" severity="error" source="gotype"></error>
<error column="2" line="9" message="could not import github.com/maps90/go-core (can&#39;t find import: github.com/mataharimall/digital/vendor/github.com/maps90/go-core)" severity="error" source="gotype"></error>
<error column="9" line="10" message="could not import github.com/maps90/go-core/log (can&#39;t find import: github.com/mataharimall/digital/vendor/github.com/maps90/go-core/log)" severity="error" source="gotype"></error>
<error column="2" line="11" message="could not import github.com/mataharimall/digital/app/baznas (can&#39;t find import: github.com/mataharimall/digital/app/baznas)" severity="error" source="gotype"></error>
<error column="40" line="14" message="undeclared name: core" severity="error" source="gotype"></error>
<error column="40" line="31" message="undeclared name: core" severity="error" source="gotype"></error>
<error column="6" line="21" message="undeclared name: config" severity="error" source="gotype"></error>
<error column="2" line="24" message="undeclared name: core" severity="error" source="gotype"></error>
<error column="2" line="25" message="undeclared name: logger" severity="error" source="gotype"></error>
<error column="14" line="25" message="undeclared name: config" severity="error" source="gotype"></error>
<error column="46" line="25" message="undeclared name: config" severity="error" source="gotype"></error>
<error column="26" line="28" message="undeclared name: baznas" severity="error" source="gotype"></error>
<error column="7" line="43" message="undeclared name: core" severity="error" source="gotype"></error>
<error column="12" line="48" message="undeclared name: config" severity="error" source="gotype"></error>
<error column="11" line="49" message="undeclared name: config" severity="error" source="gotype"></error>
<error column="60" line="24" message="error return value not checked (core.NewConfiguration(ConfigName, ConfigPath).ReadInConfig())" severity="warning" source="errcheck"></error>
<error column="8" line="45" message="error return value not checked (route(r))" severity="warning" source="errcheck"></error>
</file>
</checkstyle>
screen shot 2017-06-05 at 3 29 15 pm

I run this via Jenkins, trying to automate coding style. Any idea?

Thanks

danielleberre commented 7 years ago

AFAIK, the plugin should report 3 issues:

<error column="2" line="16" message="exported const ConfigName should have comment (or a comment on this block) or be unexported" severity="warning" source="golint"></error>
<error column="60" line="24" message="error return value not checked (core.NewConfiguration(ConfigName, ConfigPath).ReadInConfig())" severity="warning" source="errcheck"></error>
<error column="8" line="45" message="error return value not checked (route(r))" severity="warning" source="errcheck"></error>

The remaining errors are issues with the tools which cannot access some code.

@thibaultfalque do we support them?

thibaultfalque commented 7 years ago

@danielleberre Yes, I have checked the rules and I support this error for "errcheck" . I added acceptance tests for this messages.

@gozali The Sonarqube documentation say:

When running an analysis in preview or incremental mode, the SonarQube platform provides the ability to generate a report of issues so developers can see whether they're about to inject new technical debt before submitting their new code. This way, they can make sure they're not committing code with new issues, and therefore that no new technical debt will be reported on the SonarQube server after the next full analysis.

So I think Sonarqube have register this violations and output "no new issue" because there is not new issue in the code since the last analysis. But if you run "gometalinter" or "golint" they are showing "errors" because there is not notion of history and quality.

goz commented 7 years ago

finally I figure it out, I should fix the path and scan only go files. thanks @thibaultfalque @danielleberre

screen shot 2017-06-07 at 10 19 04 am