Skip to content

Commit

Permalink
build(deps): bump github.com/denis-tingaikin/go-headerfrom 0.4.3 to 0…
Browse files Browse the repository at this point in the history
….5.0 (golangci#4396)

Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
  • Loading branch information
2 people authored and Antonboom committed Mar 3, 2024
1 parent 8dab491 commit cf7de0f
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
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
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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
default:
require.Failf(tb, "invalid prefix of comment line %s", line)
}

Expand Down

0 comments on commit cf7de0f

Please sign in to comment.