johnsonjh/jleveldb

View on GitHub
leveldb/version.go

Summary

Maintainability
D
2 days
Test Coverage

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

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 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 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 versionStaging.finish has 73 lines of code (exceeds 50 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 1 hr to fix

      Method version.get has 8 return statements (exceeds 4 allowed).
      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 50 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

                          } 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

            Method version.walkOverlapping has 5 return statements (exceeds 4 allowed).
            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: Major
            Found in leveldb/version.go - About 35 mins to fix

              Method version.pickMemdbLevel has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
              Open

              func (v *version) pickMemdbLevel(umin, umax []byte, maxLevel int) (level int) {
                  if maxLevel > 0 {
                      if len(v.levels) == 0 {
                          return maxLevel
                      }
              Severity: Minor
              Found in leveldb/version.go - About 35 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

              There are no issues that match your filters.

              Category
              Status