1.1.4 • Published 3 years ago

r-2-sonar v1.1.4

Weekly downloads
10
License
MIT
Repository
github
Last release
3 years ago

SonarQube R

Uploading your R project lintr information into SonarQube. This can be used as a plugin, to insert R language issues with sonar scanner.

Dependencies

You need to have the following

  • R (tested with version 4.0.3).

You need to have the following R libraries:

  • lintr
  • devtools
  • roxygen2

Usage

Install lintr packages and R.

Rscript -e 'install.packages("lintr")'
Rscript -e 'install.packages("devtools")'
Rscript -e 'install.packages("roxygen2")'

To generate the file lintr_out.json execute the command:

rscript .\run_lintr.R

The lintr generates a json file lintr_out.json with the issues found on your code. This format is not compatible with SonarQube and needs to follow the format:

So that Sonar Scanner is able to import the issues to SonarQube.

Issue fields description for Sonar.

  • engineId - string
  • ruleId - string
  • primaryLocation - Location object
  • type - string. One of BUG, VULNERABILITY, CODE_SMELL
  • severity - string. One of BLOCKER, CRITICAL, MAJOR, MINOR, INFO
  • effortMinutes - integer, optional. Defaults to 0
  • secondaryLocations - array of Location objects, optional

The mapping table is used to generate issue type, effort and severity required to ingest the information into SonarQube.

LinterIssue TypeEffort MinutesSeverity
object_usage_linterCODE_SMELL5MINOR
absolute_path_linterCODE_SMELL5MINOR
nonportable_path_linterCODE_SMELL5MINOR
pipe_continuation_linterCODE_SMELL5MINOR
assignment_linterCODE_SMELL5MINOR
camel_case_linterCODE_SMELL5MINOR
closed_curly_linterCODE_SMELL5MINOR
commas_linterCODE_SMELL5MINOR
commented_code_linterCODE_SMELL5MINOR
cyclocomp_linterCODE_SMELL5MINOR
equals_na_linterCODE_SMELL5MINOR
extraction_operator_linterCODE_SMELL5MINOR
function_left_parentheses_linterCODE_SMELL5MINOR
function_left_parentheses_linterCODE_SMELL5MINOR
implicit_integer_linterCODE_SMELL5MINOR
infix_spaces_linterCODE_SMELL5MINOR
line_length_linterCODE_SMELL5MINOR
no_tab_linterCODE_SMELL5MINOR
object_length_linterCODE_SMELL5MINOR
object_name_linterCODE_SMELL5MINOR
open_curly_linterCODE_SMELL5MINOR
paren_brace_linterCODE_SMELL5MINOR
semicolon_terminator_linterCODE_SMELL5MINOR
seq_linterCODE_SMELL5MINOR
single_quotes_linterCODE_SMELL5MINOR
spaces_inside_linterCODE_SMELL5MINOR
spaces_left_parentheses_linterCODE_SMELL5MINOR
todo_comment_linterCODE_SMELL5MINOR
trailing_blank_lines_linterCODE_SMELL5MINOR
trailing_whitespace_linterCODE_SMELL5MINOR
T_and_F_symbol_linterCODE_SMELL5MINOR
undesirable_function_linterCODE_SMELL5MINOR
undesirable_operator_linterCODE_SMELL5MINOR
unneeded_concatenation_linterCODE_SMELL5MINOR
other non specified in the tableCODE_SMELL5MINOR

Translating from lintr json into SonarQube json format can be done online via in this site:

Save the converted json as the lintr_out.json .

Add the following line to your sonar-project.properties file:

sonar.externalIssuesReportPaths=lintr_sonar_out.json

Execute sonar-scanner to upload the issues to SonarQube server.

Enjoy.

Contribute