The Wayback Machine - https://web.archive.org/web/20200916165945/https://github.com/brainagency/ruby-sonar-plugin-utils
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
tmp
 
 
 
 
 
 
 
 
 
 
 
 

README.md

ruby-sonar-plugin-utils

Contains a bunch of utility scripts to perform some file conversions and other preparation stuffs for original plugin.

Requirements

All scripts are pure Ruby scripts, so to be able to run provided scripts on your local machine you need:

  1. Have installed Ruby. The rvm is a good choice to do it!
  2. Install bundler gem by gem install bundler
  3. Install dependencies by running bundle install

Utility scripts

Convert rubocop rules into SonarQube profile rules

Command specification:

$ ./rubocop_rules_to_profile.rb -i <INPUT_FILE_PATH> -o <OUTPUT_FILE_PATH>

Converts an YAML file with Rubocop rules into XML file of SonarQube profile rules.

Details

Example of Rubocop rules file:

Style/AccessModifierIndentation:
  Description: Check indentation of private/protected visibility modifiers.
  StyleGuide: '#indent-public-private-protected'
  Enabled: true

Example of SQ profile rule definition part:

<rule>
  <repositoryKey>rubocop</repositoryKey>
  <key>Style/AccessModifierIndentation</key>
  <priority>MINOR</priority>   
</rule>

Default severity level mapping depending on the Rubocop's rule key:

KEY_PREFIX_MAPPING_TO_PRIORITY = {
  /^Style/       => SonarQube::RulePriorities::MINOR,
  /^Metrics/     => SonarQube::RulePriorities::INFO,
  /^Lint/        => SonarQube::RulePriorities::MINOR,
  /^Bundler/     => SonarQube::RulePriorities::INFO,
  /^Performance/ => SonarQube::RulePriorities::MINOR,
  /^Rails/       => SonarQube::RulePriorities::MINOR,
  /^Security/    => SonarQube::RulePriorities::CRITICAL
}

Convert rubocop rules into SonarQube rule definitions

Command specification:

$ ./rubocop_rules_to_sq_rule_definitions.rb -i <INPUT_FILE_PATH> -o <OUTPUT_FILE_PATH>

Converts an YAML file with Rubocop rules into XML file of SonarQube rule definitions.

Details

Example of Rubocop rules file:

Style/AccessModifierIndentation:
  Description: Check indentation of private/protected visibility modifiers.
  StyleGuide: '#indent-public-private-protected'
  Enabled: true

Example of SQ rule definition part:

<rules>
  <rule>
    <key>Style/AccessModifierIndentation</key>
    <priority>MINOR</priority>
    <name>Check indentation of private/protected visibility modifiers.</name>
    <description>Check indentation of private/protected visibility modifiers.</description>
    <type>CODE_SMELL</type>
    <status>ready</status>   
  </rule>
</rules>

Developing

Testing

All scripts are fully tested by unit tests. For running tests, please, use the following command:

$ bundle exec rake

About

Contains a bunch of utility scripts to perform some file conversions and other preparation stuffs for original plugin.

Topics

Resources

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.