Skip to content
Open
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
43 changes: 20 additions & 23 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ linters:
- errcheck
path: internal/setup/fetch.go
text: lockFile.Unlock.*not checked
- linters:
- unused
path: cmd/chisel/main.go
text: addDebugCommand.*unused
- linters:
- unused
path: ^.*/log.go$
Expand All @@ -50,25 +46,26 @@ linters:
- staticcheck
path: ^.*.go$
text: '"golang.org/x/crypto/openpgp/\w+" is deprecated'
settings:
staticcheck:
checks:
- all
# Checks now detecting new issues after migrating to golangci-lint v2.
# TODO: Remove these and solve raised issues.
- -QF1008
- -ST1005
- -ST1012
- -QF1004
- -ST1011
- -ST1005
- -ST1003
- -QF1009
- -QF1011
- -S1011
- -S1005
- -QF1001
- -QF1012
- linters:
- staticcheck
path: cmd/chisel/.*.go
text: "ST1005:"
- linters:
- staticcheck
path: ^.*/log.go$
text: "ST1003:"
- linters:
- staticcheck
path: internal/cache/cache.go
text: "ST1012: error var MissErr"
- linters:
- staticcheck
path: internal/setup/setup.go
text: "ST1012: error var preferNone"
- linters:
- staticcheck
path: internal/testutil/containschecker.go
text: "QF1011"
issues:
max-issues-per-linter: 0
max-same-issues: 0
8 changes: 4 additions & 4 deletions cmd/chisel/cmd_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func addHelp(parser *flags.Parser) error {
// case, parser.Command.Active should be the command
// on which help is being requested (like "chisel foo
// --help", active is foo), or nil in the toplevel.
if parser.Command.Active == nil {
if parser.Active == nil {
// this means *either* a bare 'chisel --help',
// *or* 'chisel --help command'
//
Expand Down Expand Up @@ -101,7 +101,7 @@ func (w *manfixer) Write(buf []byte) (int, error) {
var tpRegexp = regexp.MustCompile(`(?m)(?:^\.TP\n)+`)

func (w *manfixer) flush() error {
str := tpRegexp.ReplaceAllLiteralString(w.Buffer.String(), ".TP\n")
str := tpRegexp.ReplaceAllLiteralString(w.String(), ".TP\n")
_, err := io.Copy(Stdout, strings.NewReader(str))
return err
}
Expand Down Expand Up @@ -131,12 +131,12 @@ func (cmd cmdHelp) Execute(args []string) error {
// the subcommand is set below. The Active command at this point is `chisel
// help`, in the loop below we change it to be `chisel os.Args[1]
// os.Args[2] ...`.
cmd.parser.Command.Active = nil
cmd.parser.Active = nil
for _, subname := range cmd.Positional.Subs {
subcmd = subcmd.Find(subname)
if subcmd == nil {
sug := "chisel help"
if x := cmd.parser.Command.Active; x != nil && x.Name != "help" {
if x := cmd.parser.Active; x != nil && x.Name != "help" {
sug = "chisel help " + x.Name
}
return fmt.Errorf("unknown command %q, see '%s'.", subname, sug)
Expand Down
6 changes: 3 additions & 3 deletions cmd/chisel/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func Parser() *flags.Parser {
name = string(opt.ShortName)
}
desc, ok := c.optDescs[name]
if !(c.optDescs == nil || ok) {
if c.optDescs != nil && !ok {
panicf("%s missing description for %s", c.name, name)
}
lintDesc(c.name, name, desc, opt.Description)
Expand Down Expand Up @@ -261,7 +261,7 @@ func Parser() *flags.Parser {
name = string(opt.ShortName)
}
desc, ok := c.optDescs[name]
if !(c.optDescs == nil || ok) {
if c.optDescs != nil && !ok {
panicf("%s missing description for %s", c.name, name)
}
lintDesc(c.name, name, desc, opt.Description)
Expand Down Expand Up @@ -345,7 +345,7 @@ func run() error {
sug := "chisel help"
if len(xtra) > 0 {
sub = xtra[0]
if x := parser.Command.Active; x != nil && x.Name != "help" {
if x := parser.Active; x != nil && x.Name != "help" {
sug = "chisel help " + x.Name
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/archive/testarchive/testarchive.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (r *Release) Content() []byte {
digests := bytes.Buffer{}
for _, item := range r.Items {
content := item.Content()
digests.WriteString(fmt.Sprintf(" %s %d %s\n", makeSha256(content), len(content), item.Path()))
fmt.Fprintf(&digests, " %s %d %s\n", makeSha256(content), len(content), item.Path())
}
content := fmt.Sprintf(string(testutil.Reindent(`
Origin: Ubuntu
Expand Down
2 changes: 1 addition & 1 deletion internal/deb/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func extractHardLinks(pkgReader io.ReadSeeker, opts *extractHardLinkOptions) err
// this package.
if len(opts.pendingLinks) > 0 {
var targets []string
for target, _ := range opts.pendingLinks {
for target := range opts.pendingLinks {
targets = append(targets, target)
}
sort.Strings(targets)
Expand Down
9 changes: 3 additions & 6 deletions internal/slicer/slicer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1990,7 +1990,7 @@ func (s *S) TestRun(c *C) {
m := make(map[string]string)
for k, v := range t.release {
if !strings.Contains(v, "v2-archives:") {
v = strings.Replace(v, "archives:", "v2-archives:", -1)
v = strings.ReplaceAll(v, "archives:", "v2-archives:")
}
m[k] = v
}
Expand All @@ -2007,7 +2007,7 @@ func (s *S) TestRun(c *C) {
if strings.Contains(v, "format: v1") &&
!strings.Contains(v, "v2-archives:") &&
!strings.Contains(v, "default: true") {
v = strings.Replace(v, "format: v1", "format: v2", -1)
v = strings.ReplaceAll(v, "format: v1", "format: v2")
}
m[k] = v
}
Expand Down Expand Up @@ -2190,10 +2190,7 @@ func treeDumpManifestPaths(mfest *manifest.Manifest) (map[string]string, error)
}

// append {slice1, ..., sliceN} to the end of the path dump.
slicesStr := make([]string, 0, len(path.Slices))
for _, slice := range path.Slices {
slicesStr = append(slicesStr, slice)
}
slicesStr := slices.Clone(path.Slices)
sort.Strings(slicesStr)
result[path.Path] = fmt.Sprintf("%s {%s}", fsDump, strings.Join(slicesStr, ","))
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/testutil/pkgdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func fixupTarEntry(entry *TarEntry) {
if hdr.Gid == 0 && hdr.Gname == "" {
hdr.Gname = "root"
}
if hdr.ModTime == zeroTime {
if hdr.ModTime.Equal(zeroTime) {
hdr.ModTime = epochStartTime
}
if hdr.Format == 0 {
Expand Down
Loading