All Projects → racodond → sonar-css-plugin

racodond / sonar-css-plugin

Licence: LGPL-3.0 license
SonarQube CSS / SCSS / Less Analyzer

Programming Languages

java
68154 projects - #9 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to sonar-css-plugin

sonar-gherkin-plugin
SonarQube Cucumber Gherkin Analyzer
Stars: ✭ 33 (-28.26%)
Mutual labels:  styleguide, linter, static-analysis, sonarqube, code-quality, static-analyzer, guidelines, sonarqube-plugin
Sonar Jproperties Plugin
SonarQube Java Properties Analyzer
Stars: ✭ 5 (-89.13%)
Mutual labels:  styleguide, linter, static-analysis, sonarqube, code-quality, static-analyzer, guidelines
Sonar Dotnet
Code analyzer for C# and VB.NET projects https://redirect.sonarsource.com/plugins/vbnet.html
Stars: ✭ 466 (+913.04%)
Mutual labels:  static-analysis, sonarqube, code-quality, static-analyzer
Sonarts
Static code analyzer for TypeScript
Stars: ✭ 776 (+1586.96%)
Mutual labels:  linter, static-analysis, sonarqube, code-quality
tryceratops
A linter to prevent exception handling antipatterns in Python (limited only for those who like dinosaurs).
Stars: ✭ 381 (+728.26%)
Mutual labels:  stylelint, styleguide, linter, static-analysis
Sonarjs
SonarSource Static Analyzer for JavaScript and TypeScript
Stars: ✭ 696 (+1413.04%)
Mutual labels:  static-analysis, sonarqube, code-quality, static-analyzer
Pep8speaks
A GitHub app to automatically review Python code style over Pull Requests
Stars: ✭ 546 (+1086.96%)
Mutual labels:  styleguide, linter, static-analysis, code-quality
Flake8
The official GitHub mirror of https://gitlab.com/pycqa/flake8
Stars: ✭ 1,112 (+2317.39%)
Mutual labels:  stylelint, styleguide, linter, static-analysis
lints
Lint all your JavaScript, CSS, HTML, Markdown and Dockerfiles with a single command
Stars: ✭ 14 (-69.57%)
Mutual labels:  stylelint, linter, static-analysis, static-analyzer
Detekt
Static code analysis for Kotlin
Stars: ✭ 4,169 (+8963.04%)
Mutual labels:  linter, static-analysis, code-quality
Reviewdog
🐶 Automated code review tool integrated with any code analysis tools regardless of programming language
Stars: ✭ 4,541 (+9771.74%)
Mutual labels:  linter, static-analysis, code-quality
Sonar Kotlin
SonarQube plugin for Kotlin
Stars: ✭ 412 (+795.65%)
Mutual labels:  linter, sonarqube, code-quality
Pmd
An extensible multilanguage static code analyzer.
Stars: ✭ 3,667 (+7871.74%)
Mutual labels:  linter, static-analysis, code-quality
Pylint
It's not just a linter that annoys you!
Stars: ✭ 3,733 (+8015.22%)
Mutual labels:  linter, static-analysis, code-quality
localhost-sonarqube
Analysing source code locally with SonarQube in a Docker environment.
Stars: ✭ 17 (-63.04%)
Mutual labels:  static-analysis, sonarqube, code-quality
Njsscan
njsscan is a semantic aware SAST tool that can find insecure code patterns in your Node.js applications.
Stars: ✭ 128 (+178.26%)
Mutual labels:  linter, static-analysis, static-analyzer
Wotan
Pluggable TypeScript and JavaScript linter
Stars: ✭ 271 (+489.13%)
Mutual labels:  linter, static-analysis, code-quality
Static Analysis
⚙️ A curated list of static analysis (SAST) tools for all programming languages, config files, build tools, and more.
Stars: ✭ 9,310 (+20139.13%)
Mutual labels:  linter, static-analysis, code-quality
Cflint
Static code analysis for CFML (a linter)
Stars: ✭ 156 (+239.13%)
Mutual labels:  linter, static-analysis, code-quality
static-code-analysis-plugin
A plugin to simplify Static Code Analysis on Gradle. Not restricted to, but specially useful, in Android projects, by making sure all analysis can access the SDK classes.
Stars: ✭ 36 (-21.74%)
Mutual labels:  linter, static-analysis, code-quality

Release Build Status Build status

Quality Gate status Lines of Code Coverage

SonarQube CSS / SCSS / Less Analyzer

Disclaimer

I don't want to keep maintaining this plugin. Feel free to ping me if you want to take over.

Description

This SonarQube plugin analyzes:

  • CSS files
  • CSS code embedded in HTML/XHTML files
  • SCSS files
  • Less files

and:

  • Computes metrics: lines of code, complexity, number of rules, etc.
  • Validates your CSS code
  • Checks for duplicated code
  • Checks various guidelines to find out potential bugs, vulnerabilities and code smells through more than:
  • Provides the ability to write your own checks

Usage

Installation Guide

  1. Download and install SonarQube
  2. Install the CSS / SCSS / Less plugin by a direct download. The latest version is compatible with SonarQube 6.7+.
  3. Install your favorite scanner (SonarQube Scanner, Maven, Ant, etc.)
  4. Analyze your code

Analyzing CSS code embedded in HTML/XHTML files

The plugin analyzes CSS code embedded in <style type="text/css">...</style> tags in HTML/XHTML files. To do so, as a prerequisite, SonarQube has to import those files. Either:

The list of files containing embedded CSS to analyze can be customized through the sonar.css.embedded.file.suffixes property.

stylelint / SonarQube Rule Mapping

If you are already using stylelint, adding SonarQube to your stack will help you bring code quality to another level. The stylelint / SonarQube rule mapping may be of great help to define your SonarQube quality profile.

Custom Checks

You're thinking of new valuable checks? Version 2.1 or greater provides an API to write your own custom checks. A sample plugin with detailed explanations is available here. If your custom checks may benefit the community, feel free to create a pull request in order to make the check available in the CSS / SCSS / Less analyzer.

You're thinking of new checks that may benefit the community but don't have the time or the skills to write them? Feel free to create an issue for your checks to be taken under consideration.

Metrics

Functions

Number of rules.

Complexity

The following elements increment the complexity by one:

  • Class selector
  • ID selector
  • Attribute selector
  • Type selector
  • Pseudo selector
  • Keyframes selector
  • At-rule

Complexity/function

It computes the complexity/rule, meaning the average number of selectors per rule. It gives a measurement on how specific the selectors are.

Available Rules

Common to CSS and SCSS and Less

  • "!important" flag should be placed at the end of the declaration
  • "!important" flag should not be used
  • "@font-face" rule should be made compatible with the required browsers
  • "FIXME" tags should be handled
  • "NOSONAR" tags should not be used to switch off issues
  • "stylelint-disable" tags should be removed
  • "stylelint-enable" tags should be removed
  • "text-transform" properties should not be set to "uppercase" or "capitalize" for some languages
  • "TODO" tags should be handled
  • @charset should be the first element in the style sheet and not be preceded by any character
  • Box model size should be carefully reviewed
  • Byte Order Mark (BOM) should not be used for UTF-8 files
  • Case-insensitive flag should not be used
  • Class selectors should follow a naming convention
  • CSS should be written in lower case
  • Deprecated system colors should not be used
  • Duplicated background images should be removed
  • Duplicated properties should be removed
  • Each declaration should end with a semicolon
  • Empty declarations should be removed
  • Empty rules should be removed
  • Empty stylesheets should be removed
  • Experimental @-rules should not be used
  • Experimental identifiers should not be used
  • Experimental properties should not be used
  • Experimental pseudo-elements and pseudo-classes should not be used
  • Experimental selector combinators should not be used
  • Files should contain an empty new line at the end
  • Files should not have too many lines
  • Font family names should be quoted
  • Font files inlining should not be used
  • font-family properties should end with a generic font family
  • font-family should not contain duplicated font family names
  • Forbidden properties should not be used
  • Generic font family names should not be quoted
  • Gradient definitions should be set for all vendors
  • ID selectors should follow a naming convention
  • IDs in selectors should be removed
  • Leading zeros should be removed
  • Lines should not be too long
  • Lines should not end with trailing whitespaces
  • Missing vendor prefixes should be added to experimental properties
  • Name of overqualified element should be removed
  • Named colors should not be used
  • Number precision should not be too high
  • Obsolete properties should not be used
  • Obsolete pseudo-elements and pseudo-classes should not be used
  • Obsolete selector combinators should not be used
  • Over-specified selectors should be simplified
  • Properties that do not work with the "display" property should be removed
  • Property values should be valid
  • Protocol-relative URL should not be used
  • Regular expression like selectors should not be used
  • Regular expression on @-rule
  • Regular expression on comment
  • Regular expression on function
  • Regular expression on property
  • Regular expression on unit
  • Rule properties should be alphabetically ordered
  • Shorthand properties should be used whenever possible
  • Shorthand properties should not be used
  • Single quotes should be used instead of double quotes for strings
  • Source code should comply with formatting standards
  • Standard properties should be specified along with vendor-prefixed properties
  • Star hack should not be used
  • Stylesheets should not contain too many rules
  • Stylesheets should not contain too many selectors
  • Tabulation characters should not be used
  • The number of web fonts should be reduced
  • There should be one single declaration per line
  • Trailing zeros for numeric values should be removed
  • Types in selectors should be removed
  • Underscore hack should not be used
  • Units for zero length values should be removed
  • Universal selector should not be used as key part
  • Unknown @-rules should be removed
  • Unknown properties should be removed
  • Unknown pseudo-elements and pseudo-classes should be removed
  • Unknown type selectors should be removed
  • URL 'paper.gif' should never be used
  • URL should be quoted

Specific to CSS

  • "@import" rule should not be used
  • @import rules should precede all other at-rules and style rules
  • CSS variables should follow a naming convention
  • Experimental functions should not be used
  • Obsolete functions should not be used
  • Stylesheets should not "@import" too many other sheets
  • Unknown CSS functions should be removed

Specific to CSS embedded in HTML/XHTML

  • CSS should not be embedded in HTML files

Specific to SCSS

  • @debug directives should not be used in production code
  • @extend directives should not be used
  • @if ... @else if ... constructs should end with @else directive
  • Always use 'through' instead of 'to' in @for directives
  • Conditions should not be too complex
  • Control flow directives @if, @else if, @else, @for, @while, and @each should not be nested too deeply
  • Custom functions should follow a naming convention
  • Declarations and directives should be properly sorted
  • Deprecated unescaped multiline strings should not be used
  • Empty control flow directive should be removed
  • Empty mixins should be removed
  • Mixins should follow a naming convention
  • Nested properties should define at least two properties
  • Placeholder selectors should follow a naming convention
  • Related @if / @else if directives should not have the same condition
  • Rulesets should not be nested too deeply
  • SCSS variables should follow a naming convention
  • Single-line comments (//) should be preferred over multi-line comments (/* ... */)
  • Two branches in the same conditional structure should not have exactly the same implementation
  • Useless parentheses following @include and @mixin with no parameter should be removed

Specific to Less

  • Deprecated "e" escaping function should be replaced with ~"value" syntax
  • Less variables should follow a naming convention
  • Rulesets should not be nested too deeply
  • Same variable should not be declared multiple times within the same scope
  • Single-line comments (//) should be preferred over multi-line comments (/* ... */)
  • Unknown CSS / Less functions should be removed
  • Variables should be declared at the beginning of the block
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].