Skip to content

Commit

Permalink
minor lint formatting cleanups
Browse files Browse the repository at this point in the history
Signed-off-by: Talon Bowler <talon.bowler@docker.com>
  • Loading branch information
daghack committed Jun 10, 2024
1 parent 5760de7 commit ff10dcc
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions frontend/dockerfile/dockerfile2llb/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ func toDispatchState(ctx context.Context, dt []byte, opt ConvertOpt) (*dispatchS
// The `dockerfile.Warnings` *should* only contain warnings about empty continuation
// lines, but we'll check the warning message to be sure, so that we don't accidentally
// process warnings that are not related to empty continuation lines twice.
if warning.URL == linter.RuleNoEmptyContinuations.URL {
if warning.URL == linter.RuleNoEmptyContinuation.URL {
location := []parser.Range{*warning.Location}
msg := linter.RuleNoEmptyContinuations.Format()
lint.Run(&linter.RuleNoEmptyContinuations, location, msg)
msg := linter.RuleNoEmptyContinuation.Format()
lint.Run(&linter.RuleNoEmptyContinuation, location, msg)
}
}

Expand Down
8 changes: 4 additions & 4 deletions frontend/dockerfile/dockerfile_lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
var lintTests = integration.TestFuncs(
testRuleCheckOption,
testStageName,
testNoEmptyContinuations,
testNoEmptyContinuation,
testConsistentInstructionCasing,
testFileConsistentCommandCasing,
testDuplicateStageName,
Expand Down Expand Up @@ -237,7 +237,7 @@ from scratch as base2
})
}

func testNoEmptyContinuations(t *testing.T, sb integration.Sandbox) {
func testNoEmptyContinuation(t *testing.T, sb integration.Sandbox) {
dockerfile := []byte(`
FROM scratch
# warning: empty continuation line
Expand All @@ -252,9 +252,9 @@ COPY Dockerfile \
Dockerfile: dockerfile,
Warnings: []expectedLintWarning{
{
RuleName: "NoEmptyContinuations",
RuleName: "NoEmptyContinuation",
Description: "Empty continuation lines will become errors in a future release",
URL: "https://docs.docker.com/go/dockerfile/rule/no-empty-continuations/",
URL: "https://docs.docker.com/go/dockerfile/rule/no-empty-continuation/",
Detail: "Empty continuation line",
Level: 1,
Line: 6,
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 @@ $ docker build --check .
<td>The 'as' keyword should match the case of the 'from' keyword</td>
</tr>
<tr>
<td><a href="./no-empty-continuations.md">NoEmptyContinuations</a></td>
<td><a href="./no-empty-continuation.md">NoEmptyContinuation</a></td>
<td>Empty continuation lines will become errors in a future release</td>
</tr>
<tr>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: NoEmptyContinuations
title: NoEmptyContinuation
description: Empty continuation lines will become errors in a future release
aliases:
- /go/dockerfile/rule/no-empty-continuations/
- /go/dockerfile/rule/no-empty-continuation/
---

## Output
Expand Down
2 changes: 1 addition & 1 deletion frontend/dockerfile/linter/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (rule *LinterRule[F]) Run(warn LintWarnFunc, location []parser.Range, txt .
}

func LintFormatShort(rulename, msg string, startLine int) string {
return fmt.Sprintf("Lint Rule '%s': %s (line %d)", rulename, msg, startLine)
return fmt.Sprintf("%s: %s (line %d)", rulename, msg, startLine)
}

type LintWarnFunc func(rulename, description, url, fmtmsg string, location []parser.Range)
6 changes: 3 additions & 3 deletions frontend/dockerfile/linter/ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ var (
return fmt.Sprintf("'%s' and '%s' keywords' casing do not match", as, from)
},
}
RuleNoEmptyContinuations = LinterRule[func() string]{
Name: "NoEmptyContinuations",
RuleNoEmptyContinuation = LinterRule[func() string]{
Name: "NoEmptyContinuation",
Description: "Empty continuation lines will become errors in a future release",
URL: "https://docs.docker.com/go/dockerfile/rule/no-empty-continuations/",
URL: "https://docs.docker.com/go/dockerfile/rule/no-empty-continuation/",
Format: func() string {
return "Empty continuation line"
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/dockerfile/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func Parse(rwc io.Reader) (*Result, error) {
warnings = append(warnings, Warning{
Short: "Empty continuation line found in: " + line,
Detail: [][]byte{[]byte("Empty continuation lines will become errors in a future release")},
URL: "https://docs.docker.com/go/dockerfile/rule/no-empty-continuations/",
URL: "https://docs.docker.com/go/dockerfile/rule/no-empty-continuation/",
Location: &Range{Start: Position{Line: currentLine}, End: Position{Line: currentLine}},
})
}
Expand Down

0 comments on commit ff10dcc

Please sign in to comment.