Compare commits
No commits in common. "bb63cb65ba3402daf44b34237faf6094231f07fc" and "b8c0465502f83d3d77fe66ce80a7af2e27c0578f" have entirely different histories.
bb63cb65ba
...
b8c0465502
|
@ -1 +1 @@
|
||||||
Subproject commit 8e202e7c501128d66b74121ecd8f09a98367f876
|
Subproject commit 6d82a1344fbbd994e8c63428e5c1759bd7ef4f6f
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3dc44926b28477928808deb17059e5fed7635094
|
Subproject commit 1e1d15265956703a14efb52a1aef82f2fecee46b
|
|
@ -1 +1 @@
|
||||||
Subproject commit da38c70c7f17b0c1e98883cf258176ecd2856598
|
Subproject commit a384a00736523d674851b6a58b383487b7328144
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8790cd7f3ad6bc5885cafda12f3f71a2a4ff9ea3
|
Subproject commit c7c905ebcfad171e0edba0485358744c49aad6e2
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8a91338da01c8fb0051b1d0183d503073535e337
|
Subproject commit 50ec9ccbb6d7fe9b5352a018b6ac6445ac5c354f
|
|
@ -1 +1 @@
|
||||||
Subproject commit c7965f56d9f0b72eb2b491d4d6eada3daddee4bc
|
Subproject commit dd11177f3c3cf21728a84d808595de887fe4807a
|
|
@ -9,8 +9,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Match struct {
|
type Match struct {
|
||||||
Keywords []string
|
Keyword []string
|
||||||
Score int
|
Score int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Conf struct {
|
type Conf struct {
|
||||||
|
@ -41,10 +41,9 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
score, comment := GetResult(formattedMessages, conf)
|
|
||||||
return stage.ParserResult{
|
return stage.ParserResult{
|
||||||
Score: score,
|
Score: GetScore(formattedMessages, conf),
|
||||||
Comment: comment,
|
Comment: GetComment(formattedMessages),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,32 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetResult(jsonMessages []JsonMessage, conf Conf) (int, string) {
|
func contains(arr []string, element string) bool {
|
||||||
score := conf.Score
|
for i := range arr {
|
||||||
comment := "### Test results summary\n\n"
|
// TODO: The keyword in json report might also be an array, need to split it
|
||||||
|
if strings.Contains(arr[i], element) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetScore(jsonMessages []JsonMessage, conf Conf) int {
|
||||||
|
fullmark := conf.Score
|
||||||
|
for _, jsonMessage := range jsonMessages {
|
||||||
|
keyword := jsonMessage.CheckName
|
||||||
|
for _, match := range conf.Matches {
|
||||||
|
if contains(match.Keyword, keyword) {
|
||||||
|
fullmark -= match.Score
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fullmark
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetComment(jsonMessages []JsonMessage) string {
|
||||||
|
res := "### Test results summary\n\n"
|
||||||
keys := [...]string{
|
keys := [...]string{
|
||||||
"codequality-unchecked-malloc-result",
|
"codequality-unchecked-malloc-result",
|
||||||
"codequality-no-global-variables",
|
"codequality-no-global-variables",
|
||||||
|
@ -33,29 +56,22 @@ func GetResult(jsonMessages []JsonMessage, conf Conf) (int, string) {
|
||||||
mapping[key] = 0
|
mapping[key] = 0
|
||||||
}
|
}
|
||||||
for _, jsonMessage := range jsonMessages {
|
for _, jsonMessage := range jsonMessages {
|
||||||
checkName := jsonMessage.CheckName
|
keyword := jsonMessage.CheckName
|
||||||
for _, match := range conf.Matches {
|
flag := true
|
||||||
for _, keyword := range match.Keywords {
|
|
||||||
// TODO: The keyword in json report might also be an array, need to split it
|
|
||||||
if strings.Contains(checkName, keyword) {
|
|
||||||
score -= match.Score
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
listed := false
|
|
||||||
for key := range mapping {
|
for key := range mapping {
|
||||||
if strings.Contains(checkName, key) {
|
if strings.Contains(keyword, key) {
|
||||||
mapping[key] += 1
|
mapping[key] += 1
|
||||||
listed = true
|
flag = false
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !listed {
|
if flag {
|
||||||
mapping["others"] += 1
|
mapping["others"] += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, key := range keys {
|
for i, key := range keys {
|
||||||
comment = fmt.Sprintf("%s%d. %s: %d\n", comment, i+1, key, mapping[key])
|
res = fmt.Sprintf("%s%d. %s: %d\n", res, i+1, key, mapping[key])
|
||||||
}
|
}
|
||||||
return score, comment
|
return res
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user