History

Add more linters to improve code readability (#19989)

Add nakedret, unconvert, wastedassign, stylecheck and nolintlint linters to improve code readability - nakedret - https://github.com/alexkohler/nakedret - nakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length. - unconvert - https://github.com/mdempsky/unconvert - Remove unnecessary type conversions - wastedassign - https://github.com/sanposhiho/wastedassign - wastedassign finds wasted assignment statements. - notlintlint - Reports ill-formed or insufficient nolint directives - stylecheck - https://staticcheck.io/docs/checks/#ST - keep style consistent - excluded: [ST1003 - Poorly chosen identifier](https://staticcheck.io/docs/checks/#ST1003) and [ST1005 - Incorrectly formatted error string](https://staticcheck.io/docs/checks/#ST1005)

Wim committed 4 years ago

Commit cb503751 parent 3289abc147 files · +402 −397Browse files

Showing the changes to services/gitdiff/gitdiff.go (1 of 147 files). Show all

Unified · Split

services/gitdiff/gitdiff.go+3−4
@@ -1011,7 +1011,7 @@ parsingLoop: · 1010 unmodified lines
10111011
10121012 func skipToNextDiffHead(input *bufio.Reader) (line string, err error) {
10131013 // need to skip until the next cmdDiffHead
1014− isFragment, wasFragment := false, false
1014+ var isFragment, wasFragment bool
10151015 var lineBytes []byte
10161016 for {
10171017 lineBytes, isFragment, err = input.ReadLine()
@@ -1036,7 +1036,7 @@ func skipToNextDiffHead(input *bufio.Reader) (line string, err error) { · 18 unmodified lines
10361036 }
10371037 line += tail
10381038 }
1039− return
1039+ return line, err
10401040 }
10411041
10421042 func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio.Reader) (lineBytes []byte, isFragment bool, err error) {
@@ -1257,8 +1257,7 @@ func createDiffFile(diff *Diff, line string) *DiffFile { · 214 unmodified lines
12571257
12581258 rd := strings.NewReader(line[len(cmdDiffHead):] + " ")
12591259 curFile.Type = DiffFileChange
1260− oldNameAmbiguity := false
1261− newNameAmbiguity := false
1260+ var oldNameAmbiguity, newNameAmbiguity bool
12621261
12631262 curFile.OldName, oldNameAmbiguity = readFileName(rd)
12641263 curFile.Name, newNameAmbiguity = readFileName(rd)