Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve consistency of linter rules messages #5470

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions frontend/dockerfile/dockerfile_lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
RuleName: "UndefinedVar",
Description: "Variables should be defined before their use",
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-var/",
Detail: "Usage of undefined variable '$bar'",
Detail: "Usage of undefined variable $bar",
Level: 1,
Line: 6,
},
Expand All @@ -322,15 +322,15 @@
RuleName: "UndefinedVar",
Description: "Variables should be defined before their use",
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-var/",
Detail: "Usage of undefined variable '$foo'",
Detail: "Usage of undefined variable $foo",
Level: 1,
Line: 3,
},
{
RuleName: "UndefinedVar",
Description: "Variables should be defined before their use",
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-var/",
Detail: "Usage of undefined variable '$bar'",
Detail: "Usage of undefined variable $bar",
Level: 1,
Line: 6,
},
Expand Down Expand Up @@ -374,7 +374,7 @@
RuleName: "FromAsCasing",
Description: "The 'as' keyword should match the case of the 'from' keyword",
URL: "https://docs.docker.com/go/dockerfile/rule/from-as-casing/",
Detail: "'as' and 'FROM' keywords' casing do not match",
Detail: "'as' and 'FROM' keywords' casing does not match",
Line: 2,
Level: 1,
},
Expand All @@ -392,7 +392,7 @@
RuleName: "FromAsCasing",
Description: "The 'as' keyword should match the case of the 'from' keyword",
URL: "https://docs.docker.com/go/dockerfile/rule/from-as-casing/",
Detail: "'as' and 'FROM' keywords' casing do not match",
Detail: "'as' and 'FROM' keywords' casing does not match",
Line: 2,
Level: 1,
},
Expand All @@ -413,7 +413,7 @@
RuleName: "FromAsCasing",
Description: "The 'as' keyword should match the case of the 'from' keyword",
URL: "https://docs.docker.com/go/dockerfile/rule/from-as-casing/",
Detail: "'as' and 'FROM' keywords' casing do not match",
Detail: "'as' and 'FROM' keywords' casing does not match",
Line: 2,
Level: 1,
},
Expand Down Expand Up @@ -465,7 +465,7 @@
RuleName: "FromAsCasing",
Description: "The 'as' keyword should match the case of the 'from' keyword",
URL: "https://docs.docker.com/go/dockerfile/rule/from-as-casing/",
Detail: "'as' and 'FROM' keywords' casing do not match",
Detail: "'as' and 'FROM' keywords' casing does not match",
Line: 8,
Level: 1,
},
Expand All @@ -487,7 +487,7 @@
RuleName: "FromAsCasing",
Description: "The 'as' keyword should match the case of the 'from' keyword",
URL: "https://docs.docker.com/go/dockerfile/rule/from-as-casing/",
Detail: "'AS' and 'from' keywords' casing do not match",
Detail: "'AS' and 'from' keywords' casing does not match",
Line: 4,
Level: 1,
},
Expand Down Expand Up @@ -535,7 +535,7 @@
RuleName: "ConsistentInstructionCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
Detail: "Command 'From' should match the case of the command majority (uppercase)",
Detail: "Command 'From' should match the case of the majority of commands (uppercase)",
Level: 1,
Line: 4,
},
Expand All @@ -556,7 +556,7 @@
RuleName: "ConsistentInstructionCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
Detail: "Command 'copy' should match the case of the command majority (uppercase)",
Detail: "Command 'copy' should match the case of the majority of commands (uppercase)",
Line: 4,
Level: 1,
},
Expand All @@ -576,7 +576,7 @@
RuleName: "ConsistentInstructionCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
Detail: "Command 'frOM' should match the case of the command majority (lowercase)",
Detail: "Command 'frOM' should match the case of the majority of commands (lowercase)",
Line: 4,
Level: 1,
},
Expand All @@ -596,7 +596,7 @@
RuleName: "ConsistentInstructionCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
Detail: "Command 'COPY' should match the case of the command majority (lowercase)",
Detail: "Command 'COPY' should match the case of the majority of commands (lowercase)",
Line: 4,
Level: 1,
},
Expand All @@ -618,7 +618,7 @@
RuleName: "ConsistentInstructionCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
Detail: "Command 'from' should match the case of the command majority (uppercase)",
Detail: "Command 'from' should match the case of the majority of commands (uppercase)",
Line: 4,
Level: 1,
},
Expand All @@ -640,7 +640,7 @@
RuleName: "ConsistentInstructionCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
Detail: "Command 'FROM' should match the case of the command majority (lowercase)",
Detail: "Command 'FROM' should match the case of the majority of commands (lowercase)",
Line: 4,
Level: 1,
},
Expand Down Expand Up @@ -1056,7 +1056,7 @@
RuleName: "UndefinedVar",
Description: "Variables should be defined before their use",
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-var/",
Detail: "Usage of undefined variable '$foo'",
Detail: "Usage of undefined variable $foo",
Level: 1,
Line: 3,
},
Expand All @@ -1079,7 +1079,7 @@
RuleName: "UndefinedVar",
Description: "Variables should be defined before their use",
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-var/",
Detail: "Usage of undefined variable '$DIR_ASSET' (did you mean $DIR_ASSETS?)",
Detail: "Usage of undefined variable $DIR_ASSET (did you mean $DIR_ASSETS?)",
Level: 1,
Line: 6,
},
Expand All @@ -1099,7 +1099,7 @@
RuleName: "UndefinedVar",
Description: "Variables should be defined before their use",
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-var/",
Detail: "Usage of undefined variable '$PAHT' (did you mean $PATH?)",
Detail: "Usage of undefined variable $PAHT (did you mean $PATH?)",
Level: 1,
Line: 3,
},
Expand Down Expand Up @@ -1187,15 +1187,15 @@
RuleName: "LegacyKeyValueFormat",
Description: "Legacy key/value format with whitespace separator should not be used",
URL: "https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/",
Detail: "\"ENV key=value\" should be used instead of legacy \"ENV key value\" format",
Detail: "`ENV key=value` should be used instead of legacy `ENV key value` format",
Line: 3,
Level: 1,
},
{
RuleName: "LegacyKeyValueFormat",
Description: "Legacy key/value format with whitespace separator should not be used",
URL: "https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/",
Detail: "\"LABEL key=value\" should be used instead of legacy \"LABEL key value\" format",
Detail: "`LABEL key=value` should be used instead of legacy `LABEL key value` format",
Line: 4,
Level: 1,
},
Expand Down Expand Up @@ -1227,15 +1227,15 @@
RuleName: "LegacyKeyValueFormat",
Description: "Legacy key/value format with whitespace separator should not be used",
URL: "https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/",
Detail: "\"ENV key=value\" should be used instead of legacy \"ENV key value\" format",
Detail: "`ENV key=value` should be used instead of legacy `ENV key value` format",
Line: 3,
Level: 1,
},
{
RuleName: "LegacyKeyValueFormat",
Description: "Legacy key/value format with whitespace separator should not be used",
URL: "https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/",
Detail: "\"LABEL key=value\" should be used instead of legacy \"LABEL key value\" format",
Detail: "`LABEL key=value` should be used instead of legacy `LABEL key value` format",
Line: 4,
Level: 1,
},
Expand Down Expand Up @@ -1502,7 +1502,7 @@
})
// Compare expectedLintWarning with actual lint results
for i, w := range lintResults.Warnings {
checkLintWarning(t, w, warnings[i])

Check failure on line 1505 in frontend/dockerfile/dockerfile_lint_test.go

View workflow job for this annotation

GitHub Actions / test-windows-amd64 (containerd, ./frontend/dockerfile)

Failed: frontend/dockerfile/TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#04

=== RUN TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#04 dockerfile_lint_test.go:1505: Error Trace: D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1665 D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1505 D:/a/buildkit/buildkit/frontend/gateway/grpcclient/client.go:215 D:/a/buildkit/buildkit/client/build.go:58 D:/a/buildkit/buildkit/client/solve.go:295 D:/a/buildkit/buildkit/vendor/golang.org/x/sync/errgroup/errgroup.go:78 C:/hostedtoolcache/windows/go/1.22.8/x64/src/runtime/asm_amd64.s:1695 Error: Not equal: expected: "The 'as' keyword should match the case of the 'from' keyword" actual : "The AS keyword should match the case of the FROM keyword" Diff: --- Expected +++ Actual @@ -1 +1 @@ -The 'as' keyword should match the case of the 'from' keyword +The AS keyword should match the case of the FROM keyword Test: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#04 dockerfile_lint_test.go:1518: Error Trace: D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1518 D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1649 Error: Should be true Test: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#04 --- FAIL: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#04 (0.16s)

Check failure on line 1505 in frontend/dockerfile/dockerfile_lint_test.go

View workflow job for this annotation

GitHub Actions / test-windows-amd64 (containerd, ./frontend/dockerfile)

Failed: frontend/dockerfile/TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#05

=== RUN TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#05 dockerfile_lint_test.go:1505: Error Trace: D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1665 D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1505 D:/a/buildkit/buildkit/frontend/gateway/grpcclient/client.go:215 D:/a/buildkit/buildkit/client/build.go:58 D:/a/buildkit/buildkit/client/solve.go:295 D:/a/buildkit/buildkit/vendor/golang.org/x/sync/errgroup/errgroup.go:78 C:/hostedtoolcache/windows/go/1.22.8/x64/src/runtime/asm_amd64.s:1695 Error: Not equal: expected: "The 'as' keyword should match the case of the 'from' keyword" actual : "The AS keyword should match the case of the FROM keyword" Diff: --- Expected +++ Actual @@ -1 +1 @@ -The 'as' keyword should match the case of the 'from' keyword +The AS keyword should match the case of the FROM keyword Test: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#05 dockerfile_lint_test.go:1518: Error Trace: D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1518 D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1649 Error: Should be true Test: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#05 --- FAIL: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#05 (0.19s)

Check failure on line 1505 in frontend/dockerfile/dockerfile_lint_test.go

View workflow job for this annotation

GitHub Actions / test-windows-amd64 (containerd, ./frontend/dockerfile)

Failed: frontend/dockerfile/TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#06

=== RUN TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#06 dockerfile_lint_test.go:1505: Error Trace: D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1665 D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1505 D:/a/buildkit/buildkit/frontend/gateway/grpcclient/client.go:215 D:/a/buildkit/buildkit/client/build.go:58 D:/a/buildkit/buildkit/client/solve.go:295 D:/a/buildkit/buildkit/vendor/golang.org/x/sync/errgroup/errgroup.go:78 C:/hostedtoolcache/windows/go/1.22.8/x64/src/runtime/asm_amd64.s:1695 Error: Not equal: expected: "The 'as' keyword should match the case of the 'from' keyword" actual : "The AS keyword should match the case of the FROM keyword" Diff: --- Expected +++ Actual @@ -1 +1 @@ -The 'as' keyword should match the case of the 'from' keyword +The AS keyword should match the case of the FROM keyword Test: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#06 dockerfile_lint_test.go:1518: Error Trace: D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1518 D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1649 Error: Should be true Test: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#06 --- FAIL: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=unmarshal#06 (0.14s)
}
called = true
return nil, nil
Expand Down Expand Up @@ -1642,7 +1642,7 @@
}

t.Run("warntype=progress", func(t *testing.T) {
checkProgressStream(t, sb, lintTest)

Check failure on line 1645 in frontend/dockerfile/dockerfile_lint_test.go

View workflow job for this annotation

GitHub Actions / test-windows-amd64 (containerd, ./frontend/dockerfile)

Failed: frontend/dockerfile/TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=progress#04

=== RUN TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=progress#04 dockerfile_lint_test.go:1645: Error Trace: D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1657 D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1611 D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1645 Error: Not equal: expected: "The 'as' keyword should match the case of the 'from' keyword" actual : "The AS keyword should match the case of the FROM keyword" Diff: --- Expected +++ Actual @@ -1 +1 @@ -The 'as' keyword should match the case of the 'from' keyword +The AS keyword should match the case of the FROM keyword Test: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=progress#04 --- FAIL: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=progress#04 (0.28s)

Check failure on line 1645 in frontend/dockerfile/dockerfile_lint_test.go

View workflow job for this annotation

GitHub Actions / test-windows-amd64 (containerd, ./frontend/dockerfile)

Failed: frontend/dockerfile/TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=progress#05

=== RUN TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=progress#05 dockerfile_lint_test.go:1645: Error Trace: D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1657 D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1611 D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1645 Error: Not equal: expected: "The 'as' keyword should match the case of the 'from' keyword" actual : "The AS keyword should match the case of the FROM keyword" Diff: --- Expected +++ Actual @@ -1 +1 @@ -The 'as' keyword should match the case of the 'from' keyword +The AS keyword should match the case of the FROM keyword Test: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=progress#05 --- FAIL: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=progress#05 (0.17s)

Check failure on line 1645 in frontend/dockerfile/dockerfile_lint_test.go

View workflow job for this annotation

GitHub Actions / test-windows-amd64 (containerd, ./frontend/dockerfile)

Failed: frontend/dockerfile/TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=progress#06

=== RUN TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=progress#06 dockerfile_lint_test.go:1645: Error Trace: D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1657 D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1611 D:/a/buildkit/buildkit/frontend/dockerfile/dockerfile_lint_test.go:1645 Error: Not equal: expected: "The 'as' keyword should match the case of the 'from' keyword" actual : "The AS keyword should match the case of the FROM keyword" Diff: --- Expected +++ Actual @@ -1 +1 @@ -The 'as' keyword should match the case of the 'from' keyword +The AS keyword should match the case of the FROM keyword Test: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=progress#06 --- FAIL: TestIntegration/TestRuleCheckOption/worker=containerd/frontend=builtin/warntype=progress#06 (0.17s)
})

t.Run("warntype=unmarshal", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/dockerfile/docs/rules/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ To learn more about how to use build checks, see
</tr>
<tr>
<td><a href="./from-as-casing/">FromAsCasing</a></td>
<td>The 'as' keyword should match the case of the 'from' keyword</td>
<td>The AS keyword should match the case of the FROM keyword</td>
</tr>
<tr>
<td><a href="./no-empty-continuation/">NoEmptyContinuation</a></td>
Expand Down
5 changes: 2 additions & 3 deletions frontend/dockerfile/docs/rules/from-as-casing.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
title: FromAsCasing
description: >-
The 'as' keyword should match the case of the 'from' keyword
The AS keyword should match the case of the FROM keyword
aliases:
- /go/dockerfile/rule/from-as-casing/
---

## Output

```text
'as' and 'FROM' keywords' casing do not match
'as' and 'FROM' keywords' casing does not match
```

## Description
Expand Down Expand Up @@ -42,4 +42,3 @@ from debian:latest as deb-builder
## Related errors

- [`FileConsistentCommandCasing`](./consistent-instruction-casing.md)

2 changes: 1 addition & 1 deletion frontend/dockerfile/docs/rules/legacy-key-value-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ aliases:
## Output

```text
"ENV key=value" should be used instead of legacy "ENV key value" format
`ENV key=value` should be used instead of legacy `ENV key value` format
```

## Description
Expand Down
4 changes: 2 additions & 2 deletions frontend/dockerfile/docs/rules/undefined-var.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ aliases:
## Output

```text
Usage of undefined variable '$foo'
Usage of undefined variable $foo
```

## Description
Expand All @@ -35,7 +35,7 @@ ENV PATH=$PAHT:/app/bin
The check identifies that `$PAHT` is undefined and likely a typo for `$PATH`:

```text
Usage of undefined variable '$PAHT' (did you mean $PATH?)
Usage of undefined variable $PAHT (did you mean $PATH?)
```

## Examples
Expand Down
2 changes: 1 addition & 1 deletion frontend/dockerfile/linter/docs/FromAsCasing.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Output

```text
'as' and 'FROM' keywords' casing do not match
'as' and 'FROM' keywords' casing does not match
```

## Description
Expand Down
2 changes: 1 addition & 1 deletion frontend/dockerfile/linter/docs/LegacyKeyValueFormat.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Output

```text
"ENV key=value" should be used instead of legacy "ENV key value" format
`ENV key=value` should be used instead of legacy `ENV key value` format
```

## Description
Expand Down
4 changes: 2 additions & 2 deletions frontend/dockerfile/linter/docs/UndefinedVar.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Output

```text
Usage of undefined variable '$foo'
Usage of undefined variable $foo
```

## Description
Expand All @@ -27,7 +27,7 @@ ENV PATH=$PAHT:/app/bin
The check identifies that `$PAHT` is undefined and likely a typo for `$PATH`:

```text
Usage of undefined variable '$PAHT' (did you mean $PATH?)
Usage of undefined variable $PAHT (did you mean $PATH?)
```

## Examples
Expand Down
30 changes: 15 additions & 15 deletions frontend/dockerfile/linter/ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ var (
}
RuleFromAsCasing = LinterRule[func(string, string) string]{
Name: "FromAsCasing",
Description: "The 'as' keyword should match the case of the 'from' keyword",
Description: "The AS keyword should match the case of the FROM keyword",
URL: "https://docs.docker.com/go/dockerfile/rule/from-as-casing/",
Format: func(from, as string) string {
return fmt.Sprintf("'%s' and '%s' keywords' casing do not match", as, from)
return fmt.Sprintf("'%s' and '%s' keywords' casing does not match", as, from)
},
}
RuleNoEmptyContinuation = LinterRule[func() string]{
Expand All @@ -34,23 +34,23 @@ var (
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
Format: func(violatingCommand, correctCasing string) string {
return fmt.Sprintf("Command '%s' should match the case of the command majority (%s)", violatingCommand, correctCasing)
return fmt.Sprintf("Command '%s' should match the case of the majority of commands (%s)", violatingCommand, correctCasing)
},
}
RuleDuplicateStageName = LinterRule[func(string) string]{
Name: "DuplicateStageName",
Description: "Stage names should be unique",
URL: "https://docs.docker.com/go/dockerfile/rule/duplicate-stage-name/",
Format: func(stageName string) string {
return fmt.Sprintf("Duplicate stage name %q, stage names should be unique", stageName)
return fmt.Sprintf("Duplicate stage name '%q', stage names should be unique", stageName)
},
}
RuleReservedStageName = LinterRule[func(string) string]{
Name: "ReservedStageName",
Description: "Reserved words should not be used as stage names",
URL: "https://docs.docker.com/go/dockerfile/rule/reserved-stage-name/",
Format: func(reservedStageName string) string {
return fmt.Sprintf("Stage name should not use the same name as reserved stage %q", reservedStageName)
return fmt.Sprintf("Stage name should not use the same name as the reserved stage %q", reservedStageName)
},
}
RuleJSONArgsRecommended = LinterRule[func(instructionName string) string]{
Expand All @@ -74,27 +74,27 @@ var (
Description: "FROM command must use declared ARGs",
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-arg-in-from/",
Format: func(baseArg, suggest string) string {
out := fmt.Sprintf("FROM argument '%s' is not declared", baseArg)
out := fmt.Sprintf("FROM argument $%s is not declared", baseArg)
if suggest != "" {
out += fmt.Sprintf(" (did you mean %s?)", suggest)
out += fmt.Sprintf(" (did you mean $%s?)", suggest)
}
return out
},
}
RuleWorkdirRelativePath = LinterRule[func(workdir string) string]{
Name: "WorkdirRelativePath",
Description: "Relative workdir without an absolute workdir declared within the build can have unexpected results if the base image changes",
Description: "Relative WORKDIR without an absolute WORKDIR declared within the build can have unexpected results if the base image changes",
URL: "https://docs.docker.com/go/dockerfile/rule/workdir-relative-path/",
Format: func(workdir string) string {
return fmt.Sprintf("Relative workdir %q can have unexpected results if the base image changes", workdir)
return fmt.Sprintf("Relative WORKDIR %q can have unexpected results if the base image changes", workdir)
},
}
RuleUndefinedVar = LinterRule[func(string, string) string]{
Name: "UndefinedVar",
Description: "Variables should be defined before their use",
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-var/",
Format: func(arg, suggest string) string {
out := fmt.Sprintf("Usage of undefined variable '$%s'", arg)
out := fmt.Sprintf("Usage of undefined variable $%s", arg)
if suggest != "" {
out += fmt.Sprintf(" (did you mean $%s?)", suggest)
}
Expand All @@ -114,14 +114,14 @@ var (
Description: "Legacy key/value format with whitespace separator should not be used",
URL: "https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/",
Format: func(cmdName string) string {
return fmt.Sprintf("\"%s key=value\" should be used instead of legacy \"%s key value\" format", cmdName, cmdName)
return fmt.Sprintf("`%s key=value` should be used instead of legacy `%s key value` format", cmdName, cmdName)
},
}
RuleInvalidBaseImagePlatform = LinterRule[func(string, string, string) string]{
Name: "InvalidBaseImagePlatform",
Description: "Base image platform does not match expected target platform",
Format: func(image, expected, actual string) string {
return fmt.Sprintf("Base image %s was pulled with platform %q, expected %q for current build", image, actual, expected)
return fmt.Sprintf("Base image '%s' was pulled with platform '%q', expected '%q' for current build", image, actual, expected)
},
}
RuleRedundantTargetPlatform = LinterRule[func(string) string]{
Expand Down Expand Up @@ -153,15 +153,15 @@ var (
Description: "FROM --platform flag should not use a constant value",
URL: "https://docs.docker.com/go/dockerfile/rule/from-platform-flag-const-disallowed/",
Format: func(platform string) string {
return fmt.Sprintf("FROM --platform flag should not use constant value %q", platform)
return fmt.Sprintf("FROM --platform flag should not use constant value '%q'", platform)
},
}
RuleCopyIgnoredFile = LinterRule[func(string, string) string]{
Name: "CopyIgnoredFile",
Description: "Attempting to Copy file that is excluded by .dockerignore",
Description: "Attempting to COPY/ADD file that is excluded by .dockerignore",
URL: "https://docs.docker.com/go/dockerfile/rule/copy-ignored-file/",
Format: func(cmd, file string) string {
return fmt.Sprintf("Attempting to %s file %q that is excluded by .dockerignore", cmd, file)
return fmt.Sprintf("Attempting to %s file '%q' that is excluded by .dockerignore", cmd, file)
},
Experimental: true,
}
Expand Down
Loading