Code analysis on commit with SonarLint/SonarQube

Answered

There is an option to run code analysis before commit by using checkbox "Perform code analysis".

As I understand that this basically runs the same as menu "Analyze -> Inspect code...".

Now if I disable this checkbox no analysis will be run automatically before code commit.

Now I installed SonarLint plugin and it runs its own analysis independent of this checkbox.

How does this work? Is there some additional list of analysis that will be run even if checkbox is disabled?

Why is the SonarLint analysis run even though the checkbox is disabled?

 

Thanks for examplanation,

Zbynek

 

0
10 comments

SonarLint is a third-party plugin. They just built their pre-commit-handler to always run the inspection.

Please contact the SonarLint vendor for details.

They say it should be possible to disable the check on commit since 2.5, with the additional Perform SonarLint analysis code- see https://jira.sonarsource.com/browse/SLI-125?jql=project%20%3D%20SLI%20AND%20text%20~%20%22commit%22

0

Makes sense thanks.

Maybe a follow-up, I installed SonarQube plugin and I know have inspection named "SonarQube issues (SonarQube new)".

I can run this using Analyze -> Run Inspection By Name...". How can I attach this to the "Perform code analysis" checkbox before commit.

What kind of analysis is run when this checkbox is checked?

 

Thanks

0

> What kind of analysis is run when this checkbox is checked

Exactly the same that is run with Analyze - Inspect Code, with the appropriate scope, as currently there is one inspection profile per project.

To run SonarQube inspection along with other inspections, edit the profile using Settings - Editor - Inspections

 

0

I know this should probably be pointed to plugin developer but when I run "Analyze - Inspect code" SonarQube runs analysis.

When I check "Perform code analysis" SonarQube is NOT invoked. So it seems its not exactly the same...

0

Maybe, it does not integrate with the default profile correctly, or there is some bug. It appears there is a request about it - see https://youtrack.jetbrains.com/issue/IDEA-147927

 

0

I know this is probably targeted to plugin developers, but I see 3 years old with no updates. Are there any?

Shouldn't it be at least closed with comment like "plugin developer responsibility"?

Whats the point of keeping issues so old with no progress?

 

New issue created with plugin development group as well - https://github.com/sonar-intellij-plugin/sonar-intellij-plugin/issues/216.

0

> Shouldn't it be at least closed with comment like "plugin developer responsibility"?

Well, it could be solved by a plugin, or maybe could be solved in the platform somehow, for all plugins in general.

 

> What's the point of keeping issues so old with no progress?

It is not possible to fix and implement everything, ALso it does not appear a popular request.

But it is valid though - why declining or closing it? If (when_ some changes are done in this area, it could be fixed along with them, for example.

The long backlog is a different story though.

0

Well it would be nice to be able to select inspection to be run before commit inspection by name.

Is that possible?

0

No, it is not possible 

0

Okey than, I'm gonna watch both issues and wait :/

Thanks for the feedback anyway, appreciated!

1

Please sign in to leave a comment.