Comments (11)
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.
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:
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.
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.
from sonar-css-plugin.
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.
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.
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.
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.
Thanks for your investigation. But don't have vain hopes about SonarLint supporting non-SonarSource plugins...
from sonar-css-plugin.
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.
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.
from sonar-css-plugin.
Related Issues (20)
- Change or disable rules HOT 1
- user-select css property HOT 9
- Add parameter to 'experimental-xxx-usage' rules to flag some properties/@-rules/pseudos/functions/identifiers as non-experimental
- Parse error in at-rule prelude with non-quoted URL
- Support CSS Fonts Module Level 4 HOT 2
- `MissingNewLineAtEndOfFileCheck` should skip empty files HOT 3
- Unknown type selectors - exclusion HOT 3
- Please add support for Angular Material HOT 3
- How to flag some pseudo elements as non-experimental? HOT 2
- the plugin can not be updated via the marketplace of the sonar HOT 1
- Cannot enable both this plugin and the built-in "SonarCSS" plugin HOT 2
- Naming convention HOT 2
- Parent selector (&) not supported in variable declaration HOT 4
- box-shadow considered experimental HOT 4
- validate-property-value: false-positive on `background-color` value format HOT 1
- Throws an error with special characters HOT 1
- SCSS parser failure (S2260): parser does not support identifiers starting with "-#" HOT 2
- FP css:validate-property-value on filter HOT 6
- Exclude the file type css HOT 1
- link to "quick try" doesn't work HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sonar-css-plugin.