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_filesPass below options to Sonar Scanner to generate JSON report
-Dsonar.analysis.mode=preview -Dsonar.report.export.path=sonar-report.jsonThe .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:trueTo 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 > 0License
MIT
Development
- Clone this repo
- Run
bundle installto setup dependencies. - Run
bundle exec rake specto run the tests. - Use
bundle exec guardto automatically have tests run as you make changes. - Make your changes.