Showing 142 of 166 total issues
Avoid deeply nested control flow statements. Open
Open
if !del && i.icmp.uCompare(ukey, i.key) < 0 {
return true
}
Avoid deeply nested control flow statements. Open
Open
select {
case pool <- b:
default:
}
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
select {
case pool <- b:
default:
}
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 incoming.batch.internalLen > mergeLimit {
overflow = true
break merge
}
Method Writer.Close
has 7 return statements (exceeds 4 allowed). Open
Open
func (w *Writer) Close() error {
if w.err != nil {
return w.err
}
Avoid deeply nested control flow statements. Open
Open
goto cont
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
if overlaps.size() > int64(v.s.o.GetCompactionGPOverlaps(level)) {
break
}
Avoid deeply nested control flow statements. Open
Open
if setFunc == nil {
n.mu.Unlock()
n.unref()
return nil
}
Avoid deeply nested control flow statements. Open
Open
if internalLen > mergeLimit {
overflow = true
break merge
}
Avoid deeply nested control flow statements. Open
Open
if err := b.flush(b.stash(hasLastUkey, lastUkey, lastSeq, i)); err != nil {
return err
}
Method DB.flush
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (db *DB) flush(n int) (mdb *memDB, mdbFree int, err error) {
delayed := false
slowdownTrigger := db.s.o.GetWriteL0SlowdownTrigger()
pauseTrigger := db.s.o.GetWriteL0PauseTrigger()
// 请问您知道这里为什么要用匿名函数吗,我理解的是直接用循环就可以
- 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 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
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
} 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) {
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
Avoid deeply nested control flow statements. Open
Open
if n.value == nil {
n.size = 0
n.mu.Unlock()
n.unref()
return nil