johnsonjh/jleveldb

View on GitHub
leveldb/db_compaction.go

Summary

Maintainability
F
4 days
Test Coverage

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

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

    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

    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

      Method DB.tCompaction has 77 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (db *DB) tCompaction() {
          var (
              x     cCmd
              waitQ []cCmd
          )
      Severity: Major
      Found in leveldb/db_compaction.go - About 2 hrs to fix

        Method tableCompactionBuilder.run has 74 lines of code (exceeds 50 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 1 hr to fix

          Method DB.memCompaction has 60 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (db *DB) memCompaction() {
              mdb := db.getFrozenMem()
              if mdb == nil {
                  return
              }
          Severity: Minor
          Found in leveldb/db_compaction.go - About 1 hr 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 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

              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

                Method tableCompactionBuilder.run has 6 return statements (exceeds 4 allowed).
                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: Major
                Found in leveldb/db_compaction.go - About 40 mins to fix

                  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

                    There are no issues that match your filters.

                    Category
                    Status