mirror of
https://github.com/scratchfoundation/golangci-lint.git
synced 2025-07-28 06:59:10 -04:00
Add go-header linter (#1181)
* add go-header linter * apply review comments: add goheader example into .golangci.example.yml * apply review comments: correctly handle multiline comments
This commit is contained in:
parent
b22e3f1874
commit
01b566a646
9 changed files with 139 additions and 1 deletions
test
|
@ -173,6 +173,12 @@ func buildConfigFromShortRepr(t *testing.T, repr string, config map[string]inter
|
|||
lastObj[keyParts[len(keyParts)-1]] = kv[1]
|
||||
}
|
||||
|
||||
func skipMultilineComment(scanner *bufio.Scanner) {
|
||||
for line := scanner.Text(); !strings.Contains(line, "*/") && scanner.Scan(); {
|
||||
line = scanner.Text()
|
||||
}
|
||||
}
|
||||
|
||||
func extractRunContextFromComments(t *testing.T, sourcePath string) *runContext {
|
||||
f, err := os.Open(sourcePath)
|
||||
assert.NoError(t, err)
|
||||
|
@ -183,10 +189,13 @@ func extractRunContextFromComments(t *testing.T, sourcePath string) *runContext
|
|||
scanner := bufio.NewScanner(f)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if strings.HasPrefix(line, "/*") {
|
||||
skipMultilineComment(scanner)
|
||||
continue
|
||||
}
|
||||
if !strings.HasPrefix(line, "//") {
|
||||
return rc
|
||||
}
|
||||
|
||||
line = strings.TrimPrefix(line, "//")
|
||||
if strings.HasPrefix(line, "args: ") {
|
||||
assert.Nil(t, rc.args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue