diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-01 22:41:34 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-01 22:42:26 -0700 |
commit | 6e1a9fbb1e9a943e04902ed3a4958f6821e39456 (patch) | |
tree | 4f2afbce761eb377ad0b0ab2e4fb2f478ff844f5 | |
parent | 5b4d97f34c4fec6268c46ceb951f3a2d85492bd6 (diff) |
lint: Set exclude-use-default=false
-rw-r--r-- | .golangci.yml | 11 | ||||
-rw-r--r-- | cmd/btrfs-rec/inspect_lsfiles.go | 8 | ||||
-rw-r--r-- | cmd/btrfs-rec/inspect_lstrees.go | 2 | ||||
-rw-r--r-- | cmd/btrfs-rec/inspect_spewitems.go | 6 | ||||
-rw-r--r-- | lib/textui/log.go | 8 | ||||
-rw-r--r-- | lib/textui/text.go | 8 |
6 files changed, 29 insertions, 14 deletions
diff --git a/.golangci.yml b/.golangci.yml index d1c1798..6b9a830 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -55,6 +55,9 @@ linters: - varnamelen - wrapcheck linters-settings: + errcheck: + exclude-functions: + - "git.lukeshu.com/btrfs-progs-ng/lib/textui.Fprintf" gci: sections: - standard @@ -74,6 +77,10 @@ linters-settings: gomoddirectives: replace-allow-list: - github.com/jacobsa/fuse + gosec: + excludes: + - G104 # duplicates errcheck + - G304 # this program opens arbitrary files nolintlint: require-explanation: true require-specific: true @@ -83,12 +90,16 @@ linters-settings: checks: - "all" - "-ST1003" # CONST_VAL names for consistency with other btrfs code + - "-ST1000" # TODO: get this to pass + - "-ST1020" # TODO: get this to pass + - "-ST1021" # TODO: get this to pass tagliatelle: case: use-field-name: true rules: json: pascal issues: + exclude-use-default: false exclude-rules: # Ignore false positives that don't actually have any words. - linters: [dupword] diff --git a/cmd/btrfs-rec/inspect_lsfiles.go b/cmd/btrfs-rec/inspect_lsfiles.go index 502d91d..395f60a 100644 --- a/cmd/btrfs-rec/inspect_lsfiles.go +++ b/cmd/btrfs-rec/inspect_lsfiles.go @@ -1,4 +1,4 @@ -// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com> +// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com> // // SPDX-License-Identifier: GPL-2.0-or-later @@ -34,7 +34,11 @@ func init() { }, RunE: func(fs *btrfs.FS, cmd *cobra.Command, _ []string) (err error) { out := bufio.NewWriter(os.Stdout) - defer out.Flush() + defer func() { + if _err := out.Flush(); _err != nil && err == nil { + err = _err + } + }() defer func() { if r := derror.PanicToError(recover()); r != nil { textui.Fprintf(out, "\n\n%+v\n", r) diff --git a/cmd/btrfs-rec/inspect_lstrees.go b/cmd/btrfs-rec/inspect_lstrees.go index 0f70cd1..f74956a 100644 --- a/cmd/btrfs-rec/inspect_lstrees.go +++ b/cmd/btrfs-rec/inspect_lstrees.go @@ -60,7 +60,7 @@ func init() { textui.Fprintf(table, " %v items\t% *s\n", typ, numWidth, strconv.Itoa(treeItemCnt[typ])) } textui.Fprintf(table, " total items\t% *s\n", numWidth, strconv.Itoa(totalItems)) - table.Flush() + _ = table.Flush() } visitedNodes := make(containers.Set[btrfsvol.LogicalAddr]) btrfsutil.WalkAllTrees(ctx, fs, btrfsutil.WalkAllTreesHandler{ diff --git a/cmd/btrfs-rec/inspect_spewitems.go b/cmd/btrfs-rec/inspect_spewitems.go index 8d71797..3b79e8b 100644 --- a/cmd/btrfs-rec/inspect_spewitems.go +++ b/cmd/btrfs-rec/inspect_spewitems.go @@ -1,4 +1,4 @@ -// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com> +// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com> // // SPDX-License-Identifier: GPL-2.0-or-later @@ -39,13 +39,13 @@ func init() { Item: func(path btrfstree.TreePath, item btrfstree.Item) error { textui.Fprintf(os.Stdout, "%s = ", path) spew.Dump(item) - os.Stdout.WriteString("\n") + _, _ = os.Stdout.WriteString("\n") return nil }, BadItem: func(path btrfstree.TreePath, item btrfstree.Item) error { textui.Fprintf(os.Stdout, "%s = ", path) spew.Dump(item) - os.Stdout.WriteString("\n") + _, _ = os.Stdout.WriteString("\n") return nil }, }, diff --git a/lib/textui/log.go b/lib/textui/log.go index 0fe03e5..d2373f8 100644 --- a/lib/textui/log.go +++ b/lib/textui/log.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2022 Ambassador Labs +// Copyright (C) 2019-2022-2023 Ambassador Labs // Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com> // // SPDX-License-Identifier: Apache-2.0 @@ -134,21 +134,21 @@ func (l *logger) Log(lvl dlog.LogLevel, msg string) { // UnformattedLog implements dlog.OptimizedLogger. func (l *logger) UnformattedLog(lvl dlog.LogLevel, args ...any) { l.log(lvl, func(w io.Writer) { - printer.Fprint(w, args...) + _, _ = printer.Fprint(w, args...) }) } // UnformattedLogln implements dlog.OptimizedLogger. func (l *logger) UnformattedLogln(lvl dlog.LogLevel, args ...any) { l.log(lvl, func(w io.Writer) { - printer.Fprintln(w, args...) + _, _ = printer.Fprintln(w, args...) }) } // UnformattedLogf implements dlog.OptimizedLogger. func (l *logger) UnformattedLogf(lvl dlog.LogLevel, format string, args ...any) { l.log(lvl, func(w io.Writer) { - printer.Fprintf(w, format, args...) + _, _ = printer.Fprintf(w, format, args...) }) } diff --git a/lib/textui/text.go b/lib/textui/text.go index 615516d..c0a3c5e 100644 --- a/lib/textui/text.go +++ b/lib/textui/text.go @@ -1,4 +1,4 @@ -// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com> +// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com> // // SPDX-License-Identifier: GPL-2.0-or-later @@ -53,7 +53,7 @@ var ( // String implements fmt.Formatter. func (h humanized) Format(f fmt.State, verb rune) { - printer.Fprintf(f, fmtutil.FmtStateString(f, verb), h.val) + _, _ = printer.Fprintf(f, fmtutil.FmtStateString(f, verb), h.val) } // String implements fmt.Stringer. @@ -144,7 +144,7 @@ func (v metric[T]) Format(f fmt.State, verb rune) { if v.Val < 0 { y = -y } - printer.Fprintf(f, fmtutil.FmtStateString(f, verb)+"%s%s", + _, _ = printer.Fprintf(f, fmtutil.FmtStateString(f, verb)+"%s%s", y, prefix, v.Unit) } @@ -192,7 +192,7 @@ func (v iec[T]) Format(f fmt.State, verb rune) { if v.Val < 0 { y = -y } - printer.Fprintf(f, fmtutil.FmtStateString(f, verb)+"%s%s", + _, _ = printer.Fprintf(f, fmtutil.FmtStateString(f, verb)+"%s%s", number.Decimal(y), prefix, v.Unit) } |