Showing 142 of 166 total issues
Method mBucket.get
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func (b *mBucket) get(r *Cache, h *mNode, hash uint32, ns, key uint64, noset bool) (done, added bool, n *Node) {
Function KeyValueTesting
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func KeyValueTesting(rnd *rand.Rand, kv KeyValue, p DB, setup func(KeyValue) DB, teardown func(DB)) {
Method DB.has
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func (db *DB) has(auxm *memdb.DB, auxt tFiles, key []byte, seq uint64, ro *opt.ReadOptions) (ret bool, err error) {
Function newCompaction
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func newCompaction(s *session, v *version, sourceLevel int, t0 tFiles, typ int) *compaction {
Method version.walkOverlapping
has 5 return statements (exceeds 4 allowed). Open
func (v *version) walkOverlapping(aux tFiles, ikey internalKey, f func(level int, t *tFile) bool, lf func() bool) {
ukey := ikey.ukey()
// Aux level.
if aux != nil {
Function BytesSeparator
has 5 return statements (exceeds 4 allowed). Open
func BytesSeparator(a, b []byte) []byte {
if bytes.Equal(a, b) {
return b
}
i, n := 0, len(a)
Method Cache.Get
has 5 return statements (exceeds 4 allowed). Open
func (r *Cache) Get(ns, key uint64, setFunc func() (size int, value Value)) *Handle {
r.mu.RLock()
defer r.mu.RUnlock()
if r.closed {
return nil
Function KeyValueTesting
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func KeyValueTesting(rnd *rand.Rand, kv KeyValue, p DB, setup func(KeyValue) DB, teardown func(DB)) {
if rnd == nil {
rnd = NewRand()
}
- 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.memCompaction
has 5 return statements (exceeds 4 allowed). Open
func (db *DB) memCompaction() {
mdb := db.getFrozenMem()
if mdb == nil {
return
}
Method session.recover
has 5 return statements (exceeds 4 allowed). Open
func (s *session) recover() (err error) {
defer func() {
if os.IsNotExist(err) {
// Don't return os.ErrNotExist if the underlying storage contains
// other files that belong to LevelDB. So the DB won't get trashed.
Method memStorage.Rename
has 5 return statements (exceeds 4 allowed). Open
func (ms *memStorage) Rename(oldfd, newfd FileDesc) error {
if !FileDescOk(oldfd) || !FileDescOk(newfd) {
return ErrInvalidFile
}
if oldfd == newfd {
Method session.refLoop
has 5 return statements (exceeds 4 allowed). Open
func (s *session) refLoop() {
var (
fileRef = make(map[int64]int) // Table file reference counter
ref = make(map[int64]*vTask) // Current referencing version store
deltas = make(map[int64]*vDelta)
Function Open
has 5 return statements (exceeds 4 allowed). Open
func Open(stor storage.Storage, o *opt.Options) (db *DB, err error) {
s, err := newSession(stor, o)
if err != nil {
return
}
Method DB.writeJournal
has 5 return statements (exceeds 4 allowed). Open
func (db *DB) writeJournal(batches []*Batch, seq uint64, sync bool) error {
wr, err := db.journal.Next()
if err != nil {
return err
}
Method version.pickMemdbLevel
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (v *version) pickMemdbLevel(umin, umax []byte, maxLevel int) (level int) {
if maxLevel > 0 {
if len(v.levels) == 0 {
return maxLevel
}
- 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 Reader.OffsetOf
has 5 return statements (exceeds 4 allowed). Open
func (r *Reader) OffsetOf(key []byte) (offset int64, err error) {
r.mu.RLock()
defer r.mu.RUnlock()
if r.err != nil {
Method Cache.Close
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (r *Cache) Close() error {
r.mu.Lock()
if !r.closed {
r.closed = 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
Method dbIter.Prev
has 5 return statements (exceeds 4 allowed). Open
func (i *dbIter) Prev() bool {
if i.dir == dirSOI || i.err != nil {
return false
} else if i.dir == dirReleased {
i.err = ErrIterReleased
Method mergedIterator.Next
has 5 return statements (exceeds 4 allowed). Open
func (i *mergedIterator) Next() bool {
if i.dir == dirEOI || i.err != nil {
return false
} else if i.dir == dirReleased {
i.err = ErrIterReleased
Method blockIter.Seek
has 5 return statements (exceeds 4 allowed). Open
func (i *blockIter) Seek(key []byte) bool {
if i.err != nil {
return false
} else if i.dir == dirReleased {
i.err = ErrIterReleased