Showing 142 of 166 total issues
Avoid deeply nested control flow statements. Open
Open
if atomic.AddUint32(sizeHalfPtr, 1) == 20 {
atomic.StoreUint32(sizePtr, uint32(cap(b)/2))
atomic.StoreUint32(sizeHalfPtr, 0)
} else {
select {
Avoid deeply nested control flow statements. Open
Open
if n.value == nil {
n.size = 0
n.mu.Unlock()
n.unref()
return nil
Avoid deeply nested control flow statements. Open
Open
if i.dir == dirSOI || i.icmp.uCompare(ukey, i.key) > 0 {
i.key = append(i.key[:0], ukey...)
i.value = append(i.value[:0], i.iter.Value()...)
i.dir = dirForward
return true
Avoid deeply nested control flow statements. Open
Open
if ourBatch == nil {
ourBatch = db.batchPool.Get().(*Batch)
ourBatch.Reset()
batches = append(batches, ourBatch)
}
Avoid deeply nested control flow statements. Open
Open
if err := b.flush(b.stash(hasLastUkey, lastUkey, lastSeq, i)); err != nil {
return err
}
Method DB.CompactRange
has 7 return statements (exceeds 4 allowed). Open
Open
func (db *DB) CompactRange(r util.Range) error {
if err := db.ok(); err != nil {
return err
}
Avoid deeply nested control flow statements. Open
Open
goto cont
Method DB.tableRangeCompaction
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (db *DB) tableRangeCompaction(level int, umin, umax []byte) error {
db.logf("table@compaction range L%d %q:%q", level, umin, umax)
if level >= 0 {
if c := db.s.getCompactionRange(level, umin, umax, true); c != nil {
db.tableCompaction(c, true)
- 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
Avoid deeply nested control flow statements. Open
Open
if db.resumeWrite() {
x.ack(nil)
} else {
waitQ = append(waitQ, x)
}
Avoid deeply nested control flow statements. Open
Open
select {
case pool <- b:
default:
}
Avoid deeply nested control flow statements. Open
Open
if overlaps.size() > int64(v.s.o.GetCompactionGPOverlaps(level)) {
break
}
Avoid deeply nested control flow statements. Open
Open
if internalLen > mergeLimit {
overflow = true
break merge
}
Avoid deeply nested control flow statements. Open
Open
} else if v.levels[pLevel].overlaps(v.s.icmp, umin, umax, false) {
break
}
Function NewReader
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewReader(f io.ReaderAt, size int64, fd storage.FileDesc, cache *cache.NamespaceGetter, bpool *util.BufferPool, o *opt.Options) (*Reader, error) {
Avoid deeply nested control flow statements. Open
Open
if !del {
i.key = append(i.key[:0], ukey...)
i.value = append(i.value[:0], i.iter.Value()...)
}
Avoid deeply nested control flow statements. Open
Open
select {
case pool <- b:
default:
}
Avoid deeply nested control flow statements. Open
Open
if incoming.batch.internalLen > mergeLimit {
overflow = true
break merge
}
Method DB.putRec
has 7 return statements (exceeds 4 allowed). Open
Open
func (db *DB) putRec(kt keyType, key, value []byte, wo *opt.WriteOptions) error {
if err := db.ok(); err != nil {
return err
}
Avoid deeply nested control flow statements. Open
Open
if setFunc == nil {
n.mu.Unlock()
n.unref()
return nil
}
Method indexedIterator.Prev
has 7 return statements (exceeds 4 allowed). Open
Open
func (i *indexedIterator) Prev() bool {
if i.err != nil {
return false
} else if i.Released() {
i.err = ErrIterReleased