Skip to content

Commit

Permalink
Merge branch 'konveyor:main' into 301-unify-conditional-interface-imp…
Browse files Browse the repository at this point in the history
…lementations-to-either-use-value-or-pointer-types
  • Loading branch information
JonahSussman authored Aug 29, 2023
2 parents 4e5c6f7 + 40129ff commit 96d996b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 2 additions & 0 deletions cmd/analyzer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func init() {
func main() {
if err := rootCmd.Execute(); err != nil {
println(err.Error())
} else if rootCmd.Flags().Changed("help") {
return
}

// This will globally prevent the yaml library from auto-wrapping lines at 80 characters
Expand Down
26 changes: 17 additions & 9 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,15 +406,6 @@ func (r *ruleEngine) createViolation(conditionResponse ConditionResponse, rule R
lineNumber := *m.LineNumber
incident.LineNumber = &lineNumber
}
links := []konveyor.Link{}
if len(m.Links) > 0 {
for _, l := range m.Links {
links = append(links, konveyor.Link{
URL: l.URL,
Title: l.Title,
})
}
}
// Some violations may not have a location in code.
limitSnip := (r.codeSnipLimit != 0 && fileCodeSnipCount[string(m.FileURI)] == r.codeSnipLimit)
if !limitSnip {
Expand Down Expand Up @@ -492,6 +483,8 @@ func (r *ruleEngine) createViolation(conditionResponse ConditionResponse, rule R
}
}

rule.Labels = deduplicateLabels(rule.Labels)

return konveyor.Violation{
Description: rule.Description,
Labels: rule.Labels,
Expand Down Expand Up @@ -558,3 +551,18 @@ func matchesAllSelectors(m RuleMeta, selectors ...RuleSelector) bool {
}
return true
}

func deduplicateLabels(labels []string) []string {
present := map[string]bool{}
uniquelabels := []string{}

for _, label := range labels {
if !present[label] {
present[label] = true
uniquelabels = append(uniquelabels, label)
}
}

return uniquelabels

}

0 comments on commit 96d996b

Please sign in to comment.