johnsonjh/jleveldb

View on GitHub

Showing 142 of 166 total issues

Avoid deeply nested control flow statements.
Open

                    if !del && i.icmp.uCompare(ukey, i.key) < 0 {
                        return true
                    }
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

      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

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

            Method Writer.Close has 7 return statements (exceeds 4 allowed).
            Open

            func (w *Writer) Close() error {
                if w.err != nil {
                    return w.err
                }
            
            
            Severity: Major
            Found in leveldb/table/writer.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

                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

                                      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 setFunc == nil {
                                            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 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

                                            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.flush has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                          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()
                              // 请问您知道这里为什么要用匿名函数吗,我理解的是直接用循环就可以
                          Severity: Minor
                          Found in leveldb/db_write.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

                          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

                                                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

                                              } 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

                                  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

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