File tree Expand file tree Collapse file tree 4 files changed +50
-1
lines changed
fossid/src/main/resources/templates/asciidoc
freemarker/src/main/kotlin Expand file tree Collapse file tree 4 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,15 @@ List of all the provenances with their files and snippets.
31
31
32
32
[#if scanResult.scanner.name != "FossId" ] [#continue ] [/#if ]
33
33
34
+ [#assign snippetsLimitIssue = helper.getSnippetsLimitIssue() ]
35
+
36
+ [#if snippetsLimitIssue?? ]
37
+ [WARNING]
38
+ ====
39
+ ${snippetsLimitIssue}
40
+ ====
41
+ [/#if ]
42
+
34
43
[#if scanResult.provenance.vcsInfo?? ]
35
44
[#assign url = scanResult.provenance.vcsInfo.url ]
36
45
[#else ]
Original file line number Diff line number Diff line change @@ -198,6 +198,7 @@ class FreemarkerTemplateProcessor(
198
198
/* *
199
199
* A collection of helper functions for the Freemarker templates.
200
200
*/
201
+ @Suppress(" TooManyFunctions" )
201
202
class TemplateHelper (private val input : ReporterInput ) {
202
203
/* *
203
204
* Return only those [packages] that are a dependency of at least one of the provided [projects][projectIds].
@@ -277,6 +278,18 @@ class FreemarkerTemplateProcessor(
277
278
fun hasUnresolvedIssues (threshold : Severity = input.ortConfig.severeIssueThreshold) =
278
279
input.ortResult.getOpenIssues(minSeverity = threshold).isNotEmpty()
279
280
281
+ /* *
282
+ * If there are any issue caused by reaching the snippets limit, return the text of the issue. Otherwise reuturn
283
+ * 'null'.
284
+ */
285
+ @Suppress(" UNUSED" ) // This function is used in the templates.
286
+ fun getSnippetsLimitIssue () =
287
+ input.ortResult.scanner?.scanResults?.flatMap { result ->
288
+ result.summary.issues
289
+ }?.firstOrNull {
290
+ it.message.contains(" snippets limit" )
291
+ }?.message
292
+
280
293
/* *
281
294
* Return `true` if there are any unresolved and non-excluded [RuleViolation]s whose severity is equal to or
282
295
* greater than the [threshold], or `false` otherwise.
Original file line number Diff line number Diff line change @@ -195,6 +195,16 @@ internal suspend fun mapSnippetFindings(
195
195
results + = mappedSnippets
196
196
}
197
197
198
+ if (runningSnippetCount >= snippetsLimit) {
199
+ issues + = Issue (
200
+ source = " FossId" ,
201
+ message = " The snippets limit of $snippetsLimit has been reached. To see the possible remaining " +
202
+ " snippets, please perform a snippet choice for the snippets presents in the snippet report an " +
203
+ " rerun the scan." ,
204
+ severity = Severity .HINT
205
+ )
206
+ }
207
+
198
208
return results.also {
199
209
remainingSnippetChoices.forEach { snippetChoice ->
200
210
// The issue is created only if the chosen snippet does not correspond to a file marked by a previous run.
Original file line number Diff line number Diff line change @@ -758,7 +758,12 @@ class FossIdSnippetChoiceTest : WordSpec({
758
758
}
759
759
760
760
summary.snippetFindings.flatMap { it.snippets } shouldHaveSize 2
761
- // todo + test issue
761
+
762
+ summary.issues.forAtLeastOne {
763
+ it.message shouldBe " The snippets limit of 2 has been reached. To see the possible remaining " +
764
+ " snippets, please perform a snippet choice for the snippets presents in the snippet report an " +
765
+ " rerun the scan."
766
+ }
762
767
}
763
768
764
769
" list all the snippets of a file even if if goes over the snippets limit" {
@@ -796,6 +801,12 @@ class FossIdSnippetChoiceTest : WordSpec({
796
801
797
802
summary.snippetFindings shouldHaveSize 2
798
803
summary.snippetFindings.flatMap { it.snippets } shouldHaveSize 3
804
+
805
+ summary.issues.forAtLeastOne {
806
+ it.message shouldBe " The snippets limit of 2 has been reached. To see the possible remaining " +
807
+ " snippets, please perform a snippet choice for the snippets presents in the snippet report an " +
808
+ " rerun the scan."
809
+ }
799
810
}
800
811
801
812
" not count the chosen snippet when enforcing the snippet limits" {
@@ -840,6 +851,12 @@ class FossIdSnippetChoiceTest : WordSpec({
840
851
summary.snippetFindings.drop(1).forEach {
841
852
it.sourceLocation.path shouldBe FILE_2
842
853
}
854
+
855
+ summary.issues.forAtLeastOne {
856
+ it.message shouldBe " The snippets limit of 2 has been reached. To see the possible remaining " +
857
+ " snippets, please perform a snippet choice for the snippets presents in the snippet report an " +
858
+ " rerun the scan."
859
+ }
843
860
}
844
861
}
845
862
})
You can’t perform that action at this time.
0 commit comments