Skip to content

Commit

Permalink
fix(reporter): Prevent null in snippet report template
Browse files Browse the repository at this point in the history
A `null` value cannot be assigned to a variable in Freemarker. Hence, use
the empty string instead when there is no snippet limit issue.

Signed-off-by: Nicolas Nobelis <[email protected]>
  • Loading branch information
nnobelis authored and sschuberth committed May 22, 2024
1 parent 1636ddc commit f55ce56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ List of all the provenances with their files and snippets.

[#assign snippetsLimitIssue = helper.getSnippetsLimitIssue()]

[#if snippetsLimitIssue??]
[#if snippetsLimitIssue?has_content]
[WARNING]
====
${snippetsLimitIssue}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,16 @@ class FreemarkerTemplateProcessor(
input.ortResult.getOpenIssues(minSeverity = threshold).isNotEmpty()

/**
* If there are any issue caused by reaching the snippets limit, return the text of the issue. Otherwise reuturn
* 'null'.
* If there are any issue caused by reaching the snippets limit, return the text of the issue. Otherwise return
* the empty string.
*/
@Suppress("UNUSED") // This function is used in the templates.
fun getSnippetsLimitIssue() =
input.ortResult.scanner?.scanResults?.flatMap { result ->
result.summary.issues
}?.firstOrNull {
it.message.contains("snippets limit")
}?.message
}?.message.orEmpty()

/**
* Return `true` if there are any unresolved and non-excluded [RuleViolation]s whose severity is equal to or
Expand Down

0 comments on commit f55ce56

Please sign in to comment.