johnsonjh/jleveldb

View on GitHub

Showing 142 of 166 total issues

Storage has 32 methods (exceeds 20 allowed). Consider refactoring.
Open

type Storage struct {
    storage.Storage
    path    string
    onClose func() (preserve bool, err error)
    onLog   func(str string)
Severity: Minor
Found in leveldb/testutil/storage.go - About 4 hrs to fix

    Method DB.writeLocked has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
    Open

    func (db *DB) writeLocked(batch, ourBatch *Batch, merge, sync bool) error {
        // Try to flush memdb. This method would also trying to throttle writes
        // if it is too fast and compaction cannot catch-up.
        mdb, mdbFree, err := db.flush(batch.internalLen)
        if err != nil {
    Severity: Minor
    Found in leveldb/db_write.go - About 3 hrs 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.get has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
    Open

    func (v *version) get(aux tFiles, ikey internalKey, ro *opt.ReadOptions, noValue bool) (value []byte, tcomp bool, err error) {
        if v.closing {
            return nil, false, ErrClosed
        }
    
    
    Severity: Minor
    Found in leveldb/version.go - About 3 hrs 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.recoverJournal has 117 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (db *DB) recoverJournal() error {
        // Get all journals and sort it by file number.
        rawFds, err := db.s.stor.List(storage.TypeJournal)
        if err != nil {
            return err
    Severity: Major
    Found in leveldb/db.go - About 3 hrs to fix

      KeyValue has 30 methods (exceeds 20 allowed). Consider refactoring.
      Open

      type KeyValue struct {
          entries []KeyValueEntry
          nbytes  int
      }
      Severity: Minor
      Found in leveldb/testutil/kv.go - About 3 hrs to fix

        File main.go has 567 lines of code (exceeds 500 allowed). Consider refactoring.
        Open

        package main
        
        import (
            crand "crypto/rand"
            "encoding/binary"
        Severity: Minor
        Found in manualtest/dbstress/main.go - About 3 hrs to fix

          Function KeyValue_Generate has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
          Open

          func KeyValue_Generate(rnd *rand.Rand, n, incr, minlen, maxlen, vminlen, vmaxlen int) *KeyValue {
              if rnd == nil {
                  rnd = NewRand()
              }
              if maxlen < minlen {
          Severity: Minor
          Found in leveldb/testutil/kv.go - About 3 hrs 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

          Function NewReader has 94 lines of code (exceeds 50 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) {
              if f == nil {
                  return nil, errors.New("leveldb/table: nil file")
              }
          
          
          Severity: Major
          Found in leveldb/table/reader.go - About 2 hrs to fix

            Method Reader.nextChunk has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
            Open

            func (r *Reader) nextChunk(first bool) error {
                for {
                    if r.j+headerSize <= r.n {
                        checksum := binary.LittleEndian.Uint32(r.buf[r.j+0 : r.j+4])
                        length := binary.LittleEndian.Uint16(r.buf[r.j+4 : r.j+6])
            Severity: Minor
            Found in leveldb/journal/journal.go - About 2 hrs 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.compactionError has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
            Open

            func (db *DB) compactionError() {
                var err error
            noerr:
                // No error.
                for {
            Severity: Minor
            Found in leveldb/db_compaction.go - About 2 hrs 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

            sessionRecord has 23 methods (exceeds 20 allowed). Consider refactoring.
            Open

            type sessionRecord struct {
                hasRec         int
                comparer       string
                journalNum     int64
                prevJournalNum int64
            Severity: Minor
            Found in leveldb/session_record.go - About 2 hrs to fix

              File cache.go has 518 lines of code (exceeds 500 allowed). Consider refactoring.
              Open

              // Copyright © 2012, Suryandaru Triandana <syndtr@gmail.com>
              // Copyright © 2021, Jeffrey H. Johnson <trnsz@pobox.com>
              //
              // All rights reserved.
              //
              Severity: Minor
              Found in leveldb/cache/cache.go - About 2 hrs to fix

                Method Reader.find has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
                Open

                func (r *Reader) find(key []byte, filtered bool, ro *opt.ReadOptions, noValue bool) (rkey, value []byte, err error) {
                    r.mu.RLock()
                    defer r.mu.RUnlock()
                
                    if r.err != nil {
                Severity: Minor
                Found in leveldb/table/reader.go - About 2 hrs 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 sessionRecord.decode has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
                Open

                func (p *sessionRecord) decode(r io.Reader) error {
                    br, ok := r.(byteReader)
                    if !ok {
                        br = bufio.NewReader(r)
                    }
                Severity: Minor
                Found in leveldb/session_record.go - About 2 hrs 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 BufferPool.Get has 85 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (p *BufferPool) Get(n int) []byte {
                    if p == nil {
                        return make([]byte, n)
                    }
                
                
                Severity: Major
                Found in leveldb/util/buffer_pool.go - About 2 hrs to fix

                  Method blockIter.Prev has 84 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (i *blockIter) Prev() bool {
                      if i.dir == dirSOI || i.err != nil {
                          return false
                      } else if i.dir == dirReleased {
                          i.err = ErrIterReleased
                  Severity: Major
                  Found in leveldb/table/reader.go - About 2 hrs to fix

                    Method version.get has 83 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (v *version) get(aux tFiles, ikey internalKey, ro *opt.ReadOptions, noValue bool) (value []byte, tcomp bool, err error) {
                        if v.closing {
                            return nil, false, ErrClosed
                        }
                    
                    
                    Severity: Major
                    Found in leveldb/version.go - About 2 hrs to fix

                      Method DB.GetProperty has 82 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (db *DB) GetProperty(name string) (value string, err error) {
                          err = db.ok()
                          if err != nil {
                              return
                          }
                      Severity: Major
                      Found in leveldb/db.go - About 2 hrs to fix

                        Method DB.compactionTransact has 80 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (db *DB) compactionTransact(name string, t compactionTransactInterface) {
                            defer func() {
                                if x := recover(); x != nil {
                                    if x == errCompactionTransactExiting {
                                        if err := t.revert(); err != nil {
                        Severity: Major
                        Found in leveldb/db_compaction.go - About 2 hrs to fix

                          IteratorTesting has 21 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          type IteratorTesting struct {
                              KeyValue
                              Iter         iterator.Iterator
                              Rand         *rand.Rand
                              PostFn       func(t *IteratorTesting)
                          Severity: Minor
                          Found in leveldb/testutil/iter.go - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language