johnsonjh/jleveldb

View on GitHub

Showing 142 of 166 total issues

Avoid deeply nested control flow statements.
Open

                    if atomic.AddUint32(sizeHalfPtr, 1) == 20 {
                        atomic.StoreUint32(sizePtr, uint32(cap(b)/2))
                        atomic.StoreUint32(sizeHalfPtr, 0)
                    } else {
                        select {
Severity: Major
Found in leveldb/util/buffer_pool.go - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if n.value == nil {
                            n.size = 0
                            n.mu.Unlock()
                            n.unref()
                            return nil
    Severity: Major
    Found in leveldb/cache/cache.go - About 45 mins to fix

      Avoid deeply nested control flow statements.
      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
      Severity: Major
      Found in leveldb/db_iter.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if ourBatch == nil {
                                ourBatch = db.batchPool.Get().(*Batch)
                                ourBatch.Reset()
                                batches = append(batches, ourBatch)
                            }
        Severity: Major
        Found in leveldb/db_write.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if err := b.flush(b.stash(hasLastUkey, lastUkey, lastSeq, i)); err != nil {
                                  return err
                              }
          Severity: Major
          Found in leveldb/db_compaction.go - About 45 mins to fix

            Method DB.CompactRange has 7 return statements (exceeds 4 allowed).
            Open

            func (db *DB) CompactRange(r util.Range) error {
                if err := db.ok(); err != nil {
                    return err
                }
            
            
            Severity: Major
            Found in leveldb/db_write.go - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  goto cont
              Severity: Major
              Found in leveldb/db_iter.go - About 45 mins to fix

                Method DB.tableRangeCompaction has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                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)
                Severity: Minor
                Found in leveldb/db_compaction.go - About 45 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

                Avoid deeply nested control flow statements.
                Open

                                    if db.resumeWrite() {
                                        x.ack(nil)
                                    } else {
                                        waitQ = append(waitQ, x)
                                    }
                Severity: Major
                Found in leveldb/db_compaction.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      select {
                                      case pool <- b:
                                      default:
                                      }
                  Severity: Major
                  Found in leveldb/util/buffer_pool.go - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if overlaps.size() > int64(v.s.o.GetCompactionGPOverlaps(level)) {
                                            break
                                        }
                    Severity: Major
                    Found in leveldb/version.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if internalLen > mergeLimit {
                                              overflow = true
                                              break merge
                                          }
                      Severity: Major
                      Found in leveldb/db_write.go - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                        } else if v.levels[pLevel].overlaps(v.s.icmp, umin, umax, false) {
                                            break
                                        }
                        Severity: Major
                        Found in leveldb/version.go - About 45 mins to fix

                          Function NewReader has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          func NewReader(f io.ReaderAt, size int64, fd storage.FileDesc, cache *cache.NamespaceGetter, bpool *util.BufferPool, o *opt.Options) (*Reader, error) {
                          Severity: Minor
                          Found in leveldb/table/reader.go - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if !del {
                                                    i.key = append(i.key[:0], ukey...)
                                                    i.value = append(i.value[:0], i.iter.Value()...)
                                                }
                            Severity: Major
                            Found in leveldb/db_iter.go - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  select {
                                                  case pool <- b:
                                                  default:
                                                  }
                              Severity: Major
                              Found in leveldb/util/buffer_pool.go - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if incoming.batch.internalLen > mergeLimit {
                                                        overflow = true
                                                        break merge
                                                    }
                                Severity: Major
                                Found in leveldb/db_write.go - About 45 mins to fix

                                  Method DB.putRec has 7 return statements (exceeds 4 allowed).
                                  Open

                                  func (db *DB) putRec(kt keyType, key, value []byte, wo *opt.WriteOptions) error {
                                      if err := db.ok(); err != nil {
                                          return err
                                      }
                                  
                                  
                                  Severity: Major
                                  Found in leveldb/db_write.go - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        if setFunc == nil {
                                                            n.mu.Unlock()
                                                            n.unref()
                                                            return nil
                                                        }
                                    Severity: Major
                                    Found in leveldb/cache/cache.go - About 45 mins to fix

                                      Method indexedIterator.Prev has 7 return statements (exceeds 4 allowed).
                                      Open

                                      func (i *indexedIterator) Prev() bool {
                                          if i.err != nil {
                                              return false
                                          } else if i.Released() {
                                              i.err = ErrIterReleased
                                      Severity: Major
                                      Found in leveldb/iterator/indexed_iter.go - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language