johnsonjh/jleveldb

View on GitHub

Showing 142 of 166 total issues

Function main has a Cognitive Complexity of 194 (exceeds 20 allowed). Consider refactoring.
Open

func main() {
    flag.Parse()

    var src cryptoSource
    rnd := rand.New(src)
Severity: Minor
Found in manualtest/dbstress/main.go - About 3 days 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

File reader.go has 943 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: Major
Found in leveldb/table/reader.go - About 1 day to fix

    Method session.refLoop has a Cognitive Complexity of 93 (exceeds 20 allowed). Consider refactoring.
    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: Minor
    Found in leveldb/session_util.go - About 1 day 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

    File db.go has 870 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: Major
    Found in leveldb/db.go - About 1 day to fix

      Function recoverTable has a Cognitive Complexity of 83 (exceeds 20 allowed). Consider refactoring.
      Open

      func recoverTable(s *session, o *opt.Options) error {
          o = dupOptions(o)
          // Mask StrictReader, lets StrictRecovery doing its job.
          o.Strict &= ^opt.StrictReader
      
      
      Severity: Minor
      Found in leveldb/db.go - About 1 day 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 main has 289 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func main() {
          flag.Parse()
      
          var src cryptoSource
          rnd := rand.New(src)
      Severity: Major
      Found in manualtest/dbstress/main.go - About 1 day to fix

        Method DB.recoverJournal has a Cognitive Complexity of 81 (exceeds 20 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: Minor
        Found in leveldb/db.go - About 1 day 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

        File db_compaction.go has 750 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/db_compaction.go - About 1 day to fix

          Method BufferPool.Get has a Cognitive Complexity of 60 (exceeds 20 allowed). Consider refactoring.
          Open

          func (p *BufferPool) Get(n int) []byte {
              if p == nil {
                  return make([]byte, n)
              }
          
          
          Severity: Minor
          Found in leveldb/util/buffer_pool.go - About 6 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 versionStaging.finish has a Cognitive Complexity of 54 (exceeds 20 allowed). Consider refactoring.
          Open

          func (p *versionStaging) finish(trivial bool) *version {
              // Build new version.
              nv := newVersion(p.base.s)
              numLevel := len(p.levels)
              if len(p.base.levels) > numLevel {
          Severity: Minor
          Found in leveldb/version.go - About 5 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 recoverTable has 161 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func recoverTable(s *session, o *opt.Options) error {
              o = dupOptions(o)
              // Mask StrictReader, lets StrictRecovery doing its job.
              o.Strict &= ^opt.StrictReader
          
          
          Severity: Major
          Found in leveldb/db.go - About 5 hrs to fix

            File storage.go has 625 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

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

              Method version.walkOverlapping has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
              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: Minor
              Found in leveldb/version.go - About 4 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.recoverJournalRO has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring.
              Open

              func (db *DB) recoverJournalRO() error {
                  // Get all journals and sort it by file number.
                  rawFds, err := db.s.stor.List(storage.TypeJournal)
                  if err != nil {
                      return err
              Severity: Minor
              Found in leveldb/db.go - About 4 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 session.refLoop has 139 lines of code (exceeds 50 allowed). Consider refactoring.
              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 4 hrs to fix

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

                func (db *DB) tCompaction() {
                    var (
                        x     cCmd
                        waitQ []cCmd
                    )
                Severity: Minor
                Found in leveldb/db_compaction.go - About 4 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 a Cognitive Complexity of 44 (exceeds 20 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: Minor
                Found in leveldb/table/reader.go - About 4 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

                Options has 33 methods (exceeds 20 allowed). Consider refactoring.
                Open

                type Options struct {
                    // AltFilters defines one or more 'alternative filters'.
                    // 'alternative filters' will be used during reads if a filter block
                    // does not match with the 'effective filter'.
                    //
                Severity: Minor
                Found in leveldb/opt/options.go - About 4 hrs to fix

                  Method tableCompactionBuilder.run has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (b *tableCompactionBuilder) run(cnt *compactionTransactCounter) (err error) {
                      snapResumed := b.snapIter > 0
                      hasLastUkey := b.snapHasLastUkey // The key might has zero length, so this is necessary.
                      lastUkey := append([]byte{}, b.snapLastUkey...)
                      lastSeq := b.snapLastSeq
                  Severity: Minor
                  Found in leveldb/db_compaction.go - About 4 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

                  Severity
                  Category
                  Status
                  Source
                  Language