debt_index() and quality_score() give a single project-wide number,
but they don't tell you where to start fixing things. sonar_hotspots()
fills that gap: it breaks the technical debt down per file and ranks
files from the most to the least costly to remediate – the R equivalent
of SonarQube's "Code Smells" / hotspots view, which developers use to
prioritize their first pull request after an audit.
Usage
sonar_hotspots(
x,
n = 10,
cost_lint_error = 30,
cost_lint_warning = 10,
cost_lint_style = 2,
cost_style = 5
)Arguments
- x
An
rsonar_resultobject returned bysonar_analyse().- n
Maximum number of files to return. Default
10.- cost_lint_error
Cost in minutes per lint issue of type
error. Default30.- cost_lint_warning
Cost in minutes per lint warning. Default
10.- cost_lint_style
Cost in minutes per lint style violation. Default
2.- cost_style
Cost in minutes per improperly formatted file (styler). Default
5.
Value
An rsonar_hotspots object (a data frame) with one row per file,
ordered by decreasing debt, containing the columns:
rankRank position,
1= highest debtfileFile path, relative to the analyzed project
lint_errors,lint_warnings,lint_styleIssue counts by severity, from lintr
style_issueTRUEif the file needs re-formatting (styler)coverage_pctLine coverage for the file, or
NAif coverage was not computed or the file has no coverage datadebt_minutesEstimated remediation effort, in minutes
Examples
if (FALSE) { # \dontrun{
res <- sonar_analyse(".")
# The 10 files that concentrate the most technical debt
hotspots <- sonar_hotspots(res)
print(hotspots)
# Only the top 3, with custom weights
sonar_hotspots(res, n = 3, cost_lint_error = 60)
} # }