Skip to content

Commit f55ce56

Browse files
nnobelissschuberth
authored andcommitted
fix(reporter): Prevent null in snippet report template
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]>
1 parent 1636ddc commit f55ce56

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

plugins/reporters/fossid/src/main/resources/templates/asciidoc/fossid_snippet.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ List of all the provenances with their files and snippets.
3333

3434
[#assign snippetsLimitIssue = helper.getSnippetsLimitIssue()]
3535

36-
[#if snippetsLimitIssue??]
36+
[#if snippetsLimitIssue?has_content]
3737
[WARNING]
3838
====
3939
${snippetsLimitIssue}

plugins/reporters/freemarker/src/main/kotlin/FreemarkerTemplateProcessor.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,16 +279,16 @@ class FreemarkerTemplateProcessor(
279279
input.ortResult.getOpenIssues(minSeverity = threshold).isNotEmpty()
280280

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

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

0 commit comments

Comments
 (0)