Showing 291 of 829 total issues
Method EventHeaderData.UnmarshalBinary
has 87 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (e *EventHeaderData) UnmarshalBinary(raw []byte) (err error) {
defer func() {
if r := recover(); r != nil {
err = ErrInvalidEncoding
}
Method Index.fillEventVectors
has 87 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (vi *Index) fillEventVectors(e *inter.EventHeaderData) allVecs {
meIdx := vi.validatorIdxs[e.Creator]
myVecs := allVecs{
beforeSeq: NewHighestBeforeSeq(len(vi.bi.BranchIDCreatorIdxs)),
beforeTime: NewHighestBeforeTime(len(vi.bi.BranchIDCreatorIdxs)),
Method TxPool.loop
has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring. Open
Open
func (pool *TxPool) loop() {
defer pool.wg.Done()
var (
prevPending, prevQueued, prevStales int
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function MainGenesis
has 85 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func MainGenesis() Genesis {
g := Genesis{
Time: genesisTime,
Alloc: VAccounts{
Accounts: Accounts{
Function DAGtoASCIIscheme
has 84 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func DAGtoASCIIscheme(events Events) (string, error) {
events = events.ByParents()
var (
scheme rows
Store
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
Open
func (s *Store) IncBlocksMissed(stakerID idx.StakerID, periodDiff inter.Timestamp) {
s.mutex.BlockDowntime.Lock()
defer s.mutex.BlockDowntime.Unlock()
missed := s.getBlocksMissed(stakerID)
Function GetAPIs
has 82 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func GetAPIs(apiBackend Backend) []rpc.API {
nonceLock := new(AddrLocker)
orig := []rpc.API{
{
Namespace: "eth",
Method FilterCriteria.UnmarshalJSON
has 82 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
type input struct {
BlockHash *common.Hash `json:"blockHash"`
FromBlock *rpc.BlockNumber `json:"fromBlock"`
ToBlock *rpc.BlockNumber `json:"toBlock"`
Function DoEstimateGas
has 81 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap uint64) (hexutil.Uint64, error) {
// Binary search the gas requirement, as it may be higher than the amount used
var (
lo uint64 = params.TxGas - 1
hi uint64
Method Election.ProcessRoot
has 81 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (el *Election) ProcessRoot(newRoot RootAndSlot) (*Res, error) {
res, err := el.chooseAtropos()
if err != nil || res != nil {
return res, err
}
Method Store.MigrateMultiDelegations
has 80 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *Store) MigrateMultiDelegations() error {
{ // migrate s.table.Delegations
newKeys := make([][]byte, 0, 10000)
newValues := make([][]byte, 0, 10000)
{
Emitter
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type Emitter struct {
txTime *lru.Cache // tx hash -> tx time
net *lachesis.Config
config *EmitterConfig
Method PeerPacksDownloader.loop
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
Open
func (d *PeerPacksDownloader) loop() {
// Iterate the event fetching until a quit is requested
syncTicker := time.NewTicker(recheckInterval)
defer syncTicker.Stop()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function ForEachRandFork
has 76 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func ForEachRandFork(
nodes []idx.StakerID,
cheatersArr []idx.StakerID,
eventCount int,
parentCount int,
Function ExportState
has 22 return statements (exceeds 4 allowed). Open
Open
func ExportState(path string, gdb *gossip.Store, cdb *poset.Store, net *lachesis.Config) (*genesisstore.Store, error) {
_ = os.RemoveAll(path)
err := os.MkdirAll(path, 0700)
if err != nil {
Method EventHeaderData.MarshalBinary
has 73 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (e *EventHeaderData) MarshalBinary() ([]byte, error) {
isPrevEpochHashEmpty := (e.PrevEpochHash == hash.Zero)
isTxHashEmpty := (e.TxHash == EmptyTxHash)
fields64 := []uint64{
Method ProtocolManager.handleMsg
has 21 return statements (exceeds 4 allowed). Open
Open
func (pm *ProtocolManager) handleMsg(p *peer) error {
// Read the next message from the remote peer, and ensure it's fully consumed
msg, err := p.rw.ReadMsg()
if err != nil {
return err
Method TxPool.reset
has 68 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (pool *TxPool) reset(oldHead, newHead *EvmHeader) {
// If we're reorging an old state, reinject all dropped transactions
var reinject types.Transactions
if oldHead != nil && oldHead.Hash != newHead.ParentHash {
Function lachesisOperaMigrationMain
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func lachesisOperaMigrationMain(ctx *cli.Context) error {
if args := ctx.Args(); len(args) > 0 {
return fmt.Errorf("invalid command: %q", args[0])
}
Method Metric.Write
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (m *Metric) Write(out *dto.Metric) error {
switch metric := m.m.(type) {
case metrics.Meter:
t := metric.Snapshot()