Skip to content

Commit

Permalink
Test tags (#97)
Browse files Browse the repository at this point in the history
* Test tags

* Don't repeat tags when merging
  • Loading branch information
BraisGabin committed Feb 13, 2024
1 parent 90566d8 commit 6726d57
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/commonMain/kotlin/io/github/detekt/sarif4k/Merging.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fun SarifSchema210.merge(other: SarifSchema210): SarifSchema210 {

fun PropertyBag?.merge(other: PropertyBag?): PropertyBag? {
return (this?.tags.orEmpty() + other?.tags.orEmpty())
.distinct()
.takeIf { it.isNotEmpty() }
?.let { PropertyBag(it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class SarifSerializerTest {
startLine = 1,
startColumn = 1
)
),
properties = PropertyBag(
tags = listOf("tag")
)
)
)
Expand Down
8 changes: 7 additions & 1 deletion src/jvmTest/resources/input_1.sarif.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,11 @@
}
}
}
]
],
"properties": {
"tags": [
"tag",
"tag1"
]
}
}
8 changes: 7 additions & 1 deletion src/jvmTest/resources/input_2.sarif.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,11 @@
}
}
}
]
],
"properties": {
"tags": [
"tag",
"tag2"
]
}
}
9 changes: 8 additions & 1 deletion src/jvmTest/resources/output.sarif.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,12 @@
}
}
}
]
],
"properties": {
"tags": [
"tag",
"tag1",
"tag2"
]
}
}
8 changes: 7 additions & 1 deletion src/jvmTest/resources/output_different_tool.sarif.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,11 @@
}
}
}
]
],
"properties": {
"tags": [
"tag",
"tag1"
]
}
}
5 changes: 5 additions & 0 deletions src/jvmTest/resources/test.sarif.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
"startColumn": 1,
"startLine": 1
}
},
"properties": {
"tags": [
"tag"
]
}
}
],
Expand Down

0 comments on commit 6726d57

Please sign in to comment.