forked from Checkmarx/kics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomments.go
39 lines (35 loc) · 852 Bytes
/
comments.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package model
// RemoveDuplicates removes duplicate lines from a slice of lines.
func RemoveDuplicates(lines []int) []int {
seen := make(map[int]bool)
var result []int
for _, line := range lines {
if !seen[line] {
result = append(result, line)
seen[line] = true
}
}
return result
}
// ProcessCommands processes a slice of commands.
func ProcessCommands(commands []string) CommentCommand {
for _, command := range commands {
switch com := CommentCommand(command); com {
case IgnoreLine:
return IgnoreLine
case IgnoreBlock:
return IgnoreBlock
default:
continue
}
}
return CommentCommand(commands[0])
}
// Range returns a slice of lines between the start and end line numbers.
func Range(start, end int) (lines []int) {
lines = make([]int, end-start+1)
for i := range lines {
lines[i] = start + i
}
return
}