johnsonjh/jleveldb

View on GitHub

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) {
Severity: Minor
Found in leveldb/cache/cache.go - About 35 mins to fix

    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)) {
    Severity: Minor
    Found in leveldb/testutil/kvtest.go - About 35 mins to fix

      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) {
      Severity: Minor
      Found in leveldb/db.go - About 35 mins to fix

        Function newCompaction has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func newCompaction(s *session, v *version, sourceLevel int, t0 tFiles, typ int) *compaction {
        Severity: Minor
        Found in leveldb/session_compaction.go - About 35 mins to fix

          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 {
          Severity: Major
          Found in leveldb/version.go - About 35 mins to fix

            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)
            Severity: Major
            Found in leveldb/testutil/util.go - About 35 mins to fix

              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
              Severity: Major
              Found in leveldb/cache/cache.go - About 35 mins to fix

                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()
                    }
                
                
                Severity: Minor
                Found in leveldb/testutil/kvtest.go - About 35 mins to fix

                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
                    }
                Severity: Major
                Found in leveldb/db_compaction.go - About 35 mins to fix

                  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.
                  Severity: Major
                  Found in leveldb/session.go - About 35 mins to fix

                    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 {
                    Severity: Major
                    Found in leveldb/storage/mem_storage.go - About 35 mins to fix

                      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)
                      Severity: Major
                      Found in leveldb/session_util.go - About 35 mins to fix

                        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
                            }
                        Severity: Major
                        Found in leveldb/db.go - About 35 mins to fix

                          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
                              }
                          Severity: Major
                          Found in leveldb/db_write.go - About 35 mins to fix

                            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
                                    }
                            Severity: Minor
                            Found in leveldb/version.go - About 35 mins to fix

                            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 {
                            Severity: Major
                            Found in leveldb/table/reader.go - About 35 mins to fix

                              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
                              
                              
                              Severity: Minor
                              Found in leveldb/cache/cache.go - About 35 mins to fix

                              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
                              Severity: Major
                              Found in leveldb/db_iter.go - About 35 mins to fix

                                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
                                Severity: Major
                                Found in leveldb/iterator/merged_iter.go - About 35 mins to fix

                                  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
                                  Severity: Major
                                  Found in leveldb/table/reader.go - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language