GithubHelp home page GithubHelp logo

Comments (11)

racodond avatar racodond commented on June 19, 2024

Hi Roman,

SonarSource is preventing all non-SonarSource products from being executed in SonarLint. Thus, unfortunately, you'll never see this CSS plugin in action in your IDE...

David

from sonar-css-plugin.

Ivan-L avatar Ivan-L commented on June 19, 2024

Hi @racodond,

I know that you closed this issue about a year ago, but I wanted to ask if anything has changed since then. We use SonarQube for commenting on pull requests and use your Sonar CSS plugin extensively. What we have found is that the rules of this plugin tend to be violated the most in our team (but that is fine, we correct the code since we want it to be uniform). However, it would be extremely useful if we saw the rule violations prior to pull requests being created.

We use the SonarLint plugin within Visual Studio for Windows and Visual Studio Code to warn us of rule violations for files other than CSS/SCSS. Adding support for CSS/SCSS support would be greatly advantageous to us since we would be able to see the rule violations within the editor.

I have recently tried to modify the SonarLint plugin for Visual Studio Code, located here. It took very few changes to get it to download the latest .jar file from your repository and invoke it for .css and .scss files. However, SonarLint.Core complained that the CSS plugin (.jar) does not support SonarLint:
sonarlint css plugin
It would seem that you need to add a sonarLintSupported entry to your pom.xml file to make SonarLint.Core recognize that your plugin supports SonarLint, see here as an example. I am not familiar at all with SonarLint plugins or their requirements, so I am not sure whether anything further is required to be implemented, apart from that extra entry.

Is this something that you could consider adding support for?

from sonar-css-plugin.

Ivan-L avatar Ivan-L commented on June 19, 2024

Just an update, the entry should be <sonar.sonarLintSupported>true</sonar.sonarLintSupported> under the <properties> element of the pom.xml file. I did get the plugin to load now, the scss file that I had open in the editor did get indexed, but the analysis does not execute. As mentioned, my SonarQube plugin knowledge is extremely limited.
sonar css loading

from sonar-css-plugin.

roman-hres avatar roman-hres commented on June 19, 2024

Hi @Ivan-L ,

I think that there nothing that can be done on the side of the sonar-css-plugin.
As far as I know, Sonar has created a whitelist inside the their code. Probably in the core project.
(You can see it here: https://github.com/SonarSource/sonarlint-core/blob/51f1534fea84e900ee62508b3d6c82b30b66a7ff/core/src/main/java/org/sonarsource/sonarlint/core/plugin/PluginCacheLoader.java)

SonarLint is using this list to check is it possible to index and analyze the file. Unfortunately css or less is not included in the list so SonarLint will ignore them. As far as I know it had be done with purpose. There is a ticket on Sonar jira with a little explanation why it had be done https://jira.sonarsource.com/browse/SLCORE-65

So it's more on SonarLint side then on sonar-css-plugin.
You can try to fork the SonarLint repository, extend the list (add css or less) and build corresponded jar for your project. Unfortunately I don't know exactly how it can be done for Visual Studio Code (I'm using IntelliJ IDEA)

Hope it will help you
Best regards,
Roman

from sonar-css-plugin.

Ivan-L avatar Ivan-L commented on June 19, 2024

Hi @Phoenix8095 ,

Yeah I managed to bypass the whitelist by adding <sonar.sonarLintSupported>true</sonar.sonarLintSupported> to the <properties> element of the pom.xml in the sonar-css-plugin folder of this repo. Note that plugins either have to be whitelisted or need to indicate that they support SonarLint, as on line 67.

However, I could not get further as the ScssAnalyzerSensor or CssAnalyzerSensor sensors of this plugin never get executed by SonarLint Core. I spent a good deal of time trying to figure out how sensors are discovered by SonarLint Core within plugins that are loaded and how they are then executed, but gave up due to time constraints. I also could not get SonarLint Core to compile, although that is probably my lack of Java / Maven knowledge. I may give it another go when time permits.

from sonar-css-plugin.

racodond avatar racodond commented on June 19, 2024

Hi guys,

SonarSource do not want non-SonarSource plugins to run in SonarLint. So, they won't make it easy to hack. If they did want so, they would just have added a white list that could be extended in configuration.

Regards,

David

from sonar-css-plugin.

Ivan-L avatar Ivan-L commented on June 19, 2024

I gave it one last shot and did manage to get the ScssAnalyzerSensor to start analyzing a file from SonarLint within Visual Studio Code. @racodond You are right they did not make it easy.

Continuing with the approach of setting the sonar.sonarLintSupported flag to true in the plugin in order to try to get SonarLint Core to execute the SCSS sensor, I hit the whitelist for a second time, this time in the ExtensionInstaller. Indeed, only SonarSource sensors can be executed and this time having the sonarLintSupported flag set to true, along with annotating the base class for all of the plugin sensors with @SonarLintSide (which required the bumping of sonar.version in the plugin to 6.0) did not help.

@Phoenix8095, you were right, modifying the whitelist to add a value of css was actually easier and I did not need to have any other flags set. By the way, I could not build the SonarLint Language Server (which I believe contains SonarLint Core, the .jar output of which is used by Visual Studio Code) because of missing Maven dependencies due to their commercial nature, however after removing them and building without running the tests, the build did succeed.

So in the end, the ScssAnalyzerSensor started analyzing a file within Visual Studio Code but did not complete the analysis for some reason. At least the sensor code did run. I am going to stop here though and throw in the towel as too much needs to be modified in order to get this to work.

It is a pity. The SonarQube Issues Report plugin is also not working, so there is no way currently to see any CSS rule violations prior to doing a PR. I can only hope that SonarSource improve on this situation as this plugin is very useful and seeing the rule violations in the IDE or before a commit would definitely save time.

from sonar-css-plugin.

racodond avatar racodond commented on June 19, 2024

Thanks for your investigation. But don't have vain hopes about SonarLint supporting non-SonarSource plugins...

from sonar-css-plugin.

Hilalem avatar Hilalem commented on June 19, 2024

Hello @racodond
since sonar-css joined the family with 7.3 when will sonarLint support css?

https://www.sonarqube.org/sonarqube-7-3/

from sonar-css-plugin.

racodond avatar racodond commented on June 19, 2024

Hi @Hilalem,

The new sonar-css plugin developped by SonarSource is not linked to mine in any way. You should talk to SonarSource about your issue instead.

David

from sonar-css-plugin.

Hilalem avatar Hilalem commented on June 19, 2024

from sonar-css-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.