chain/reorg.go
Method reorganizer.gather
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
Open
func (reorg *reorganizer) gather() error {
//find branch root block , gather rollforward Target block
var err error
cdb := reorg.cs.cdb
- 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
Method reorganizer.gather
has 8 return statements (exceeds 4 allowed). Open
Open
func (reorg *reorganizer) gather() error {
//find branch root block , gather rollforward Target block
var err error
cdb := reorg.cs.cdb
Method reorganizer.swapChain
has 7 return statements (exceeds 4 allowed). Open
Open
func (reorg *reorganizer) swapChain() error {
logger.Info().Msg("swap chain to new branch")
if err := TestDebugger.Check(DEBUG_CHAIN_STOP, 1, nil); err != nil {
return err
Method ChainService.reorg
has 7 return statements (exceeds 4 allowed). Open
Open
func (cs *ChainService) reorg(topBlock *types.Block, marker *ReorgMarker) error {
logger.Info().Uint64("blockNo", topBlock.GetHeader().GetBlockNo()).Str("hash", topBlock.ID()).
Bool("recovery", (marker != nil)).Msg("reorg started")
begT := time.Now()
Method reorganizer.gatherReco
has 5 return statements (exceeds 4 allowed). Open
Open
func (reorg *reorganizer) gatherReco() error {
var err error
cdb := reorg.cs.cdb
Method reorganizer.initRecovery
has 5 return statements (exceeds 4 allowed). Open
Open
func (reorg *reorganizer) initRecovery(marker *ReorgMarker) error {
var startBlock, bestBlock, topBlock *types.Block
var err error
if marker == nil {