Skip to content

Commit

Permalink
chore: lint: enable function godoc linting
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Jul 19, 2024
1 parent 428524f commit 9e6e781
Show file tree
Hide file tree
Showing 19 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ issues:
- "^blank-imports: a blank import should be only in a main or test package, or have a comment justifying it"
- "^dot-imports: should not use dot imports"
- "^exported: (func|type) name will be used as [^\\s]+ by other packages, and that stutters; consider calling this \\w+"
- "^exported: comment on exported (const|function|type|var) [^\\s]+ should be of the form \"\\w+ ...\""
- "^exported: comment on exported (const|type|var) [^\\s]+ should be of the form \"\\w+ ...\""
- "^exported: exported (const|function|method|type|var) [^\\s]+ should have comment (\\(or a comment on this block\\) )?or be unexported"
- "^indent-error-flow: if block ends with a return statement, so drop this else and outdent its block \\(move short variable declaration to its own line if necessary\\)"
- "^package-comments: package comment should be of the form \"Package \\w+ ...\""
Expand Down
2 changes: 1 addition & 1 deletion chain/actors/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func GetActorCodeIDsFromManifest(av actorstypes.Version) (map[string]cid.Cid, bo
return cids, ok
}

// Given a Manifest CID, get the manifest from the store and Load data into its entries
// LoadManifest will get the manifest for a given Manifest CID from the store and Load data into its entries
func LoadManifest(ctx context.Context, mfCid cid.Cid, adtStore adt.Store) (*manifest.Manifest, error) {
var mf manifest.Manifest

Expand Down
4 changes: 2 additions & 2 deletions chain/actors/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ func SetPreCommitChallengeDelay(delay abi.ChainEpoch) {

}

// TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay.
func GetPreCommitChallengeDelay() abi.ChainEpoch {
// TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay.
return miner14.PreCommitChallengeDelay
}

Expand Down Expand Up @@ -521,7 +521,7 @@ func DealDurationBounds(pieceSize abi.PaddedPieceSize) (min, max abi.ChainEpoch)
return market14.DealDurationBounds(pieceSize)
}

// Sets the challenge window and scales the proving period to match (such that
// SetWPoStChallengeWindow sets the challenge window and scales the proving period to match (such that
// there are always 48 challenge windows in a proving period).
func SetWPoStChallengeWindow(period abi.ChainEpoch) {

Expand Down
1 change: 1 addition & 0 deletions chain/gen/genesis/miners.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func mkFakedSigSyscalls(base vm.SyscallBuilder) vm.SyscallBuilder {
}

// Note: Much of this is brittle, if the methodNum / param / return changes, it will break things

func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.SyscallBuilder, sroot cid.Cid, miners []genesis.Miner, nv network.Version, synthetic bool) (cid.Cid, error) {

cst := cbor.NewCborStore(cs.StateBlockstore())
Expand Down
2 changes: 1 addition & 1 deletion chain/stmgr/actors.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func PreCommitInfo(ctx context.Context, sm *StateManager, maddr address.Address,
return mas.GetPrecommittedSector(sid)
}

// Returns nil, nil if sector is not found
// MinerSectorInfo returns nil, nil if sector is not found
func MinerSectorInfo(ctx context.Context, sm *StateManager, maddr address.Address, sid abi.SectorNumber, ts *types.TipSet) (*miner.SectorOnChainInfo, error) {
act, err := sm.LoadActor(ctx, maddr, ts)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions chain/sub/incoming.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func FetchMessagesByCids(
}

// FIXME: Duplicate of above.

func FetchSignedMessagesByCids(
ctx context.Context,
bserv bserv.BlockGetter,
Expand Down
1 change: 1 addition & 0 deletions chain/sync_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ type workerStatus struct {
}

// sync manager interface

func NewSyncManager(sync SyncFunc) SyncManager {
ctx, cancel := context.WithCancel(context.Background())
return &syncManager{
Expand Down
2 changes: 1 addition & 1 deletion chain/types/ethtypes/eth_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func EthUint64FromHex(s string) (EthUint64, error) {
return EthUint64(parsedInt), nil
}

// Parse a uint64 from big-endian encoded bytes.
// EthUint64FromBytes parses a uint64 from big-endian encoded bytes.
func EthUint64FromBytes(b []byte) (EthUint64, error) {
if len(b) != 32 {
return 0, xerrors.Errorf("eth int must be 32 bytes long")
Expand Down
2 changes: 1 addition & 1 deletion chain/types/mock/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TipSet(blks ...*types.BlockHeader) *types.TipSet {
return ts
}

// Generates count new addresses using the provided seed, and returns them
// RandomActorAddresses generates count new addresses using the provided seed, and returns them
func RandomActorAddresses(seed int64, count int) ([]*address.Address, error) {
randAddrs := make([]*address.Address, count)
source := rand.New(rand.NewSource(seed))
Expand Down
2 changes: 1 addition & 1 deletion chain/types/tipset.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func tipsetSortFunc(blks []*BlockHeader) func(i, j int) bool {
}
}

// Checks:
// NewTipSet checks:
// - A tipset is composed of at least one block. (Because of our variable
// number of blocks per tipset, determined by randomness, we do not impose
// an upper limit.)
Expand Down
2 changes: 1 addition & 1 deletion cli/util/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func GetFullNodeAPI(ctx *cli.Context) (v0api.FullNode, jsonrpc.ClientCloser, err

type contextKey string

// Not thread safe
// OnSingleNode is not thread safe
func OnSingleNode(ctx context.Context) context.Context {
return context.WithValue(ctx, contextKey("retry-node"), new(*int))
}
Expand Down
2 changes: 1 addition & 1 deletion gateway/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (h RateLimiterHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.handler.ServeHTTP(w, r)
}

// this blocks new connections if there have already been too many.
// NewConnectionRateLimiterHandler blocks new connections if there have already been too many.
func NewConnectionRateLimiterHandler(handler http.Handler, connPerMinute int64) *ConnectionRateLimiterHandler {
ipmap := make(map[string]int64)
return &ConnectionRateLimiterHandler{
Expand Down
2 changes: 1 addition & 1 deletion itests/kit/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func (e *EVM) WaitTransaction(ctx context.Context, hash ethtypes.EthHash) (*api.
return nil, xerrors.Errorf("couldn't find message CID for txn hash: %s", hash)
}

// function signatures are the first 4 bytes of the hash of the function name and types
// CalcFuncSignature returns the first 4 bytes of the hash of the function name and types
func CalcFuncSignature(funcName string) []byte {
hasher := sha3.NewLegacyKeccak256()
hasher.Write([]byte(funcName))
Expand Down
6 changes: 4 additions & 2 deletions itests/kit/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const EnvRunExpensiveTests = "LOTUS_RUN_EXPENSIVE_TESTS"
// a standard CI setup, and should be skipped unless explicitly enabled.
const EnvRunVeryExpensiveTests = "LOTUS_RUN_VERY_EXPENSIVE_TESTS"

// Expensive marks a test as expensive, skipping it immediately if not running an
// Expensive marks a test as expensive, skipping it immediately if not running in a CI environment
// or if the LOTUS_RUN_EXPENSIVE_TESTS environment variable is not set to "1".
func Expensive(t *testing.T) {
switch {
case os.Getenv("CI") == "true":
Expand All @@ -25,7 +26,8 @@ func Expensive(t *testing.T) {
}
}

// Expensive marks a test as expensive, skipping it immediately if not running an
// VeryExpensive marks a test as VERY expensive, skipping it immediately if the
// LOTUS_RUN_VERY_EXPENSIVE_TESTS environment variable is not set to "1".
func VeryExpensive(t *testing.T) {
if os.Getenv(EnvRunVeryExpensiveTests) != "1" {
t.Skipf("skipping VERY expensive test outside of CI; enable by setting env var %s=1", EnvRunVeryExpensiveTests)
Expand Down
3 changes: 2 additions & 1 deletion lib/tablewriter/tablewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ func NewLineCol(name string) Column {
}
}

// Unlike text/tabwriter, this works with CLI escape codes, and allows for info
// New creates a new TableWriter. Unlike text/tabwriter, this works with CLI escape codes, and
// allows for info
//
// in separate lines
func New(cols ...Column) *TableWriter {
Expand Down
2 changes: 1 addition & 1 deletion node/config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func NoDefaultForSplitstoreTransition() error {
return xerrors.Errorf("FullNode config not found and fallback to default disallowed while we transition to splitstore discard default. Use `lotus config default` to set this repo up with a default config. Be sure to set `EnableSplitstore` to `false` if you are running a full archive node")
}

// Match the EnableSplitstore field
// MatchEnableSplitstoreField matches the EnableSplitstore field
func MatchEnableSplitstoreField(s string) bool {
enableSplitstoreRx := regexp.MustCompile(`(?m)^\s*EnableSplitstore\s*=`)
return enableSplitstoreRx.MatchString(s)
Expand Down
4 changes: 2 additions & 2 deletions node/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (h *HealthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}

// Check that the node is still working. That is, that it's still processing the chain.
// NewLiveHandler checks that the node is still working. That is, that it's still processing the chain.
// If there have been no recent changes, consider the node to be dead.
func NewLiveHandler(api lapi.FullNode) *HealthHandler {
ctx := context.Background()
Expand Down Expand Up @@ -90,7 +90,7 @@ func NewLiveHandler(api lapi.FullNode) *HealthHandler {
return &h
}

// Check if we are ready to handle traffic.
// NewReadyHandler checks if we are ready to handle traffic.
// 1. sync workers are reasonably up to date.
// 2. libp2p is servicable
func NewReadyHandler(api lapi.FullNode) *HealthHandler {
Expand Down
3 changes: 2 additions & 1 deletion node/modules/lp2p/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ func NoRelay() func() (opts Libp2pOpts, err error) {
}
}

// TODO: should be use baseRouting or can we use higher level router here?
func Discovery(router BaseIpfsRouting) (coredisc.Discovery, error) {
// TODO: should be use baseRouting or can we use higher level router here?

crouter, ok := router.(routing.ContentRouting)
if !ok {
return nil, fmt.Errorf("no suitable routing for discovery")
Expand Down
2 changes: 1 addition & 1 deletion node/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func Unset(typ interface{}) Option {
}
}

// From(*T) -> func(t T) T {return t}
// From (*T) -> func(t T) T {return t}
func From(typ interface{}) interface{} {
rt := []reflect.Type{reflect.TypeOf(typ).Elem()}
ft := reflect.FuncOf(rt, rt, false)
Expand Down

0 comments on commit 9e6e781

Please sign in to comment.