Pre commit hooks?

Hi All, I want to be able to use a sonar product do do a pre commit check to make sure changes are of good quality first. SonarQube checks after it’s pushed. SonarLint check as you write the code, but I would also like to run a check that can be tied in with something like in a pre commit hook to ensure that issues are not being ignored etc. Is this possible, it sounds like no CLI is available and I wanted to check if the above is possible and if so how and which Sonar product that would be.

Many thanks

Hello @andystannard and welcome to the Sonar community forum!

What IDE do you use? In IntelliJ IDEs and Eclipse, SonarLint can analyze the files in your changeset when you are about to commit. There are two caveats though:

  1. SonarLint today scans and reports ALL issues within the files that are part of the changeset (not only issues added with this change)
  2. This is not implemented with Git hooks, so the pre-commit checks are only executed if you use the IDE to commit.

We are considering improvements to the pre-commit functionality (you can subscribe to this roadmap card), and I would be really interested to know how important is for you to overcome the two limitations listed above. Even better, if you have a few minutes to spare, we are collecting user feedback about SonarLint and it would be great if you could fill this survey :pray:



Thanks Marco for the answer. I am also curious about this topic, I am using vs code