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

build(deps): bump github.com/denis-tingaikin/go-headerfrom 0.4.3 to 0.5.0 #4396

Merged
merged 6 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ require (
github.com/ckaznocha/intrange v0.1.0
github.com/curioswitch/go-reassign v0.2.0
github.com/daixiang0/gci v0.12.3
github.com/denis-tingaikin/go-header v0.4.3
github.com/denis-tingaikin/go-header v0.5.0
github.com/esimonov/ifshort v1.0.4
github.com/fatih/color v1.16.0
github.com/firefart/nonamedreturns v1.0.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions pkg/golinters/goheader.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ func runGoHeader(pass *analysis.Pass, conf *goheader.Configuration) ([]goanalysi
FromLinter: goHeaderName,
}

if fix := i.Fix(); fix != nil {
issue.LineRange = &result.Range{
From: issue.Line(),
To: issue.Line() + len(fix.Actual) - 1,
}
issue.Replacement = &result.Replacement{
NeedOnlyDelete: len(fix.Expected) == 0,
NewLines: fix.Expected,
}
}

issues = append(issues, goanalysis.NewIssue(&issue, pass))
}

Expand Down
1 change: 1 addition & 0 deletions pkg/lint/lintersdb/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ func (m *Manager) GetAllSupportedLinterConfigs() []*linter.Config {
linter.NewConfig(golinters.NewGoHeader(goheaderCfg)).
WithSince("v1.28.0").
WithPresets(linter.PresetStyle).
WithAutoFix().
WithURL("https://github.com/denis-tingaikin/go-header"),

linter.NewConfig(golinters.NewGoimports(goimportsCfg)).
Expand Down
9 changes: 9 additions & 0 deletions test/testdata/configs/go-header-fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
linters-settings:
goheader:
values:
const:
AUTHOR: The Awesome Project Authors
template: |-
Copyright 2024 {{ AUTHOR }}

Use of this source code is governed by LICENSE
6 changes: 6 additions & 0 deletions test/testdata/fix/in/go-header_1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright 1999 The Awesome Project Authors

//golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml
package p
8 changes: 8 additions & 0 deletions test/testdata/fix/in/go-header_2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* Copyright 1999 The Awesome Project Authors

Use of this source code is governed */

//golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml
package p
10 changes: 10 additions & 0 deletions test/testdata/fix/in/go-header_3.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
Copyright 1999 The Awesome

Use of this source code is governed by LICENSE
*/

//golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml
package p
8 changes: 8 additions & 0 deletions test/testdata/fix/out/go-header_1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2024 The Awesome Project Authors
//
// Use of this source code is governed by LICENSE

//golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml
package p
8 changes: 8 additions & 0 deletions test/testdata/fix/out/go-header_2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* Copyright 2024 The Awesome Project Authors

Use of this source code is governed by LICENSE */

//golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml
package p
10 changes: 10 additions & 0 deletions test/testdata/fix/out/go-header_3.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
Copyright 2024 The Awesome Project Authors

Use of this source code is governed by LICENSE
*/

//golangcitest:args -Egoheader
//golangcitest:expected_exitcode 0
//golangcitest:config_path testdata/configs/go-header-fix.yml
package p
8 changes: 7 additions & 1 deletion test/testshared/directives.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ func ParseTestDirectives(tb testing.TB, sourcePath string) *RunContext {
continue
}

if !strings.HasPrefix(line, "//golangcitest:") {
switch {
case strings.HasPrefix(line, "//golangcitest:"):
// Ok
case !strings.Contains(line, "golangcitest"):
// Assume this is a regular comment (required for go-header tests)
continue
ldez marked this conversation as resolved.
Show resolved Hide resolved
default:
require.Failf(tb, "invalid prefix of comment line %s", line)
}

Expand Down