0.01
No commit activity in last 3 years
No release in over 3 years
Danger plugin to analyse and report sonar violations in pull request Diff.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
~> 2.14
= 3.0.7
~> 0
~> 10.0
~> 3.4
~> 0.49.0
~> 0.9.11

Runtime

 Project Readme

danger-sonar

A danger plugin to check for Sonar violation.

Installation

$ gem install danger-sonar

Usage

Methods and attributes from this plugin are available in your Dangerfile under the sonar namespace.

Simply add below line to your Dangerfile:

sonar.json_report_file = 'sonar-report.json'
sonar.lint_files

Pass below options to Sonar Scanner to generate JSON report

-Dsonar.analysis.mode=preview -Dsonar.report.export.path=sonar-report.json

The .json will be generated inside the .sonar directory.

For inline comments in your PR, add below line to your Dangerfile:

sonar.lint_files inline_mode:true

To lint selected files, add below line to your Dangerfile:

sonar.lint_files [filename1, filename2, filename3,...]

To change messages, add below lines to your Dangerfile:

sonar.failure_message = "Sonar lint fialed due to violations, fix them to merge your PR"
sonar.warning_message = "Fix Sonar violtions"

To write custom rules based on Sonar violations, use below properties to get violations count

# To read blocker violations count
sonar.blocker_count 
# To read critical violations count
sonar.critical_count
# To read major violations count
sonar.major_count
# To read minor violations count
sonar.minor_count > 0

License

MIT

Development

  1. Clone this repo
  2. Run bundle install to setup dependencies.
  3. Run bundle exec rake spec to run the tests.
  4. Use bundle exec guard to automatically have tests run as you make changes.
  5. Make your changes.