From 2ec09770215818809910e3ad75fc48b2a67dd653 Mon Sep 17 00:00:00 2001
From: kopi-solarpunk <peter.palotas@solarpunk.buzz>
Date: Mon, 13 May 2024 11:12:19 +0200
Subject: [PATCH] refactor: start refactoring for now linter rules

---
 pkg/api/accounting_test.go            |  1 -
 pkg/api/api_test.go                   |  8 +++---
 pkg/api/balances_test.go              |  1 -
 pkg/api/bytes_test.go                 |  1 -
 pkg/api/bzz.go                        |  9 +++----
 pkg/api/bzz_test.go                   |  3 ---
 pkg/api/chequebook.go                 |  1 -
 pkg/api/chequebook_test.go            |  6 -----
 pkg/api/chunk.go                      |  3 +--
 pkg/api/chunk_test.go                 |  9 +++----
 pkg/api/cors_test.go                  |  4 +--
 pkg/api/debugstorage_test.go          |  1 -
 pkg/api/dirs.go                       |  1 -
 pkg/api/dirs_test.go                  |  7 ++---
 pkg/api/dynamicaccess.go              |  8 +++---
 pkg/api/dynamicaccess_test.go         | 37 +++++++++++---------------
 pkg/api/export_test.go                |  5 ++--
 pkg/api/feed_test.go                  |  1 -
 pkg/api/metrics.go                    |  1 -
 pkg/api/pin_test.go                   |  2 --
 pkg/api/postage_test.go               |  5 +---
 pkg/api/probe.go                      |  1 -
 pkg/api/pss_test.go                   | 11 ++++----
 pkg/api/settlements_test.go           |  1 -
 pkg/api/soc_test.go                   |  1 -
 pkg/api/staking.go                    |  2 +-
 pkg/api/staking_test.go               |  3 +--
 pkg/api/status_test.go                |  1 +
 pkg/api/stewardship.go                |  3 +--
 pkg/api/tag_test.go                   |  8 +++---
 pkg/api/version.go                    |  6 +++--
 pkg/api/wallet.go                     |  3 +--
 pkg/api/welcome_message_test.go       |  3 ++-
 pkg/dynamicaccess/accesslogic.go      | 35 +++++++++++++-----------
 pkg/dynamicaccess/accesslogic_test.go |  3 ---
 pkg/dynamicaccess/controller.go       | 23 ++++++++--------
 pkg/dynamicaccess/controller_test.go  |  6 +++--
 pkg/dynamicaccess/grantee.go          | 16 +++++++----
 pkg/dynamicaccess/history.go          | 38 +++++++++++++++------------
 pkg/dynamicaccess/mock/session.go     |  1 -
 pkg/dynamicaccess/session.go          | 24 ++++++++++-------
 pkg/dynamicaccess/session_test.go     |  2 +-
 pkg/kvs/kvs_test.go                   |  1 -
 pkg/kvs/mock/kvs.go                   |  3 ++-
 pkg/manifest/mantaray/node.go         |  7 +----
 45 files changed, 146 insertions(+), 170 deletions(-)

diff --git a/pkg/api/accounting_test.go b/pkg/api/accounting_test.go
index 7a807aa811e..6664e48108d 100644
--- a/pkg/api/accounting_test.go
+++ b/pkg/api/accounting_test.go
@@ -101,7 +101,6 @@ func TestAccountingInfo(t *testing.T) {
 	if !reflect.DeepEqual(got, expected) {
 		t.Errorf("got accounting: %v, expected: %v", got, expected)
 	}
-
 }
 
 func TestAccountingInfoError(t *testing.T) {
diff --git a/pkg/api/api_test.go b/pkg/api/api_test.go
index 2c93a20353b..e7f2f92b9c4 100644
--- a/pkg/api/api_test.go
+++ b/pkg/api/api_test.go
@@ -190,7 +190,7 @@ func newTestServer(t *testing.T, o testServerOptions) (*http.Client, *websocket.
 	erc20 := erc20mock.New(o.Erc20Opts...)
 	backend := backendmock.New(o.BackendOpts...)
 
-	var extraOpts = api.ExtraOptions{
+	extraOpts := api.ExtraOptions{
 		TopologyDriver:  topologyDriver,
 		Accounting:      acc,
 		Pseudosettle:    recipient,
@@ -344,7 +344,7 @@ func TestParseName(t *testing.T) {
 	const bzzHash = "89c17d0d8018a19057314aa035e61c9d23c47581a61dd3a79a7839692c617e4d"
 	log := log.Noop
 
-	var errInvalidNameOrAddress = errors.New("invalid name or bzz address")
+	errInvalidNameOrAddress := errors.New("invalid name or bzz address")
 
 	testCases := []struct {
 		desc       string
@@ -531,9 +531,7 @@ func TestPostageHeaderError(t *testing.T) {
 func TestOptions(t *testing.T) {
 	t.Parallel()
 
-	var (
-		client, _, _, _ = newTestServer(t, testServerOptions{})
-	)
+	client, _, _, _ := newTestServer(t, testServerOptions{})
 	for _, tc := range []struct {
 		endpoint        string
 		expectedMethods string // expectedMethods contains HTTP methods like GET, POST, HEAD, PATCH, DELETE, OPTIONS. These are in alphabetical sorted order
diff --git a/pkg/api/balances_test.go b/pkg/api/balances_test.go
index 174196d253a..da3ea24cb73 100644
--- a/pkg/api/balances_test.go
+++ b/pkg/api/balances_test.go
@@ -216,7 +216,6 @@ func TestConsumedBalances(t *testing.T) {
 	if !equalBalances(got, expected) {
 		t.Errorf("got balances: %v, expected: %v", got, expected)
 	}
-
 }
 
 func TestConsumedError(t *testing.T) {
diff --git a/pkg/api/bytes_test.go b/pkg/api/bytes_test.go
index e2acc99a9d6..88ed06d2f5b 100644
--- a/pkg/api/bytes_test.go
+++ b/pkg/api/bytes_test.go
@@ -271,7 +271,6 @@ func TestBytesInvalidStamp(t *testing.T) {
 			jsonhttptest.WithRequestBody(bytes.NewReader(content)),
 		)
 	})
-
 }
 
 func TestBytesUploadHandlerInvalidInputs(t *testing.T) {
diff --git a/pkg/api/bzz.go b/pkg/api/bzz.go
index b49bc89baea..3d85b81973a 100644
--- a/pkg/api/bzz.go
+++ b/pkg/api/bzz.go
@@ -16,10 +16,6 @@ import (
 	"strings"
 	"time"
 
-	"github.com/opentracing/opentracing-go"
-	"github.com/opentracing/opentracing-go/ext"
-	olog "github.com/opentracing/opentracing-go/log"
-
 	"github.com/ethereum/go-ethereum/common"
 	"github.com/ethersphere/bee/v2/pkg/feeds"
 	"github.com/ethersphere/bee/v2/pkg/file/joiner"
@@ -37,6 +33,9 @@ import (
 	"github.com/ethersphere/bee/v2/pkg/tracing"
 	"github.com/ethersphere/langos"
 	"github.com/gorilla/mux"
+	"github.com/opentracing/opentracing-go"
+	"github.com/opentracing/opentracing-go/ext"
+	olog "github.com/opentracing/opentracing-go/log"
 )
 
 // The size of buffer used for prefetching content with Langos when not using erasure coding
@@ -394,7 +393,7 @@ FETCH:
 	// go on normally.
 	if !feedDereferenced {
 		if l, err := s.manifestFeed(ctx, m); err == nil {
-			//we have a feed manifest here
+			// we have a feed manifest here
 			ch, cur, _, err := l.At(ctx, time.Now().Unix(), 0)
 			if err != nil {
 				logger.Debug("bzz download: feed lookup failed", "error", err)
diff --git a/pkg/api/bzz_test.go b/pkg/api/bzz_test.go
index 7d1e1b27bfe..236768a2bf6 100644
--- a/pkg/api/bzz_test.go
+++ b/pkg/api/bzz_test.go
@@ -934,7 +934,6 @@ func TestInvalidBzzParams(t *testing.T) {
 			jsonhttptest.WithRequestBody(tr),
 			jsonhttptest.WithRequestHeader(api.ContentTypeHeader, api.ContentTypeTar),
 		)
-
 	})
 
 	t.Run("batch exists", func(t *testing.T) {
@@ -962,7 +961,6 @@ func TestInvalidBzzParams(t *testing.T) {
 			jsonhttptest.WithRequestBody(tr),
 			jsonhttptest.WithRequestHeader(api.ContentTypeHeader, api.ContentTypeTar),
 		)
-
 	})
 
 	t.Run("batch not found", func(t *testing.T) {
@@ -1057,7 +1055,6 @@ func TestInvalidBzzParams(t *testing.T) {
 		address := "f30c0aa7e9e2a0ef4c9b1b750ebfeaeb7c7c24da700bb089da19a46e3677824b"
 		jsonhttptest.Request(t, client, http.MethodGet, fmt.Sprintf("/bzz/%s/", address), http.StatusNotFound)
 	})
-
 }
 
 // TestDirectUploadBzz tests that the direct upload endpoint give correct error message in dev mode
diff --git a/pkg/api/chequebook.go b/pkg/api/chequebook.go
index 33cd75d9767..b2b30e2443e 100644
--- a/pkg/api/chequebook.go
+++ b/pkg/api/chequebook.go
@@ -15,7 +15,6 @@ import (
 	"github.com/ethersphere/bee/v2/pkg/postage/postagecontract"
 	"github.com/ethersphere/bee/v2/pkg/settlement/swap"
 	"github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook"
-
 	"github.com/ethersphere/bee/v2/pkg/swarm"
 	"github.com/gorilla/mux"
 )
diff --git a/pkg/api/chequebook_test.go b/pkg/api/chequebook_test.go
index b9b9cbdef32..d1415b994fc 100644
--- a/pkg/api/chequebook_test.go
+++ b/pkg/api/chequebook_test.go
@@ -21,7 +21,6 @@ import (
 	"github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook"
 	"github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook/mock"
 	swapmock "github.com/ethersphere/bee/v2/pkg/settlement/swap/mock"
-
 	"github.com/ethersphere/bee/v2/pkg/swarm"
 )
 
@@ -427,7 +426,6 @@ func TestChequebookLastCheques(t *testing.T) {
 	if !LastChequesEqual(got, expected) {
 		t.Fatalf("Got: \n %+v \n\n Expected: \n %+v \n\n", got, expected)
 	}
-
 }
 
 func TestChequebookLastChequesPeer(t *testing.T) {
@@ -442,7 +440,6 @@ func TestChequebookLastChequesPeer(t *testing.T) {
 	sig := make([]byte, 65)
 
 	lastSentChequeFunc := func(swarm.Address) (*chequebook.SignedCheque, error) {
-
 		sig := make([]byte, 65)
 
 		lastSentCheque := &chequebook.SignedCheque{
@@ -458,7 +455,6 @@ func TestChequebookLastChequesPeer(t *testing.T) {
 	}
 
 	lastReceivedChequeFunc := func(swarm.Address) (*chequebook.SignedCheque, error) {
-
 		lastReceivedCheque := &chequebook.SignedCheque{
 			Cheque: chequebook.Cheque{
 				Beneficiary:      beneficiary0,
@@ -498,7 +494,6 @@ func TestChequebookLastChequesPeer(t *testing.T) {
 	if !reflect.DeepEqual(got, expected) {
 		t.Fatalf("Got: \n %+v \n\n Expected: \n %+v \n\n", got, expected)
 	}
-
 }
 
 func TestChequebookCashout(t *testing.T) {
@@ -780,7 +775,6 @@ func Test_chequebookLastPeerHandler_invalidInputs(t *testing.T) {
 }
 
 func LastChequesEqual(a, b *api.ChequebookLastChequesResponse) bool {
-
 	var state bool
 
 	for akeys := range a.LastCheques {
diff --git a/pkg/api/chunk.go b/pkg/api/chunk.go
index 21daa0d0f57..5acc9b42df3 100644
--- a/pkg/api/chunk.go
+++ b/pkg/api/chunk.go
@@ -13,10 +13,9 @@ import (
 	"strconv"
 
 	"github.com/ethersphere/bee/v2/pkg/cac"
-	"github.com/ethersphere/bee/v2/pkg/soc"
-
 	"github.com/ethersphere/bee/v2/pkg/jsonhttp"
 	"github.com/ethersphere/bee/v2/pkg/postage"
+	"github.com/ethersphere/bee/v2/pkg/soc"
 	"github.com/ethersphere/bee/v2/pkg/storage"
 	"github.com/ethersphere/bee/v2/pkg/swarm"
 	"github.com/gorilla/mux"
diff --git a/pkg/api/chunk_test.go b/pkg/api/chunk_test.go
index c0e1fe9de9c..66f8dfae74a 100644
--- a/pkg/api/chunk_test.go
+++ b/pkg/api/chunk_test.go
@@ -13,16 +13,15 @@ import (
 	"testing"
 	"time"
 
+	"github.com/ethersphere/bee/v2/pkg/api"
+	"github.com/ethersphere/bee/v2/pkg/jsonhttp"
+	"github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest"
 	"github.com/ethersphere/bee/v2/pkg/log"
 	mockbatchstore "github.com/ethersphere/bee/v2/pkg/postage/batchstore/mock"
 	mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock"
 	"github.com/ethersphere/bee/v2/pkg/spinlock"
-	mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock"
-
-	"github.com/ethersphere/bee/v2/pkg/api"
-	"github.com/ethersphere/bee/v2/pkg/jsonhttp"
-	"github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest"
 	testingc "github.com/ethersphere/bee/v2/pkg/storage/testing"
+	mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock"
 	"github.com/ethersphere/bee/v2/pkg/swarm"
 )
 
diff --git a/pkg/api/cors_test.go b/pkg/api/cors_test.go
index 73c3b343414..08c817c0389 100644
--- a/pkg/api/cors_test.go
+++ b/pkg/api/cors_test.go
@@ -116,7 +116,6 @@ func TestCORSHeaders(t *testing.T) {
 			}
 		})
 	}
-
 }
 
 // TestCors tests whether CORs work correctly with OPTIONS method
@@ -135,7 +134,8 @@ func TestCors(t *testing.T) {
 		{
 			endpoint:        "bzz",
 			expectedMethods: "POST",
-		}, {
+		},
+		{
 			endpoint:        "bzz/0101011",
 			expectedMethods: "GET, HEAD",
 		},
diff --git a/pkg/api/debugstorage_test.go b/pkg/api/debugstorage_test.go
index bb12a5585fd..0a7c655fdec 100644
--- a/pkg/api/debugstorage_test.go
+++ b/pkg/api/debugstorage_test.go
@@ -43,5 +43,4 @@ func TestDebugStorage(t *testing.T) {
 			jsonhttptest.WithExpectedJSONResponse(want),
 		)
 	})
-
 }
diff --git a/pkg/api/dirs.go b/pkg/api/dirs.go
index f187fbde01e..ce2b679c076 100644
--- a/pkg/api/dirs.go
+++ b/pkg/api/dirs.go
@@ -141,7 +141,6 @@ func storeDir(
 	errorFilename string,
 	rLevel redundancy.Level,
 ) (swarm.Address, error) {
-
 	logger := tracing.NewLoggerWithTraceID(ctx, log)
 	loggerV1 := logger.V(1).Build()
 
diff --git a/pkg/api/dirs_test.go b/pkg/api/dirs_test.go
index d49f0d281d6..306e561c864 100644
--- a/pkg/api/dirs_test.go
+++ b/pkg/api/dirs_test.go
@@ -371,7 +371,6 @@ func TestDirs(t *testing.T) {
 				// check error document
 				validateAltPath(t, "_non_existent_file_path_", errorDocumentPath)
 			}
-
 		}
 		t.Run(tc.name, func(t *testing.T) {
 			t.Run("tar_upload", func(t *testing.T) {
@@ -542,7 +541,7 @@ func tarFiles(t *testing.T, files []f) *bytes.Buffer {
 		// create tar header and write it
 		hdr := &tar.Header{
 			Name: filePath,
-			Mode: 0600,
+			Mode: 0o600,
 			Size: int64(len(file.data)),
 		}
 		if err := tw.WriteHeader(hdr); err != nil {
@@ -571,7 +570,7 @@ func tarEmptyDir(t *testing.T) *bytes.Buffer {
 
 	hdr := &tar.Header{
 		Name: "empty/",
-		Mode: 0600,
+		Mode: 0o600,
 	}
 
 	if err := tw.WriteHeader(hdr); err != nil {
@@ -604,11 +603,9 @@ func multipartFiles(t *testing.T, files []f) (*bytes.Buffer, string) {
 		contentType := file.header.Get(api.ContentTypeHeader)
 		if contentType != "" {
 			hdr.Set(api.ContentTypeHeader, contentType)
-
 		}
 		if len(file.data) > 0 {
 			hdr.Set(api.ContentLengthHeader, strconv.Itoa(len(file.data)))
-
 		}
 		part, err := mw.CreatePart(hdr)
 		if err != nil {
diff --git a/pkg/api/dynamicaccess.go b/pkg/api/dynamicaccess.go
index bbf3abbc69e..5a6295696bc 100644
--- a/pkg/api/dynamicaccess.go
+++ b/pkg/api/dynamicaccess.go
@@ -6,6 +6,7 @@ import (
 	"encoding/hex"
 	"encoding/json"
 	"errors"
+	"fmt"
 	"io"
 	"net/http"
 	"time"
@@ -114,7 +115,6 @@ func (s *Service) actDecryptionHandler() func(h http.Handler) http.Handler {
 			h.ServeHTTP(w, r.WithContext(setAddressInContext(ctx, reference)))
 		})
 	}
-
 }
 
 // actEncryptionHandler is a middleware that encrypts the given address using the publisher's public key
@@ -133,7 +133,7 @@ func (s *Service) actEncryptionHandler(
 	if err != nil {
 		logger.Debug("act failed to encrypt reference", "error", err)
 		logger.Error(nil, "act failed to encrypt reference")
-		return swarm.ZeroAddress, err
+		return swarm.ZeroAddress, fmt.Errorf("act failed to encrypt reference: %w", err)
 	}
 	// only need to upload history and kvs if a new history is created,
 	// meaning that the publsher uploaded to the history for the first time
@@ -142,13 +142,13 @@ func (s *Service) actEncryptionHandler(
 		if err != nil {
 			logger.Debug("done split keyvaluestore failed", "error", err)
 			logger.Error(nil, "done split keyvaluestore failed")
-			return swarm.ZeroAddress, err
+			return swarm.ZeroAddress, fmt.Errorf("done split keyvaluestore failed: %w", err)
 		}
 		err = putter.Done(historyReference)
 		if err != nil {
 			logger.Debug("done split history failed", "error", err)
 			logger.Error(nil, "done split history failed")
-			return swarm.ZeroAddress, err
+			return swarm.ZeroAddress, fmt.Errorf("done split history failed: %w", err)
 		}
 	}
 
diff --git a/pkg/api/dynamicaccess_test.go b/pkg/api/dynamicaccess_test.go
index a2d0cd6e4b2..96891e13578 100644
--- a/pkg/api/dynamicaccess_test.go
+++ b/pkg/api/dynamicaccess_test.go
@@ -221,10 +221,11 @@ func TestDacEachEndpointWithAct(t *testing.T) {
 	}
 }
 
-// nolint:paralleltest,tparallel
 // TestDacWithoutActHeader [negative tests]:
 // 1. upload w/ "Swarm-Act" header then try to dowload w/o the header.
 // 2. upload w/o "Swarm-Act" header then try to dowload w/ the header.
+//
+//nolint:paralleltest,tparallel
 func TestDacWithoutAct(t *testing.T) {
 	t.Parallel()
 	var (
@@ -321,8 +322,9 @@ func TestDacWithoutAct(t *testing.T) {
 	})
 }
 
-// nolint:paralleltest,tparallel
 // TestDacInvalidPath [negative test]: Expect Bad request when the path address is invalid.
+//
+//nolint:paralleltest,tparallel
 func TestDacInvalidPath(t *testing.T) {
 	t.Parallel()
 	var (
@@ -345,9 +347,7 @@ func TestDacInvalidPath(t *testing.T) {
 			PublicKey: pk.PublicKey,
 			Dac:       mockdac.New(),
 		})
-		var (
-			encryptedRef = "asd"
-		)
+		encryptedRef := "asd"
 
 		jsonhttptest.Request(t, client, http.MethodGet, fileDownloadResource(encryptedRef), http.StatusBadRequest,
 			jsonhttptest.WithRequestHeader(api.SwarmActTimestampHeader, strconv.FormatInt(now, 10)),
@@ -361,7 +361,8 @@ func TestDacInvalidPath(t *testing.T) {
 						Field: "address",
 						Error: api.HexInvalidByteError('s').Error(),
 					},
-				}}),
+				},
+			}),
 			jsonhttptest.WithRequestHeader(api.ContentTypeHeader, "text/html; charset=utf-8"),
 		)
 	})
@@ -516,9 +517,7 @@ func TestDacHistory(t *testing.T) {
 			PublicKey: pk.PublicKey,
 			Dac:       mockdac.New(),
 		})
-		var (
-			testfile = "testfile1"
-		)
+		testfile := "testfile1"
 
 		jsonhttptest.Request(t, client, http.MethodPost, fileUploadResource+"?name="+fileName, http.StatusInternalServerError,
 			jsonhttptest.WithRequestHeader(api.SwarmActHeader, "true"),
@@ -541,9 +540,7 @@ func TestDacHistory(t *testing.T) {
 			PublicKey: pk.PublicKey,
 			Dac:       mockdac.New(mockdac.WithHistory(h, fixtureHref.String())),
 		})
-		var (
-			encryptedRef = "a5df670544eaea29e61b19d8739faa4573b19e4426e58a173e51ed0b5e7e2ade"
-		)
+		encryptedRef := "a5df670544eaea29e61b19d8739faa4573b19e4426e58a173e51ed0b5e7e2ade"
 
 		jsonhttptest.Request(t, client, http.MethodGet, fileDownloadResource(encryptedRef), http.StatusNotFound,
 			jsonhttptest.WithRequestHeader(api.SwarmActTimestampHeader, strconv.FormatInt(now, 10)),
@@ -619,9 +616,7 @@ func TestDacTimestamp(t *testing.T) {
 	})
 
 	t.Run("download-w/o-timestamp", func(t *testing.T) {
-		var (
-			encryptedRef = "a5df670544eaea29e61b19d8739faa4573b19e4426e58a173e51ed0b5e7e2ade"
-		)
+		encryptedRef := "a5df670544eaea29e61b19d8739faa4573b19e4426e58a173e51ed0b5e7e2ade"
 		client, _, _, _ := newTestServer(t, testServerOptions{
 			Storer:    storerMock,
 			Logger:    logger,
@@ -754,7 +749,8 @@ func TestDacPublisher(t *testing.T) {
 						Field: "Swarm-Act-Publisher",
 						Error: "malformed public key: invalid length: 32",
 					},
-				}}),
+				},
+			}),
 			jsonhttptest.WithRequestHeader(api.ContentTypeHeader, "text/html; charset=utf-8"),
 		)
 	})
@@ -785,9 +781,7 @@ func TestDacPublisher(t *testing.T) {
 	})
 
 	t.Run("download-w/o-publisher", func(t *testing.T) {
-		var (
-			encryptedRef = "a5df670544eaea29e61b19d8739faa4573b19e4426e58a173e51ed0b5e7e2ade"
-		)
+		encryptedRef := "a5df670544eaea29e61b19d8739faa4573b19e4426e58a173e51ed0b5e7e2ade"
 		client, _, _, _ := newTestServer(t, testServerOptions{
 			Storer:    storerMock,
 			Logger:    logger,
@@ -862,7 +856,8 @@ func TestDacGrantees(t *testing.T) {
 						Field: "address",
 						Error: api.HexInvalidByteError('s').Error(),
 					},
-				}}),
+				},
+			}),
 		)
 	})
 	t.Run("add-revoke-grantees", func(t *testing.T) {
@@ -904,8 +899,8 @@ func TestDacGrantees(t *testing.T) {
 			jsonhttptest.WithRequestHeader(api.SwarmPostageBatchIdHeader, batchOkStr),
 			jsonhttptest.WithJSONRequestBody(body),
 		)
-
 	})
+
 	t.Run("create-granteelist", func(t *testing.T) {
 		body := api.GranteesPostRequest{
 			GranteeList: []string{
diff --git a/pkg/api/export_test.go b/pkg/api/export_test.go
index fd78ae6974f..916992815a6 100644
--- a/pkg/api/export_test.go
+++ b/pkg/api/export_test.go
@@ -29,9 +29,7 @@ var (
 	EmptyDir            = errEmptyDir
 )
 
-var (
-	ContentTypeTar = contentTypeTar
-)
+var ContentTypeTar = contentTypeTar
 
 var (
 	ErrNoResolver                       = errNoResolver
@@ -139,6 +137,7 @@ type HexInvalidByteError = hexInvalidByteError
 func MapStructure(input, output interface{}, hooks map[string]func(v string) (string, error)) error {
 	return mapStructure(input, output, hooks)
 }
+
 func NewParseError(entry, value string, cause error) error {
 	return newParseError(entry, value, cause)
 }
diff --git a/pkg/api/feed_test.go b/pkg/api/feed_test.go
index a35b9ce3423..7235ad93636 100644
--- a/pkg/api/feed_test.go
+++ b/pkg/api/feed_test.go
@@ -161,7 +161,6 @@ func TestFeed_Post(t *testing.T) {
 			)
 		})
 	})
-
 }
 
 // TestDirectUploadFeed tests that the direct upload endpoint give correct error message in dev mode
diff --git a/pkg/api/metrics.go b/pkg/api/metrics.go
index 7635468f4e3..6064595a0ed 100644
--- a/pkg/api/metrics.go
+++ b/pkg/api/metrics.go
@@ -68,7 +68,6 @@ func newMetrics() metrics {
 }
 
 func toFileSizeBucket(bytes int64) int64 {
-
 	for _, s := range fileSizeBucketsKBytes {
 		if (s * bytesInKB) >= bytes {
 			return s * bytesInKB
diff --git a/pkg/api/pin_test.go b/pkg/api/pin_test.go
index a85c34a9594..00925135efd 100644
--- a/pkg/api/pin_test.go
+++ b/pkg/api/pin_test.go
@@ -136,7 +136,6 @@ func TestPinHandlers(t *testing.T) {
 		rootHash = strings.Trim(header.Get(api.ETagHeader), "\"")
 		checkPinHandlers(t, client, rootHash, false)
 	})
-
 }
 
 func TestPinHandlersInvalidInputs(t *testing.T) {
@@ -194,7 +193,6 @@ func TestPinHandlersInvalidInputs(t *testing.T) {
 const pinRef = "620fcd78c7ce54da2d1b7cc2274a02e190cbe8fecbc3bd244690ab6517ce8f39"
 
 func TestIntegrityHandler(t *testing.T) {
-
 	t.Parallel()
 
 	t.Run("ok", func(t *testing.T) {
diff --git a/pkg/api/postage_test.go b/pkg/api/postage_test.go
index ebf808c1c7a..56cfb606078 100644
--- a/pkg/api/postage_test.go
+++ b/pkg/api/postage_test.go
@@ -17,7 +17,6 @@ import (
 	"time"
 
 	"github.com/ethereum/go-ethereum/common"
-
 	"github.com/ethersphere/bee/v2/pkg/api"
 	"github.com/ethersphere/bee/v2/pkg/bigint"
 	"github.com/ethersphere/bee/v2/pkg/jsonhttp"
@@ -373,7 +372,6 @@ func TestPostageGetBuckets(t *testing.T) {
 
 		jsonhttptest.Request(t, tsNotFound, http.MethodGet, "/stamps/"+batchOkStr+"/buckets", http.StatusNotFound)
 	})
-
 }
 
 func TestReserveState(t *testing.T) {
@@ -406,6 +404,7 @@ func TestReserveState(t *testing.T) {
 		)
 	})
 }
+
 func TestChainState(t *testing.T) {
 	t.Parallel()
 
@@ -433,7 +432,6 @@ func TestChainState(t *testing.T) {
 			}),
 		)
 	})
-
 }
 
 func TestPostageTopUpStamp(t *testing.T) {
@@ -703,7 +701,6 @@ func TestPostageDiluteStamp(t *testing.T) {
 				TxHash:  txHash.String(),
 			}),
 		)
-
 	})
 }
 
diff --git a/pkg/api/probe.go b/pkg/api/probe.go
index 8521d050f8d..5d0be5c1d69 100644
--- a/pkg/api/probe.go
+++ b/pkg/api/probe.go
@@ -58,7 +58,6 @@ func (p *Probe) Healthy() ProbeStatus {
 		return ProbeStatusNOK
 	}
 	return p.healthy.get()
-
 }
 
 // SetHealthy updates the value of the healthy status.
diff --git a/pkg/api/pss_test.go b/pkg/api/pss_test.go
index 6624e6d8d21..c97f6fcf40d 100644
--- a/pkg/api/pss_test.go
+++ b/pkg/api/pss_test.go
@@ -88,7 +88,6 @@ func TestPssWebsocketSingleHandlerDeregister(t *testing.T) {
 	)
 
 	err := cl.SetReadDeadline(time.Now().Add(longTimeout))
-
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -446,10 +445,12 @@ func TestPssPostHandlerInvalidInputs(t *testing.T) {
 	}
 }
 
-type pssSendFn func(context.Context, pss.Targets, swarm.Chunk) error
-type mpss struct {
-	f pssSendFn
-}
+type (
+	pssSendFn func(context.Context, pss.Targets, swarm.Chunk) error
+	mpss      struct {
+		f pssSendFn
+	}
+)
 
 func newMockPss(f pssSendFn) *mpss {
 	return &mpss{f}
diff --git a/pkg/api/settlements_test.go b/pkg/api/settlements_test.go
index 86f2e2e42e1..8096df88c9d 100644
--- a/pkg/api/settlements_test.go
+++ b/pkg/api/settlements_test.go
@@ -79,7 +79,6 @@ func TestSettlements(t *testing.T) {
 	if !equalSettlements(got, expected) {
 		t.Errorf("got settlements: %+v, expected: %+v", got, expected)
 	}
-
 }
 
 func TestSettlementsError(t *testing.T) {
diff --git a/pkg/api/soc_test.go b/pkg/api/soc_test.go
index 79e72ffb603..3f92e6684ff 100644
--- a/pkg/api/soc_test.go
+++ b/pkg/api/soc_test.go
@@ -122,7 +122,6 @@ func TestSOC(t *testing.T) {
 		})
 
 		t.Run("ok batch", func(t *testing.T) {
-
 			s := testingsoc.GenerateMockSOC(t, testData)
 			hexbatch := hex.EncodeToString(batchOk)
 			client, _, _, chanStorer := newTestServer(t, testServerOptions{
diff --git a/pkg/api/staking.go b/pkg/api/staking.go
index 5ca5b06d409..df588471ce3 100644
--- a/pkg/api/staking.go
+++ b/pkg/api/staking.go
@@ -10,7 +10,6 @@ import (
 	"net/http"
 
 	"github.com/ethersphere/bee/v2/pkg/bigint"
-
 	"github.com/ethersphere/bee/v2/pkg/jsonhttp"
 	"github.com/ethersphere/bee/v2/pkg/storageincentives/staking"
 	"github.com/gorilla/mux"
@@ -33,6 +32,7 @@ func (s *Service) stakingAccessHandler(h http.Handler) http.Handler {
 type getStakeResponse struct {
 	StakedAmount *bigint.BigInt `json:"stakedAmount"`
 }
+
 type stakeDepositResponse struct {
 	TxHash string `json:"txhash"`
 }
diff --git a/pkg/api/staking_test.go b/pkg/api/staking_test.go
index e6f4d0b2296..d7d569a8de8 100644
--- a/pkg/api/staking_test.go
+++ b/pkg/api/staking_test.go
@@ -12,9 +12,8 @@ import (
 	"testing"
 
 	"github.com/ethereum/go-ethereum/common"
-	"github.com/ethersphere/bee/v2/pkg/bigint"
-
 	"github.com/ethersphere/bee/v2/pkg/api"
+	"github.com/ethersphere/bee/v2/pkg/bigint"
 	"github.com/ethersphere/bee/v2/pkg/jsonhttp"
 	"github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest"
 	"github.com/ethersphere/bee/v2/pkg/sctx"
diff --git a/pkg/api/status_test.go b/pkg/api/status_test.go
index cc2c568abf4..991806dbb86 100644
--- a/pkg/api/status_test.go
+++ b/pkg/api/status_test.go
@@ -102,6 +102,7 @@ func (m *topologyPeersIterNoopMock) EachConnectedPeer(_ topology.EachPeerFunc, _
 func (m *topologyPeersIterNoopMock) EachConnectedPeerRev(_ topology.EachPeerFunc, _ topology.Select) error {
 	return nil
 }
+
 func (m *topologyPeersIterNoopMock) IsReachable() bool {
 	return true
 }
diff --git a/pkg/api/stewardship.go b/pkg/api/stewardship.go
index 99d330f78cc..bf4d93f0356 100644
--- a/pkg/api/stewardship.go
+++ b/pkg/api/stewardship.go
@@ -8,11 +8,10 @@ import (
 	"errors"
 	"net/http"
 
+	"github.com/ethersphere/bee/v2/pkg/jsonhttp"
 	"github.com/ethersphere/bee/v2/pkg/postage"
 	storage "github.com/ethersphere/bee/v2/pkg/storage"
 	"github.com/ethersphere/bee/v2/pkg/swarm"
-
-	"github.com/ethersphere/bee/v2/pkg/jsonhttp"
 	"github.com/gorilla/mux"
 )
 
diff --git a/pkg/api/tag_test.go b/pkg/api/tag_test.go
index d3b8edeb4dc..4536883c888 100644
--- a/pkg/api/tag_test.go
+++ b/pkg/api/tag_test.go
@@ -11,21 +11,19 @@ import (
 	"strconv"
 	"testing"
 
+	"github.com/ethersphere/bee/v2/pkg/api"
+	"github.com/ethersphere/bee/v2/pkg/jsonhttp"
+	"github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest"
 	mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock"
 	mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock"
 	"github.com/ethersphere/bee/v2/pkg/swarm"
 	"github.com/google/go-cmp/cmp"
-
-	"github.com/ethersphere/bee/v2/pkg/api"
-	"github.com/ethersphere/bee/v2/pkg/jsonhttp"
-	"github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest"
 )
 
 func tagsWithIdResource(id uint64) string { return fmt.Sprintf("/tags/%d", id) }
 
 // nolint:paralleltest
 func TestTags(t *testing.T) {
-
 	var (
 		tagsResource    = "/tags"
 		storerMock      = mockstorer.New()
diff --git a/pkg/api/version.go b/pkg/api/version.go
index b9bf36154c4..6838f773ca8 100644
--- a/pkg/api/version.go
+++ b/pkg/api/version.go
@@ -5,5 +5,7 @@
 package api
 
 // Version is set in the build process.
-var Version = "0.0.0"
-var DebugVersion = "0.0.0"
+var (
+	Version      = "0.0.0"
+	DebugVersion = "0.0.0"
+)
diff --git a/pkg/api/wallet.go b/pkg/api/wallet.go
index 5cdd0de087d..75674e1f48b 100644
--- a/pkg/api/wallet.go
+++ b/pkg/api/wallet.go
@@ -7,9 +7,8 @@ package api
 import (
 	"math/big"
 	"net/http"
-	"strings"
-
 	"slices"
+	"strings"
 
 	"github.com/ethereum/go-ethereum/common"
 	"github.com/ethersphere/bee/v2/pkg/bigint"
diff --git a/pkg/api/welcome_message_test.go b/pkg/api/welcome_message_test.go
index 39d7c19a039..faca74f8c9f 100644
--- a/pkg/api/welcome_message_test.go
+++ b/pkg/api/welcome_message_test.go
@@ -26,7 +26,8 @@ func TestGetWelcomeMessage(t *testing.T) {
 		DebugAPI: true,
 		P2P: mock.New(mock.WithGetWelcomeMessageFunc(func() string {
 			return DefaultTestWelcomeMessage
-		}))})
+		})),
+	})
 
 	jsonhttptest.Request(t, srv, http.MethodGet, "/welcome-message", http.StatusOK,
 		jsonhttptest.WithExpectedJSONResponse(api.WelcomeMessageResponse{
diff --git a/pkg/dynamicaccess/accesslogic.go b/pkg/dynamicaccess/accesslogic.go
index 33b8ba819ba..2d369ca951d 100644
--- a/pkg/dynamicaccess/accesslogic.go
+++ b/pkg/dynamicaccess/accesslogic.go
@@ -3,6 +3,7 @@ package dynamicaccess
 import (
 	"context"
 	"crypto/ecdsa"
+	"fmt"
 
 	encryption "github.com/ethersphere/bee/v2/pkg/encryption"
 	"github.com/ethersphere/bee/v2/pkg/kvs"
@@ -10,11 +11,14 @@ import (
 	"golang.org/x/crypto/sha3"
 )
 
-var hashFunc = sha3.NewLegacyKeccak256
-var oneByteArray = []byte{1}
-var zeroByteArray = []byte{0}
+//nolint:gochecknoglobals
+var (
+	hashFunc      = sha3.NewLegacyKeccak256
+	oneByteArray  = []byte{1}
+	zeroByteArray = []byte{0}
+)
 
-// Read-only interface for the ACT
+// Decryptor is a read-only interface for the ACT.
 type Decryptor interface {
 	// DecryptRef will return a decrypted reference, for given encrypted reference and grantee
 	DecryptRef(ctx context.Context, storage kvs.KeyValueStore, encryptedRef swarm.Address, publisher *ecdsa.PublicKey) (swarm.Address, error)
@@ -22,13 +26,13 @@ type Decryptor interface {
 	Session
 }
 
-// Control interface for the ACT (does write operations)
+// Control interface for the ACT (does write operations).
 type Control interface {
 	// Embedding the Decryptor interface
 	Decryptor
-	// Adds a new grantee to the ACT
+	// AddGrantee adds a new grantee to the ACT
 	AddGrantee(ctx context.Context, storage kvs.KeyValueStore, publisherPubKey, granteePubKey *ecdsa.PublicKey, accessKey *encryption.Key) error
-	// Encrypts a Swarm reference for a given grantee
+	// EncryptRef encrypts a Swarm reference for a given grantee
 	EncryptRef(ctx context.Context, storage kvs.KeyValueStore, grantee *ecdsa.PublicKey, ref swarm.Address) (swarm.Address, error)
 }
 
@@ -38,14 +42,14 @@ type ActLogic struct {
 
 var _ Control = (*ActLogic)(nil)
 
-// Adds a new publisher to an empty act
+// AddPublisher adds a new publisher to an empty act.
 func (al ActLogic) AddPublisher(ctx context.Context, storage kvs.KeyValueStore, publisher *ecdsa.PublicKey) error {
 	accessKey := encryption.GenerateRandomKey(encryption.KeyLength)
 
 	return al.AddGrantee(ctx, storage, publisher, publisher, &accessKey)
 }
 
-// Encrypts a SWARM reference for a publisher
+// EncryptRef encrypts a SWARM reference for a publisher.
 func (al ActLogic) EncryptRef(ctx context.Context, storage kvs.KeyValueStore, publisherPubKey *ecdsa.PublicKey, ref swarm.Address) (swarm.Address, error) {
 	accessKey, err := al.getAccessKey(ctx, storage, publisherPubKey)
 	if err != nil {
@@ -54,13 +58,13 @@ func (al ActLogic) EncryptRef(ctx context.Context, storage kvs.KeyValueStore, pu
 	refCipher := encryption.New(accessKey, 0, uint32(0), hashFunc)
 	encryptedRef, err := refCipher.Encrypt(ref.Bytes())
 	if err != nil {
-		return swarm.ZeroAddress, err
+		return swarm.ZeroAddress, fmt.Errorf("failed to encrypt reference: %w", err)
 	}
 
 	return swarm.NewAddress(encryptedRef), nil
 }
 
-// Adds a new grantee to the ACT
+// AddGrantee adds a new grantee to the ACT.
 func (al ActLogic) AddGrantee(ctx context.Context, storage kvs.KeyValueStore, publisherPubKey, granteePubKey *ecdsa.PublicKey, accessKeyPointer *encryption.Key) error {
 	var (
 		accessKey encryption.Key
@@ -91,14 +95,15 @@ func (al ActLogic) AddGrantee(ctx context.Context, storage kvs.KeyValueStore, pu
 	cipher := encryption.New(encryption.Key(accessKeyDecryptionKey), 0, uint32(0), hashFunc)
 	granteeEncryptedAccessKey, err := cipher.Encrypt(accessKey)
 	if err != nil {
-		return err
+		return fmt.Errorf("failed to encrypt access key: %w", err)
 	}
 
 	// Add the new encrypted access key for the Act
+	//nolint:wrapcheck
 	return storage.Put(ctx, lookupKey, granteeEncryptedAccessKey)
 }
 
-// Will return the access key for a publisher (public key)
+// Will return the access key for a publisher (public key).
 func (al *ActLogic) getAccessKey(ctx context.Context, storage kvs.KeyValueStore, publisherPubKey *ecdsa.PublicKey) ([]byte, error) {
 	keys, err := al.getKeys(publisherPubKey)
 	if err != nil {
@@ -110,7 +115,7 @@ func (al *ActLogic) getAccessKey(ctx context.Context, storage kvs.KeyValueStore,
 	accessKeyDecryptionCipher := encryption.New(encryption.Key(publisherAKDecryptionKey), 0, uint32(0), hashFunc)
 	encryptedAK, err := storage.Get(ctx, publisherLookupKey)
 	if err != nil {
-		return nil, err
+		return nil, fmt.Errorf("failed go get value from KVS: %w", err)
 	}
 
 	return accessKeyDecryptionCipher.Decrypt(encryptedAK)
@@ -133,7 +138,7 @@ func (al ActLogic) DecryptRef(ctx context.Context, storage kvs.KeyValueStore, en
 	// Lookup encrypted access key from the ACT manifest
 	encryptedAccessKey, err := storage.Get(ctx, lookupKey)
 	if err != nil {
-		return swarm.ZeroAddress, err
+		return swarm.ZeroAddress, fmt.Errorf("failed to get access key from KVS: %w", err)
 	}
 
 	// Decrypt access key
diff --git a/pkg/dynamicaccess/accesslogic_test.go b/pkg/dynamicaccess/accesslogic_test.go
index 66a3f8930e3..3df2f28a197 100644
--- a/pkg/dynamicaccess/accesslogic_test.go
+++ b/pkg/dynamicaccess/accesslogic_test.go
@@ -79,7 +79,6 @@ func TestDecryptRef_Success(t *testing.T) {
 	}
 
 	if expectedRef.Compare(acutalRef) != 0 {
-
 		t.Errorf("Get gave back wrong Swarm reference!")
 	}
 }
@@ -123,7 +122,6 @@ func TestDecryptRefWithGrantee_Success(t *testing.T) {
 	}
 
 	if expectedRef.Compare(acutalRef) != 0 {
-
 		t.Errorf("Get gave back wrong Swarm reference!")
 	}
 }
@@ -184,7 +182,6 @@ func TestAddPublisher(t *testing.T) {
 }
 
 func TestAddNewGranteeToContent(t *testing.T) {
-
 	id0 := getPrivKey(0)
 	id1 := getPrivKey(1)
 	id2 := getPrivKey(2)
diff --git a/pkg/dynamicaccess/controller.go b/pkg/dynamicaccess/controller.go
index 5deb69c9ffe..8eb8fb4b275 100644
--- a/pkg/dynamicaccess/controller.go
+++ b/pkg/dynamicaccess/controller.go
@@ -33,13 +33,13 @@ type Controller interface {
 	io.Closer
 }
 
-type controller struct {
+type ControllerStruct struct {
 	accessLogic ActLogic
 }
 
-var _ Controller = (*controller)(nil)
+var _ Controller = (*ControllerStruct)(nil)
 
-func (c *controller) DownloadHandler(
+func (c *ControllerStruct) DownloadHandler(
 	ctx context.Context,
 	ls file.LoadSaver,
 	encryptedRef swarm.Address,
@@ -63,7 +63,7 @@ func (c *controller) DownloadHandler(
 	return c.accessLogic.DecryptRef(ctx, act, encryptedRef, publisher)
 }
 
-func (c *controller) UploadHandler(
+func (c *ControllerStruct) UploadHandler(
 	ctx context.Context,
 	ls file.LoadSaver,
 	refrefence swarm.Address,
@@ -76,6 +76,7 @@ func (c *controller) UploadHandler(
 		actRef  swarm.Address
 	)
 	now := time.Now().Unix()
+	//nolint:nestif
 	if historyRef.IsZero() {
 		history, err := NewHistory(ls)
 		if err != nil {
@@ -121,13 +122,13 @@ func (c *controller) UploadHandler(
 	return actRef, historyRef, encryptedRef, err
 }
 
-func NewController(accessLogic ActLogic) Controller {
-	return &controller{
+func NewController(accessLogic ActLogic) *ControllerStruct {
+	return &ControllerStruct{
 		accessLogic: accessLogic,
 	}
 }
 
-func (c *controller) HandleGrantees(
+func (c *ControllerStruct) HandleGrantees(
 	ctx context.Context,
 	ls file.LoadSaver,
 	gls file.LoadSaver,
@@ -254,7 +255,7 @@ func (c *controller) HandleGrantees(
 	return glref, eglref, href, actref, nil
 }
 
-func (c *controller) GetGrantees(ctx context.Context, ls file.LoadSaver, publisher *ecdsa.PublicKey, encryptedglref swarm.Address) ([]*ecdsa.PublicKey, error) {
+func (c *ControllerStruct) GetGrantees(ctx context.Context, ls file.LoadSaver, publisher *ecdsa.PublicKey, encryptedglref swarm.Address) ([]*ecdsa.PublicKey, error) {
 	granteeRef, err := c.decryptRefForPublisher(publisher, encryptedglref)
 	if err != nil {
 		return nil, err
@@ -266,7 +267,7 @@ func (c *controller) GetGrantees(ctx context.Context, ls file.LoadSaver, publish
 	return gl.Get(), nil
 }
 
-func (c *controller) encryptRefForPublisher(publisherPubKey *ecdsa.PublicKey, ref swarm.Address) (swarm.Address, error) {
+func (c *ControllerStruct) encryptRefForPublisher(publisherPubKey *ecdsa.PublicKey, ref swarm.Address) (swarm.Address, error) {
 	keys, err := c.accessLogic.Session.Key(publisherPubKey, [][]byte{oneByteArray})
 	if err != nil {
 		return swarm.ZeroAddress, err
@@ -280,7 +281,7 @@ func (c *controller) encryptRefForPublisher(publisherPubKey *ecdsa.PublicKey, re
 	return swarm.NewAddress(encryptedRef), nil
 }
 
-func (c *controller) decryptRefForPublisher(publisherPubKey *ecdsa.PublicKey, encryptedRef swarm.Address) (swarm.Address, error) {
+func (c *ControllerStruct) decryptRefForPublisher(publisherPubKey *ecdsa.PublicKey, encryptedRef swarm.Address) (swarm.Address, error) {
 	keys, err := c.accessLogic.Session.Key(publisherPubKey, [][]byte{oneByteArray})
 	if err != nil {
 		return swarm.ZeroAddress, err
@@ -301,6 +302,6 @@ func requestPipelineFactory(ctx context.Context, s storage.Putter, encrypt bool,
 }
 
 // TODO: what to do in close ?
-func (s *controller) Close() error {
+func (s *ControllerStruct) Close() error {
 	return nil
 }
diff --git a/pkg/dynamicaccess/controller_test.go b/pkg/dynamicaccess/controller_test.go
index 2b3065899a1..58087171892 100644
--- a/pkg/dynamicaccess/controller_test.go
+++ b/pkg/dynamicaccess/controller_test.go
@@ -15,9 +15,11 @@ import (
 	"github.com/ethersphere/bee/v2/pkg/kvs"
 	"github.com/ethersphere/bee/v2/pkg/swarm"
 	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/require"
 	"golang.org/x/crypto/sha3"
 )
 
+//nolint:errcheck,gosec,wrapcheck
 func getHistoryFixture(ctx context.Context, ls file.LoadSaver, al dynamicaccess.ActLogic, publisher *ecdsa.PublicKey) (swarm.Address, error) {
 	h, err := dynamicaccess.NewHistory(ls)
 	if err != nil {
@@ -67,14 +69,14 @@ func TestController_UploadHandler(t *testing.T) {
 		expRef, err := al.EncryptRef(ctx, act, &publisher.PublicKey, ref)
 
 		assert.NoError(t, err)
-		assert.Equal(t, encRef, expRef)
+		assert.Equal(t, expRef, encRef)
 		assert.NotEqual(t, hRef, swarm.ZeroAddress)
 	})
 
 	t.Run("Upload to same history", func(t *testing.T) {
 		ref := swarm.RandAddress(t)
 		_, hRef1, _, err := c.UploadHandler(ctx, ls, ref, &publisher.PublicKey, swarm.ZeroAddress)
-		assert.NoError(t, err)
+		require.NoError(t, err) // If assert fails, the test continues, if require fails, the test stops we need to consider which to use
 		_, hRef2, encRef, err := c.UploadHandler(ctx, ls, ref, &publisher.PublicKey, hRef1)
 		assert.NoError(t, err)
 		h, err := dynamicaccess.NewHistoryReference(ls, hRef2)
diff --git a/pkg/dynamicaccess/grantee.go b/pkg/dynamicaccess/grantee.go
index 02cd8099021..2cb77236b44 100644
--- a/pkg/dynamicaccess/grantee.go
+++ b/pkg/dynamicaccess/grantee.go
@@ -4,6 +4,7 @@ import (
 	"context"
 	"crypto/ecdsa"
 	"crypto/elliptic"
+	"errors"
 	"fmt"
 
 	"github.com/btcsuite/btcd/btcec/v2"
@@ -76,13 +77,18 @@ func (g *GranteeListStruct) Save(ctx context.Context) (swarm.Address, error) {
 	return swarm.NewAddress(refBytes), nil
 }
 
+var (
+	ErrNothingToRemove = errors.New("nothing to remove")
+	ErrNoGranteeFound  = errors.New("no grantee found")
+)
+
 func (g *GranteeListStruct) Remove(keysToRemove []*ecdsa.PublicKey) error {
 	if len(keysToRemove) == 0 {
-		return fmt.Errorf("nothing to remove")
+		return ErrNothingToRemove
 	}
 
 	if len(g.grantees) == 0 {
-		return fmt.Errorf("no grantee found")
+		return ErrNoGranteeFound
 	}
 	grantees := g.grantees
 
@@ -99,17 +105,17 @@ func (g *GranteeListStruct) Remove(keysToRemove []*ecdsa.PublicKey) error {
 	return nil
 }
 
-func NewGranteeList(ls file.LoadSaver) (GranteeList, error) {
+func NewGranteeList(ls file.LoadSaver) (*GranteeListStruct, error) { // Why is the error necessary?
 	return &GranteeListStruct{
 		grantees: []*ecdsa.PublicKey{},
 		loadSave: ls,
 	}, nil
 }
 
-func NewGranteeListReference(ls file.LoadSaver, reference swarm.Address) (GranteeList, error) {
+func NewGranteeListReference(ls file.LoadSaver, reference swarm.Address) (*GranteeListStruct, error) {
 	data, err := ls.Load(context.Background(), reference.Bytes())
 	if err != nil {
-		return nil, err
+		return nil, fmt.Errorf("unable to load reference, %w", err)
 	}
 	grantees := deserialize(data)
 
diff --git a/pkg/dynamicaccess/history.go b/pkg/dynamicaccess/history.go
index 25193adf886..7543007ad0c 100644
--- a/pkg/dynamicaccess/history.go
+++ b/pkg/dynamicaccess/history.go
@@ -20,44 +20,47 @@ type History interface {
 	Store(ctx context.Context) (swarm.Address, error)
 }
 
-var _ History = (*history)(nil)
+var _ History = (*HistoryStruct)(nil)
 
-var ErrEndIteration = errors.New("end iteration")
+var (
+	ErrEndIteration   = errors.New("end iteration")
+	ErrUnexpectedType = errors.New("unexpected type")
+)
 
-type history struct {
+type HistoryStruct struct {
 	manifest *manifest.MantarayManifest
 	ls       file.LoadSaver
 }
 
-func NewHistory(ls file.LoadSaver) (History, error) {
+func NewHistory(ls file.LoadSaver) (*HistoryStruct, error) {
 	m, err := manifest.NewDefaultManifest(ls, false)
 	if err != nil {
-		return nil, err
+		return nil, fmt.Errorf("failed to create default manifest: %w", err)
 	}
 
 	mm, ok := m.(*manifest.MantarayManifest)
 	if !ok {
-		return nil, fmt.Errorf("expected MantarayManifest, got %T", m)
+		return nil, fmt.Errorf("%w: expected MantarayManifest, got %T", ErrUnexpectedType, m)
 	}
 
-	return &history{manifest: mm, ls: ls}, nil
+	return &HistoryStruct{manifest: mm, ls: ls}, nil
 }
 
-func NewHistoryReference(ls file.LoadSaver, ref swarm.Address) (History, error) {
+func NewHistoryReference(ls file.LoadSaver, ref swarm.Address) (*HistoryStruct, error) {
 	m, err := manifest.NewDefaultManifestReference(ref, ls)
 	if err != nil {
-		return nil, err
+		return nil, fmt.Errorf("failed to create default manifest: %w", err)
 	}
 
 	mm, ok := m.(*manifest.MantarayManifest)
 	if !ok {
-		return nil, fmt.Errorf("expected MantarayManifest, got %T", m)
+		return nil, fmt.Errorf("%w: expected MantarayManifest, got %T", ErrUnexpectedType, m)
 	}
 
-	return &history{manifest: mm, ls: ls}, nil
+	return &HistoryStruct{manifest: mm, ls: ls}, nil
 }
 
-func (h *history) Add(ctx context.Context, ref swarm.Address, timestamp *int64, metadata *map[string]string) error {
+func (h *HistoryStruct) Add(ctx context.Context, ref swarm.Address, timestamp *int64, metadata *map[string]string) error {
 	mtdt := map[string]string{}
 	if metadata != nil {
 		mtdt = *metadata
@@ -74,10 +77,12 @@ func (h *history) Add(ctx context.Context, ref swarm.Address, timestamp *int64,
 	return h.manifest.Add(ctx, key, manifest.NewEntry(ref, mtdt))
 }
 
+var ErrInvalidTimestamp = errors.New("invalid timestamp")
+
 // Lookup finds the entry for a path or returns error if not found
-func (h *history) Lookup(ctx context.Context, timestamp int64) (manifest.Entry, error) {
+func (h *HistoryStruct) Lookup(ctx context.Context, timestamp int64) (manifest.Entry, error) {
 	if timestamp <= 0 {
-		return manifest.NewEntry(swarm.ZeroAddress, map[string]string{}), errors.New("invalid timestamp")
+		return manifest.NewEntry(swarm.ZeroAddress, map[string]string{}), ErrInvalidTimestamp
 	}
 
 	reversedTimestamp := math.MaxInt64 - timestamp
@@ -93,7 +98,7 @@ func (h *history) Lookup(ctx context.Context, timestamp int64) (manifest.Entry,
 	return manifest.NewEntry(swarm.ZeroAddress, map[string]string{}), nil
 }
 
-func (h *history) lookupNode(ctx context.Context, searchedTimestamp int64) (*mantaray.Node, error) {
+func (h *HistoryStruct) lookupNode(ctx context.Context, searchedTimestamp int64) (*mantaray.Node, error) {
 	// before node's timestamp is the closest one that is less than or equal to the searched timestamp
 	// for instance: 2030, 2020, 1994 -> search for 2021 -> before is 2020
 	var beforeNode *mantaray.Node
@@ -134,12 +139,11 @@ func (h *history) lookupNode(ctx context.Context, searchedTimestamp int64) (*man
 	}
 	if afterNode != nil {
 		return afterNode, nil
-
 	}
 	return nil, nil
 }
 
-func (h *history) Store(ctx context.Context) (swarm.Address, error) {
+func (h *HistoryStruct) Store(ctx context.Context) (swarm.Address, error) {
 	return h.manifest.Store(ctx)
 }
 
diff --git a/pkg/dynamicaccess/mock/session.go b/pkg/dynamicaccess/mock/session.go
index 9613aacedfa..f6a398e75a9 100644
--- a/pkg/dynamicaccess/mock/session.go
+++ b/pkg/dynamicaccess/mock/session.go
@@ -17,7 +17,6 @@ func (s *SessionMock) Key(publicKey *ecdsa.PublicKey, nonces [][]byte) ([][]byte
 		return nil, nil
 	}
 	return s.KeyFunc(publicKey, nonces)
-
 }
 
 func NewSessionMock(key *ecdsa.PrivateKey) *SessionMock {
diff --git a/pkg/dynamicaccess/session.go b/pkg/dynamicaccess/session.go
index 0b58c1aa3dd..76491daad46 100644
--- a/pkg/dynamicaccess/session.go
+++ b/pkg/dynamicaccess/session.go
@@ -3,6 +3,7 @@ package dynamicaccess
 import (
 	"crypto/ecdsa"
 	"errors"
+	"fmt"
 
 	"github.com/ethersphere/bee/v2/pkg/crypto"
 	"github.com/ethersphere/bee/v2/pkg/keystore"
@@ -14,19 +15,24 @@ type Session interface {
 	Key(publicKey *ecdsa.PublicKey, nonces [][]byte) ([][]byte, error)
 }
 
-var _ Session = (*session)(nil)
+var _ Session = (*SessionStruct)(nil)
 
-type session struct {
+type SessionStruct struct {
 	key *ecdsa.PrivateKey
 }
 
-func (s *session) Key(publicKey *ecdsa.PublicKey, nonces [][]byte) ([][]byte, error) {
+var (
+	ErrInvalidPublicKey  = errors.New("invalid public key")
+	ErrSecretKeyInfinity = errors.New("shared secret is point at infinity")
+)
+
+func (s *SessionStruct) Key(publicKey *ecdsa.PublicKey, nonces [][]byte) ([][]byte, error) {
 	if publicKey == nil {
-		return nil, errors.New("invalid public key")
+		return nil, ErrInvalidPublicKey
 	}
 	x, y := publicKey.Curve.ScalarMult(publicKey.X, publicKey.Y, s.key.D.Bytes())
 	if x == nil || y == nil {
-		return nil, errors.New("shared secret is point at infinity")
+		return nil, ErrSecretKeyInfinity
 	}
 
 	if len(nonces) == 0 {
@@ -37,7 +43,7 @@ func (s *session) Key(publicKey *ecdsa.PublicKey, nonces [][]byte) ([][]byte, er
 	for _, nonce := range nonces {
 		key, err := crypto.LegacyKeccak256(append(x.Bytes(), nonce...))
 		if err != nil {
-			return nil, err
+			return nil, fmt.Errorf("failed to get Keccak256 hash: %w", err)
 		}
 		keys = append(keys, key)
 	}
@@ -45,13 +51,13 @@ func (s *session) Key(publicKey *ecdsa.PublicKey, nonces [][]byte) ([][]byte, er
 	return keys, nil
 }
 
-func NewDefaultSession(key *ecdsa.PrivateKey) Session {
-	return &session{
+func NewDefaultSession(key *ecdsa.PrivateKey) *SessionStruct {
+	return &SessionStruct{
 		key: key,
 	}
 }
 
 // Currently implemented only in mock/session.go
-func NewFromKeystore(ks keystore.Service, tag, password string) Session {
+func NewFromKeystore(keystore.Service, string, string) Session {
 	return nil
 }
diff --git a/pkg/dynamicaccess/session_test.go b/pkg/dynamicaccess/session_test.go
index 493b998a805..382a79190d5 100644
--- a/pkg/dynamicaccess/session_test.go
+++ b/pkg/dynamicaccess/session_test.go
@@ -14,7 +14,7 @@ import (
 	memkeystore "github.com/ethersphere/bee/v2/pkg/keystore/mem"
 )
 
-func mockKeyFunc(publicKey *ecdsa.PublicKey, nonces [][]byte) ([][]byte, error) {
+func mockKeyFunc(*ecdsa.PublicKey, [][]byte) ([][]byte, error) {
 	return [][]byte{{1}}, nil
 }
 
diff --git a/pkg/kvs/kvs_test.go b/pkg/kvs/kvs_test.go
index 462e092d532..f542c86144b 100644
--- a/pkg/kvs/kvs_test.go
+++ b/pkg/kvs/kvs_test.go
@@ -37,7 +37,6 @@ func keyValuePair(t *testing.T) ([]byte, []byte) {
 }
 
 func TestKvs(t *testing.T) {
-
 	s, err := kvs.New(createLs())
 	assert.NoError(t, err)
 
diff --git a/pkg/kvs/mock/kvs.go b/pkg/kvs/mock/kvs.go
index 0203cc52ce6..767c8868dcf 100644
--- a/pkg/kvs/mock/kvs.go
+++ b/pkg/kvs/mock/kvs.go
@@ -24,7 +24,8 @@ func getInMemorySwarm() *single {
 		defer lock.Unlock()
 		if singleInMemorySwarm == nil {
 			singleInMemorySwarm = &single{
-				memoryMock: make(map[string]map[string][]byte)}
+				memoryMock: make(map[string]map[string][]byte),
+			}
 		}
 	}
 	return singleInMemorySwarm
diff --git a/pkg/manifest/mantaray/node.go b/pkg/manifest/mantaray/node.go
index 5a59c010d52..9561c299db5 100644
--- a/pkg/manifest/mantaray/node.go
+++ b/pkg/manifest/mantaray/node.go
@@ -16,13 +16,8 @@ const (
 )
 
 var (
-	ZeroObfuscationKey []byte
-)
-
-// nolint:gochecknoinits
-func init() {
 	ZeroObfuscationKey = make([]byte, 32)
-}
+)
 
 // Error used when lookup path does not match
 var (