Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
425 changes: 190 additions & 235 deletions analyzer_test.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
// Configuration represents go-header linter setup parameters
type Configuration struct {
// Values is map of values. Supports two types 'const` and `regexp`. Values can be used recursively.
Values map[string]map[string]string `yaml:"values"'`
Values map[string]map[string]string `yaml:"values"`
// Template is template for checking. Uses values.
Template string `yaml:"template"`
// TemplatePath path to the template file. Useful if need to load the template from a specific file.
Expand Down
4 changes: 4 additions & 0 deletions testdata/constvalue/constvalue.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// A 2020
// B

package constvalue
8 changes: 8 additions & 0 deletions testdata/constvalue/constvalue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
template: |-
A {{ YEAR }}
B

values:
const:
'YEAR': '2020'

7 changes: 7 additions & 0 deletions testdata/fix/blockcomment1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* mycompany.net
SPDX-License-Identifier: Foo */

// Package foo
package foo

func _() { println("Foo") }
8 changes: 8 additions & 0 deletions testdata/fix/blockcomment2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
mycompany.net
SPDX-License-Identifier: Foo */

// Package foo
package foo

func _() { println("Foo") }
8 changes: 8 additions & 0 deletions testdata/fix/blockcomment3.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* mycompany.net
SPDX-License-Identifier: Foo
*/

// Package foo
package foo

func _() { println("Foo") }
11 changes: 11 additions & 0 deletions testdata/fix/blockcomment4.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*

mycompany.net
SPDX-License-Identifier: Foo

*/

// Package foo
package foo

func _() { println("Foo") }
8 changes: 8 additions & 0 deletions testdata/fix/fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
template: |-
{{ MY COMPANY }}
SPDX-License-Identifier: Foo

values:
const:
'MY COMPANY': 'mycompany.com'

7 changes: 7 additions & 0 deletions testdata/fix/linecomment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// mycompany.net
// SPDX-License-Identifier: Foo

// Package foo
package foo

func _() { println("Foo") }
3 changes: 3 additions & 0 deletions testdata/headercomment/headercomment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*abc*/ // comment

package headercomment
1 change: 1 addition & 0 deletions testdata/headercomment/headercomment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
template: abc
3 changes: 3 additions & 0 deletions testdata/nestedvalues/nestedvalues.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// abcdefg

package nestedvalues
10 changes: 10 additions & 0 deletions testdata/nestedvalues/nestedvalues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
template: '{{ A }}'

values:
regexp:
'A': '[{{ B }}{{ C }}]{{D}}'
const:
'B': 'a-'
'C': 'z'
'D': '{{E}}'
'E': '{7}'
16 changes: 16 additions & 0 deletions testdata/readme/readme.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// mycompany.com
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package readme
18 changes: 18 additions & 0 deletions testdata/readme/readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
values:
const:
MY COMPANY: mycompany.com
template: |-
{{ MY COMPANY }}
SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
7 changes: 7 additions & 0 deletions testdata/regexpvalue/regexpvalue.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// A 2020
// B
// A 2020
// B
// TEXT

package regexpvalue
11 changes: 11 additions & 0 deletions testdata/regexpvalue/regexpvalue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
template: |-
{{COPYRIGHT HOLDER}}TEXT

values:
const:
'YEAR': '2020'
regexp:
'COPYRIGHT HOLDER': |-
(A {{ YEAR }}
(.*)
)+
7 changes: 7 additions & 0 deletions testdata/regexpvalue_issue/regexpvalue_issue.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// A 2020
// B
// A 2021
// B
// TEXT

package regexpvalue
11 changes: 11 additions & 0 deletions testdata/regexpvalue_issue/regexpvalue_issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
template: |-
{{COPYRIGHT HOLDER}}TEXT

values:
const:
'YEAR': '2020'
regexp:
'COPYRIGHT HOLDER': |-
(A {{ YEAR }}
(.*)
)+
Loading