Skip to content

Commit

Permalink
fix(lint): Rename unused parameters (#42)
Browse files Browse the repository at this point in the history
The `revive` linter complains now about a number of unused parameters.
This cleans it up by renaming such parameters to `_`.

Signed-off-by: Dave Henderson <[email protected]>
  • Loading branch information
hairyhenderson authored Jun 22, 2024
1 parent e19a022 commit 3f4af2a
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BROWSERTEST_VERSION = v0.7
LINT_VERSION = 1.50.1
LINT_VERSION = 1.59.1
GO_BIN = $(shell printf '%s/bin' "$$(go env GOPATH)")
SHELL = bash

Expand All @@ -12,7 +12,7 @@ lint-deps:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${GO_BIN}" v${LINT_VERSION}; \
fi
@if ! which jsguard >/dev/null; then \
go install github.com/hack-pad/safejs/jsguard/cmd/jsguard; \
go install github.com/hack-pad/safejs/jsguard/cmd/jsguard@latest; \
fi

.PHONY: lint
Expand Down
2 changes: 1 addition & 1 deletion cache/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type dir struct {
offset int
}

func (d *dir) Read(p []byte) (n int, err error) {
func (d *dir) Read(_ []byte) (n int, err error) {
return 0, &hackpadfs.PathError{Op: "read", Path: d.name, Err: hackpadfs.ErrIsDir}
}

Expand Down
6 changes: 3 additions & 3 deletions fstest/file_concurrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestConcurrentFileRead(tb testing.TB, o FSOptions) {
setupFS, commit := o.Setup.FS(tb)
assert.NoError(tb, hackpadfs.WriteFullFile(setupFS, "foo", []byte("hello world"), 0666))
fs := commit()
concurrentTasks(0, func(i int) {
concurrentTasks(0, func(_ int) {
f, err := fs.Open("foo")
if assert.NoError(tb, err) {
buf := make([]byte, 5)
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestConcurrentFileWrite(tb testing.TB, o FSOptions) {
assert.NoError(tb, f.Close())
}
fs := commit()
concurrentTasks(0, func(i int) {
concurrentTasks(0, func(_ int) {
f, err := hackpadfs.OpenFile(fs, "foo", hackpadfs.FlagWriteOnly, 0)
skipNotImplemented(tb, err)
n, err := hackpadfs.WriteFile(f, []byte("hello"))
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestConcurrentFileStat(tb testing.TB, o FSOptions) {
assert.NoError(tb, f.Close())
}
fs := commit()
concurrentTasks(0, func(i int) {
concurrentTasks(0, func(_ int) {
f, err := fs.Open("foo")
if assert.NoError(tb, err) {
info, err := f.Stat()
Expand Down
10 changes: 5 additions & 5 deletions fstest/fs_concurrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestConcurrentCreate(tb testing.TB, o FSOptions) {
o.tbRun(tb, "same file path", func(tb testing.TB) {
_, commit := o.Setup.FS(tb)
fs := commit()
concurrentTasks(0, func(i int) {
concurrentTasks(0, func(_ int) {
f, err := hackpadfs.Create(fs, "foo")
skipNotImplemented(tb, err)
if assert.NoError(tb, err) {
Expand All @@ -60,7 +60,7 @@ func TestConcurrentOpenFileCreate(tb testing.TB, o FSOptions) {
o.tbRun(tb, "same file path", func(tb testing.TB) {
_, commit := o.Setup.FS(tb)
fs := commit()
concurrentTasks(0, func(i int) {
concurrentTasks(0, func(_ int) {
f, err := hackpadfs.OpenFile(fs, "foo", hackpadfs.FlagReadWrite|hackpadfs.FlagCreate|hackpadfs.FlagTruncate, 0666)
skipNotImplemented(tb, err)
if assert.NoError(tb, err) {
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestConcurrentRemove(tb testing.TB, o FSOptions) {
assert.NoError(tb, f.Close())
}
fs := commit()
concurrentTasks(0, func(i int) {
concurrentTasks(0, func(_ int) {
err := hackpadfs.Remove(fs, "foo")
skipNotImplemented(tb, err)
assert.Equal(tb, true, err == nil || errors.Is(err, hackpadfs.ErrNotExist))
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestConcurrentMkdir(tb testing.TB, o FSOptions) {
o.tbRun(tb, "same file path", func(tb testing.TB) {
_, commit := o.Setup.FS(tb)
fs := commit()
concurrentTasks(0, func(i int) {
concurrentTasks(0, func(_ int) {
err := hackpadfs.Mkdir(fs, "foo", 0777)
skipNotImplemented(tb, err)
assert.Equal(tb, true, err == nil || errors.Is(err, hackpadfs.ErrExist))
Expand All @@ -141,7 +141,7 @@ func TestConcurrentMkdirAll(tb testing.TB, o FSOptions) {
o.tbRun(tb, "same file path", func(tb testing.TB) {
_, commit := o.Setup.FS(tb)
fs := commit()
concurrentTasks(0, func(i int) {
concurrentTasks(0, func(_ int) {
err := hackpadfs.MkdirAll(fs, "foo", 0777)
skipNotImplemented(tb, err)
assert.NoError(tb, err)
Expand Down
4 changes: 2 additions & 2 deletions fstest/fstest.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func setupOptions(options *FSOptions) error {
})
}
if options.ShouldSkip == nil {
options.ShouldSkip = func(facets Facets) bool {
options.ShouldSkip = func(_ Facets) bool {
return false
}
}
Expand All @@ -121,7 +121,7 @@ func (o FSOptions) tbRun(tb testing.TB, name string, subtest func(tb testing.TB)
}
}

func (o FSOptions) tbRunInner(tb testing.TB, name string, subtest func(tb testing.TB)) {
func (o FSOptions) tbRunInner(tb testing.TB, _ string, subtest func(tb testing.TB)) {
tb.Helper()
facets := Facets{
Name: tb.Name(),
Expand Down
7 changes: 0 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
github.com/hack-pad/go-indexeddb v0.3.0 h1:SkKFoWnN047GvblHWM076tH43T0zLduNCCiv0nKDRUI=
github.com/hack-pad/go-indexeddb v0.3.0/go.mod h1:QvfTevpDVlkfomY498LhstjwbPW6QC4VC/lxYb0Kom0=
github.com/hack-pad/go-indexeddb v0.3.1 h1:PewXAVjRU4ovlGPaAPAC6WwMxzByRE23O+rf8un+iLc=
github.com/hack-pad/go-indexeddb v0.3.1/go.mod h1:QvfTevpDVlkfomY498LhstjwbPW6QC4VC/lxYb0Kom0=
github.com/hack-pad/go-indexeddb v0.3.2 h1:DTqeJJYc1usa45Q5r52t01KhvlSN02+Oq+tQbSBI91A=
github.com/hack-pad/go-indexeddb v0.3.2/go.mod h1:QvfTevpDVlkfomY498LhstjwbPW6QC4VC/lxYb0Kom0=
github.com/hack-pad/safejs v0.1.0 h1:qPS6vjreAqh2amUqj4WNG1zIw7qlRQJ9K10eDKMCnE8=
github.com/hack-pad/safejs v0.1.0/go.mod h1:HdS+bKF1NrE72VoXZeWzxFOVQVUSqZJAG0xNCnb+Tio=
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4=
2 changes: 1 addition & 1 deletion indexeddb/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewFS(ctx context.Context, name string, options Options) (*FS, error) {
if options.Factory == nil {
options.Factory = idb.Global()
}
openRequest, err := options.Factory.Open(ctx, name, fsVersion, func(db *idb.Database, oldVersion, newVersion uint) error {
openRequest, err := options.Factory.Open(ctx, name, fsVersion, func(db *idb.Database, _, _ uint) error {
_, err := db.CreateObjectStore(contentsStore, idb.ObjectStoreOptions{})
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion keyvalue/file_rwonly.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type writeOnlyFile struct {
file *file
}

func (w *writeOnlyFile) Read(p []byte) (n int, err error) {
func (w *writeOnlyFile) Read(_ []byte) (n int, err error) {
// Read is required by hackpadfs.File
return 0, &hackpadfs.PathError{Op: "read", Path: w.file.path, Err: hackpadfs.ErrNotImplemented}
}
Expand Down
2 changes: 1 addition & 1 deletion keyvalue/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func (fs *FS) Chmod(name string, mode hackpadfs.FileMode) error {
}

// Chtimes implements hackpadfs.ChtimesFS
func (fs *FS) Chtimes(name string, atime time.Time, mtime time.Time) error {
func (fs *FS) Chtimes(name string, _ time.Time, mtime time.Time) error {
file, err := fs.getFile(name)
if err != nil {
return fs.wrapperErr("chtimes", name, err)
Expand Down
6 changes: 3 additions & 3 deletions keyvalue/txn_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func abortErr(ctx, extraCtx context.Context) error {
}

func (u *unsafeSerialTransaction) Get(path string) OpID {
return u.GetHandler(path, OpHandlerFunc(func(txn Transaction, result OpResult) error {
return u.GetHandler(path, OpHandlerFunc(func(_ Transaction, _ OpResult) error {
return nil
}))
}
Expand All @@ -140,12 +140,12 @@ func (u *unsafeSerialTransaction) GetHandler(path string, handler OpHandler) OpI
}

func (u *unsafeSerialTransaction) Set(path string, src FileRecord, contents blob.Blob) OpID {
return u.SetHandler(path, src, contents, OpHandlerFunc(func(txn Transaction, result OpResult) error {
return u.SetHandler(path, src, contents, OpHandlerFunc(func(_ Transaction, _ OpResult) error {
return nil
}))
}

func (u *unsafeSerialTransaction) SetHandler(path string, src FileRecord, contents blob.Blob, handler OpHandler) OpID {
func (u *unsafeSerialTransaction) SetHandler(path string, src FileRecord, _ blob.Blob, handler OpHandler) OpID {
op := u.newOp()
if err := abortErr(u.ctx, nil); err != nil {
u.setResult(op, OpResult{Op: op, Err: err})
Expand Down
14 changes: 7 additions & 7 deletions mem/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (f fileRecord) ReadDirNames() ([]string, error) {
return names, nil
}

func (s *store) Get(ctx context.Context, path string) (keyvalue.FileRecord, error) {
func (s *store) Get(_ context.Context, path string) (keyvalue.FileRecord, error) {
value, ok := s.records.Load(path)
if !ok {
return nil, hackpadfs.ErrNotExist
Expand All @@ -72,7 +72,7 @@ func (s *store) Get(ctx context.Context, path string) (keyvalue.FileRecord, erro
return record, nil
}

func (s *store) Set(ctx context.Context, path string, src keyvalue.FileRecord) error {
func (s *store) Set(_ context.Context, path string, src keyvalue.FileRecord) error {
var contents blob.Blob
if src != nil {
var err error
Expand All @@ -84,7 +84,7 @@ func (s *store) Set(ctx context.Context, path string, src keyvalue.FileRecord) e
return s.set(path, src, contents)
}

func (s *store) set(path string, src keyvalue.FileRecord, contents blob.Blob) error {
func (s *store) set(path string, src keyvalue.FileRecord, _ blob.Blob) error {
if src == nil {
s.records.Delete(path)
} else {
Expand Down Expand Up @@ -112,7 +112,7 @@ type transaction struct {
results []keyvalue.OpResult
}

func (s *store) Transaction(options keyvalue.TransactionOptions) (keyvalue.Transaction, error) {
func (s *store) Transaction(_ keyvalue.TransactionOptions) (keyvalue.Transaction, error) {
ctx, cancel := context.WithCancel(context.Background())
txn := &transaction{
ctx: ctx,
Expand All @@ -136,7 +136,7 @@ func (t *transaction) prepOp() (keyvalue.OpID, error) {
}

func (t *transaction) Get(path string) keyvalue.OpID {
return t.GetHandler(path, keyvalue.OpHandlerFunc(func(txn keyvalue.Transaction, result keyvalue.OpResult) error {
return t.GetHandler(path, keyvalue.OpHandlerFunc(func(_ keyvalue.Transaction, _ keyvalue.OpResult) error {
return nil
}))
}
Expand All @@ -158,7 +158,7 @@ func (t *transaction) GetHandler(path string, handler keyvalue.OpHandler) keyval
}

func (t *transaction) Set(path string, src keyvalue.FileRecord, contents blob.Blob) keyvalue.OpID {
return t.SetHandler(path, src, contents, keyvalue.OpHandlerFunc(func(txn keyvalue.Transaction, result keyvalue.OpResult) error {
return t.SetHandler(path, src, contents, keyvalue.OpHandlerFunc(func(_ keyvalue.Transaction, _ keyvalue.OpResult) error {
return nil
}))
}
Expand All @@ -179,7 +179,7 @@ func (t *transaction) SetHandler(path string, src keyvalue.FileRecord, contents
return op
}

func (t *transaction) Commit(ctx context.Context) ([]keyvalue.OpResult, error) {
func (t *transaction) Commit(_ context.Context) ([]keyvalue.OpResult, error) {
t.abort()
t.store.mu.Unlock()
return t.results, nil
Expand Down
2 changes: 1 addition & 1 deletion mount/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ type Point struct {
// MountPoints returns a slice of mount points every mounted file system.
func (fs *FS) MountPoints() []Point {
var points []Point
fs.mounts.Range(func(key, value interface{}) bool {
fs.mounts.Range(func(key, _ interface{}) bool {
path := key.(string)
points = append(points, Point{path})
return true
Expand Down
2 changes: 1 addition & 1 deletion os/path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func TestFromOSPath(t *testing.T) {
if tc.goos == goosWindows {
sep = '\\'
}
getVolumeName := func(p string) string { return tc.osPathVolumeName }
getVolumeName := func(_ string) string { return tc.osPathVolumeName }
path, err := fs.fromOSPath(tc.goos, sep, getVolumeName, "test", tc.osPath)
if tc.expectErr != "" {
if assert.Error(t, err) {
Expand Down
2 changes: 1 addition & 1 deletion tar/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestNewTarFromFS(t *testing.T) {
}{
{
description: "empty",
do: func(t *testing.T, fs hackpadfs.FS) {},
do: func(_ *testing.T, _ hackpadfs.FS) {},
},
{
description: "one file",
Expand Down

0 comments on commit 3f4af2a

Please sign in to comment.