Skip to content

Commit

Permalink
fix bug (DL4001 is too error lines) (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
zabio3 committed Jan 26, 2020
1 parent e71f29f commit 4895f13
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions linter/rules/dl4001.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@ import (
"github.com/moby/buildkit/frontend/dockerfile/parser"
)

// validateDL4001 Either use Wget or Curl but not both
// validateDL4001 is dockerfile linter DL4001 rule.
// Either use Wget or Curl but not both.
func validateDL4001(node *parser.Node) (rst []ValidateResult, err error) {
isCurl, isWget := false, false
var numArr []int
var lines []int
for _, child := range node.Children {
if child.Value == RUN {
for _, v := range strings.Fields(child.Next.Value) {
switch v {
case "curl":
isCurl = true
numArr = append(numArr, child.StartLine)
lines = append(lines, child.StartLine)
case "wget":
isWget = true
numArr = append(numArr, child.StartLine)
lines = append(lines, child.StartLine)
}
}
}
if isCurl && isWget {
for _, num := range numArr {
rst = append(rst, ValidateResult{line: num, addMsg: ""})
}
}
if isCurl && isWget {
for _, line := range lines {
rst = append(rst, ValidateResult{line: line, addMsg: ""})
}
}
return rst, nil
Expand Down

0 comments on commit 4895f13

Please sign in to comment.