diff options
author | Wim <wim@42.be> | 2022-06-20 12:02:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-20 12:02:49 +0200 |
commit | cb50375e2b6abf0c79d4891e5e1ea775b9759cd2 (patch) | |
tree | 938af0f442baf79cebd114692aff5ad6af37f987 /modules/git/batch_reader.go | |
parent | 3289abcefc563d6ea16c1dbd19680b874a58a6d3 (diff) | |
download | gitea-cb50375e2b6abf0c79d4891e5e1ea775b9759cd2.tar.gz gitea-cb50375e2b6abf0c79d4891e5e1ea775b9759cd2.zip |
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)
Diffstat (limited to 'modules/git/batch_reader.go')
-rw-r--r-- | modules/git/batch_reader.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/modules/git/batch_reader.go b/modules/git/batch_reader.go index 902fa89718..feb0dd31be 100644 --- a/modules/git/batch_reader.go +++ b/modules/git/batch_reader.go @@ -176,12 +176,12 @@ func ReadBatchLine(rd *bufio.Reader) (sha []byte, typ string, size int64, err er typ = typ[:idx] size, err = strconv.ParseInt(sizeStr, 10, 64) - return + return sha, typ, size, err } // ReadTagObjectID reads a tag object ID hash from a cat-file --batch stream, throwing away the rest of the stream. func ReadTagObjectID(rd *bufio.Reader, size int64) (string, error) { - id := "" + var id string var n int64 headerLoop: for { @@ -216,7 +216,7 @@ headerLoop: // ReadTreeID reads a tree ID from a cat-file --batch stream, throwing away the rest of the stream. func ReadTreeID(rd *bufio.Reader, size int64) (string, error) { - id := "" + var id string var n int64 headerLoop: for { @@ -328,7 +328,7 @@ func ParseTreeLine(rd *bufio.Reader, modeBuf, fnameBuf, shaBuf []byte) (mode, fn // Deal with the 20-byte SHA idx = 0 for idx < 20 { - read := 0 + var read int read, err = rd.Read(shaBuf[idx:20]) n += read if err != nil { @@ -337,7 +337,7 @@ func ParseTreeLine(rd *bufio.Reader, modeBuf, fnameBuf, shaBuf []byte) (mode, fn idx += read } sha = shaBuf - return + return mode, fname, sha, n, err } var callerPrefix string |