johnsonjh/jleveldb

View on GitHub

Showing 142 of 166 total issues

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

    Method DB.get has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func (db *DB) get(auxm *memdb.DB, auxt tFiles, key []byte, seq uint64, ro *opt.ReadOptions) (value []byte, 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 DB.newIterator has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func (db *DB) newIterator(auxm *memDB, auxt tFiles, seq uint64, slice *util.Range, ro *opt.ReadOptions) *dbIter {
        Severity: Minor
        Found in leveldb/db_iter.go - About 35 mins to fix

          Function decodeBatch has 5 return statements (exceeds 4 allowed).
          Open

          func decodeBatch(data []byte, fn func(i int, index batchIndex) error) error {
              var index batchIndex
              for i, o := 0, 0; o < len(data); i++ {
                  // Key type.
                  index.keyType = keyType(data[o])
          Severity: Major
          Found in leveldb/batch.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

              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 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 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 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 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

                          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

                            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 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 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 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 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 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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language