{"id":16400968,"url":"https://github.com/racodond/sonar-css-plugin","last_synced_at":"2025-10-12T00:40:28.413Z","repository":{"id":53290219,"uuid":"83664920","full_name":"racodond/sonar-css-plugin","owner":"racodond","description":"SonarQube CSS / SCSS / Less Analyzer","archived":false,"fork":false,"pushed_at":"2022-06-28T23:27:03.000Z","size":5948,"stargazers_count":48,"open_issues_count":13,"forks_count":24,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-08-02T17:49:26.329Z","etag":null,"topics":["code-quality","css","guidelines","less","linter","scss","sonarqube","sonarqube-plugin","static-analysis","static-analyzer","styleguide","stylelint"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/racodond.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-02T10:21:50.000Z","updated_at":"2024-08-12T10:48:25.000Z","dependencies_parsed_at":"2022-08-19T19:21:20.520Z","dependency_job_id":null,"html_url":"https://github.com/racodond/sonar-css-plugin","commit_stats":null,"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"purl":"pkg:github/racodond/sonar-css-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/racodond%2Fsonar-css-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/racodond%2Fsonar-css-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/racodond%2Fsonar-css-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/racodond%2Fsonar-css-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/racodond","download_url":"https://codeload.github.com/racodond/sonar-css-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/racodond%2Fsonar-css-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009509,"owners_count":26084609,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-quality","css","guidelines","less","linter","scss","sonarqube","sonarqube-plugin","static-analysis","static-analyzer","styleguide","stylelint"],"created_at":"2024-10-11T05:29:06.506Z","updated_at":"2025-10-12T00:40:28.397Z","avatar_url":"https://github.com/racodond.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Release](https://img.shields.io/github/release/racodond/sonar-css-plugin.svg)](https://github.com/racodond/sonar-css-plugin/releases/latest)\n[![Build Status](https://api.travis-ci.org/racodond/sonar-css-plugin.svg?branch=master)](https://travis-ci.org/racodond/sonar-css-plugin)\n[![Build status](https://ci.appveyor.com/api/projects/status/jkl46pwunl60soio/branch/master?svg=true)](https://ci.appveyor.com/project/racodond/sonar-css-plugin-oy7u9/branch/master)\n\n[![Quality Gate status](https://sonarcloud.io/api/project_badges/measure?project=org.codehaus.sonar-plugins.css%3Acss\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=org.codehaus.sonar-plugins.css%3Acss)\n[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=org.codehaus.sonar-plugins.css%3Acss\u0026metric=ncloc)](https://sonarcloud.io/dashboard?id=org.codehaus.sonar-plugins.css%3Acss)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=org.codehaus.sonar-plugins.css%3Acss\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=org.codehaus.sonar-plugins.css%3Acss)\n\n\n# SonarQube CSS / SCSS / Less Analyzer\n\n## Disclaimer\nI don't want to keep maintaining this plugin. Feel free to ping me if you want to take over.\n\n## Description\nThis [SonarQube](http://www.sonarqube.org) plugin analyzes:\n\n* [CSS](https://www.w3.org/Style/CSS/) files\n* [CSS](https://www.w3.org/Style/CSS/) code embedded in HTML/XHTML files\n* [SCSS](http://sass-lang.com/) files\n* [Less](http://lesscss.org/) files\n \nand:\n\n* Computes metrics: lines of code, complexity, number of rules, etc.\n* Validates your CSS code\n* Checks for duplicated code\n* Checks various guidelines to find out potential bugs, vulnerabilities and code smells through more than:\n  * [80 checks](#available-rules) on CSS code\n  * [90 checks](#available-rules) on SCSS code\n  * [80 checks](#available-rules) on Less code\n* Provides the ability to write your own checks\n\n\n## Usage\n\n### Installation Guide\n1. [Download and install](http://docs.sonarqube.org/display/SONAR/Setup+and+Upgrade) SonarQube\n1. Install the CSS / SCSS / Less plugin by a [direct download](https://github.com/racodond/sonar-css-plugin/releases). The latest version is compatible with SonarQube 6.7+.\n1. Install your [favorite scanner](http://docs.sonarqube.org/display/SONAR/Analyzing+Source+Code#AnalyzingSourceCode-RunningAnalysis) (SonarQube Scanner, Maven, Ant, etc.)\n1. [Analyze your code](http://docs.sonarqube.org/display/SONAR/Analyzing+Source+Code#AnalyzingSourceCode-RunningAnalysis)\n\n### Analyzing CSS code embedded in HTML/XHTML files\nThe plugin analyzes CSS code embedded in `\u003cstyle type=\"text/css\"\u003e...\u003c/style\u003e` tags in HTML/XHTML files.\nTo do so, as a prerequisite, SonarQube has to import those files. Either:\n\n* Install a plugin importing those files ([Web plugin](http://docs.sonarqube.org/display/PLUG/Web+Plugin) for instance)\n* Or turn on the [import of unknown files](http://docs.sonarqube.org/display/SONAR/Analyzing+Source+Code#AnalyzingSourceCode-Unrecognizedfiles) by setting property `sonar.import_unknown_files` to `true` \n\nThe list of files containing embedded CSS to analyze can be customized through the `sonar.css.embedded.file.suffixes` property.\n\n\n## stylelint / SonarQube Rule Mapping\nIf you are already using [stylelint](https://stylelint.io/), adding SonarQube to your stack will help you bring code quality to another level.\nThe [stylelint / SonarQube rule mapping](doc/stylelint-sonarqube-rule-mapping.md) may be of great help to define your [SonarQube quality profile](https://docs.sonarqube.org/display/SONAR/Quality+Profiles).\n\n\n## Custom Checks\nYou're thinking of new valuable checks? Version 2.1 or greater provides an API to write your own custom checks.\nA sample plugin with detailed explanations is available [here](https://github.com/racodond/sonar-css-custom-rules-plugin).\nIf 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.\n\nYou'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](https://github.com/racodond/sonar-css-plugin/issues) for your checks to be taken under consideration.\n\n\n## Metrics\n\n### Functions\nNumber of rules.\n\n### Complexity\nThe following elements increment the complexity by one:\n\n* Class selector\n* ID selector\n* Attribute selector\n* Type selector\n* Pseudo selector\n* Keyframes selector\n* At-rule\n\n### Complexity/function\nIt computes the complexity/rule, meaning the average number of selectors per rule. It gives a measurement on how specific the selectors are.\n\n\n## Available Rules\n\n### Common to CSS and SCSS and Less\n\n* \"!important\" flag should be placed at the end of the declaration\n* \"!important\" flag should not be used\n* \"@font-face\" rule should be made compatible with the required browsers\n* \"FIXME\" tags should be handled\n* \"NOSONAR\" tags should not be used to switch off issues\n* \"stylelint-disable\" tags should be removed\n* \"stylelint-enable\" tags should be removed\n* \"text-transform\" properties should not be set to \"uppercase\" or \"capitalize\" for some languages\n* \"TODO\" tags should be handled\n* @charset should be the first element in the style sheet and not be preceded by any character\n* Box model size should be carefully reviewed\n* Byte Order Mark (BOM) should not be used for UTF-8 files\n* Case-insensitive flag should not be used\n* Class selectors should follow a naming convention\n* CSS should be written in lower case\n* Deprecated system colors should not be used\n* Duplicated background images should be removed\n* Duplicated properties should be removed\n* Each declaration should end with a semicolon\n* Empty declarations should be removed\n* Empty rules should be removed\n* Empty stylesheets should be removed\n* Experimental @-rules should not be used\n* Experimental identifiers should not be used\n* Experimental properties should not be used\n* Experimental pseudo-elements and pseudo-classes should not be used\n* Experimental selector combinators should not be used\n* Files should contain an empty new line at the end\n* Files should not have too many lines\n* Font family names should be quoted\n* Font files inlining should not be used\n* font-family properties should end with a generic font family\n* font-family should not contain duplicated font family names\n* Forbidden properties should not be used\n* Generic font family names should not be quoted\n* Gradient definitions should be set for all vendors\n* ID selectors should follow a naming convention\n* IDs in selectors should be removed\n* Leading zeros should be removed\n* Lines should not be too long\n* Lines should not end with trailing whitespaces\n* Missing vendor prefixes should be added to experimental properties\n* Name of overqualified element should be removed\n* Named colors should not be used\n* Number precision should not be too high\n* Obsolete properties should not be used\n* Obsolete pseudo-elements and pseudo-classes should not be used\n* Obsolete selector combinators should not be used\n* Over-specified selectors should be simplified\n* Properties that do not work with the \"display\" property should be removed\n* Property values should be valid\n* Protocol-relative URL should not be used\n* Regular expression like selectors should not be used\n* Regular expression on @-rule\n* Regular expression on comment\n* Regular expression on function\n* Regular expression on property\n* Regular expression on unit\n* Rule properties should be alphabetically ordered\n* Shorthand properties should be used whenever possible\n* Shorthand properties should not be used\n* Single quotes should be used instead of double quotes for strings\n* Source code should comply with formatting standards\n* Standard properties should be specified along with vendor-prefixed properties\n* Star hack should not be used\n* Stylesheets should not contain too many rules\n* Stylesheets should not contain too many selectors\n* Tabulation characters should not be used\n* The number of web fonts should be reduced\n* There should be one single declaration per line\n* Trailing zeros for numeric values should be removed\n* Types in selectors should be removed\n* Underscore hack should not be used\n* Units for zero length values should be removed\n* Universal selector should not be used as key part\n* Unknown @-rules should be removed\n* Unknown properties should be removed\n* Unknown pseudo-elements and pseudo-classes should be removed\n* Unknown type selectors should be removed\n* URL 'paper.gif' should never be used\n* URL should be quoted\n\n\n### Specific to CSS\n\n* \"@import\" rule should not be used\n* @import rules should precede all other at-rules and style rules\n* CSS variables should follow a naming convention\n* Experimental functions should not be used\n* Obsolete functions should not be used\n* Stylesheets should not \"@import\" too many other sheets\n* Unknown CSS functions should be removed\n\n\n### Specific to CSS embedded in HTML/XHTML\n\n* CSS should not be embedded in HTML files\n\n\n### Specific to SCSS\n\n* @debug directives should not be used in production code\n* @extend directives should not be used\n* @if ... @else if ... constructs should end with @else directive\n* Always use 'through' instead of 'to' in @for directives\n* Conditions should not be too complex\n* Control flow directives @if, @else if, @else, @for, @while, and @each should not be nested too deeply\n* Custom functions should follow a naming convention\n* Declarations and directives should be properly sorted\n* Deprecated unescaped multiline strings should not be used\n* Empty control flow directive should be removed\n* Empty mixins should be removed\n* Mixins should follow a naming convention\n* Nested properties should define at least two properties\n* Placeholder selectors should follow a naming convention\n* Related @if / @else if directives should not have the same condition\n* Rulesets should not be nested too deeply\n* SCSS variables should follow a naming convention\n* Single-line comments (//) should be preferred over multi-line comments (/* ... */)\n* Two branches in the same conditional structure should not have exactly the same implementation\n* Useless parentheses following @include and @mixin with no parameter should be removed\n\n\n### Specific to Less\n\n* Deprecated \"e\" escaping function should be replaced with ~\"value\" syntax\n* Less variables should follow a naming convention\n* Rulesets should not be nested too deeply\n* Same variable should not be declared multiple times within the same scope\n* Single-line comments (//) should be preferred over multi-line comments (/* ... */)\n* Unknown CSS / Less functions should be removed\n* Variables should be declared at the beginning of the block\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fracodond%2Fsonar-css-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fracodond%2Fsonar-css-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fracodond%2Fsonar-css-plugin/lists"}