Trigger custom action after SonarLint scan finishes


I’m writing a plugin for SonarLint using Java 11 and running on Intellij.

I’m currently trying to run a function every time a sonarlint scan ends, is there a way to implement this?

Every input is appreciated, thanks :slight_smile:

Hi @davidesn ,

We are not providing any extensibility on SonarLint for the time being. Having some context (functional use case) might be useful to understand if this is something we should add to our roadmap.

Thank you so very much for the reply @Julien_HENRY .

I currently have a custom sensor extending the SonarLint class Sensor that triggers every time a new Sonarlint scan starts, either manually or automatically.

Now, due to project limitations, I cannot extend the custom sensor class I created.
This is unfortunate, since I would be able to run post scan operations from there and easily solve the issue.

Currently, I’m only able to execute custom code after a manual scan, but not after a sonarlint automatic scan is executed.

I checked Sonar triggers, PostJob class (which is now deprecated) and a few other alternatives but none of them helped me solve this.

I am not sure my explanation was clear, perhaps I do not understand the structure of Sonarlint well enough.

TLDR: Is there any other way other than Sensor class to invoke custom code after automatic analysis?

Any other input? I’m kind of stuck wih this.

Again, we don’t plan to make SonarLint extensible, but if you could share your functional use case, maybe we could reconsider.

I understand you wrote a custom Sensor. My question is Why?

  • Is it to support a language SonarSource is not currently supporting? If yes, could you say which one? Did you write your own analyzer, or maybe are you wrapping an existing linter available as a command line tool or as a Java library?
  • Is it to add new rules to an already supported language? If yes, we would be happy to know more details about those rules, so that we could decide if it make sense to implement them.
  • Do you target a specific IDE?

Hi @Julien_HENRY ,

Thanks sincerely for your reply.

  • Yes, I wrote a custom Sensor for Gosu language, but I do not have a custom Analyzer, I just used Lint one.

  • No, it is to add rules to a new unsupported language.

  • Yes, Guidewire Studio (that runs on IntelliJ).

Hope this answers the questions, apologies for the delay.

Hi @davidesn

Thanks for your answers, it helps. I have added an entry in our insight tracking system about adding the support of Gosu in SonarLint for IntelliJ. For the moment, this is not part of our roadmap.
Also, as I mentioned, SonarLint is not intended to be extensible like SonarQube, even if we are relying on the SonarQube plugin API to run our own analyzers.

If you want to run your Sensor in the IDE, you may develop your own IDE extension (if your analyzer is based on CodeNarc, then you can have a look at CodeNarc - IntelliJ IDEs Plugin | Marketplace).
Another option is to maintain your own fork of SonarLint (please change the name), with built-in support of Gosu.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.