Code Monkey home page Code Monkey logo

sonar-css-plugin's Introduction

SonarQube CSS / SCSS / Less Analyzer

Build Status Build status Quality Gate status Twitter

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

A live example is available here.

Usage

Installation Guide

  1. Download and install SonarQube
  2. Install the CSS / SCSS / Less plugin either by a direct download or through the update center. See plugin compatibility with SonarQube versions.
  3. Install your favorite scanner (SonarQube Scanner, Maven, Ant, etc.)
  4. Analyze your code

Getting Started in Two Minutes

For a quick try, a simple package and procedure is available at https://github.com/racodond/package-test-sonarqube-css

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.

Contributing

Any contribution is more than welcome!

You feel like:

  • Adding a new check? Just open an issue to discuss the value of your check. Once validated, code, don't forget to add a lot of unit tests and open a PR.
  • Maintaining the stylelint / SonarQube rule mapping? Just open a PR
  • Fixing some bugs or improving existing checks? Just open a PR.

sonar-css-plugin's People

Contributors

agabrys avatar christophelevis avatar dbolkensteyn avatar dgageot avatar ehartmann avatar ganncamp avatar ganntest avatar godin avatar julienlancelot avatar kalidasya avatar lindamartin avatar lopho avatar racodond avatar

Watchers

 avatar  avatar

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.