johnsonjh/jleveldb

View on GitHub
leveldb/session_util.go

Summary

Maintainability
D
2 days
Test Coverage

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

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 session.newManifest has 56 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (s *session) newManifest(rec *sessionRecord, v *version) (err error) {
        fd := storage.FileDesc{Type: storage.TypeManifest, Num: s.allocFileNum()}
        writer, err := s.stor.Create(fd)
        if err != nil {
            return
    Severity: Minor
    Found in leveldb/session_util.go - About 1 hr to fix

      Method session.flushManifest has 6 return statements (exceeds 4 allowed).
      Open

      func (s *session) flushManifest(rec *sessionRecord) (err error) {
          if !s.o.GetNoSync() {
              err = s.manifestWriter.Sync()
              if err != nil {
                  return
      Severity: Major
      Found in leveldb/session_util.go - About 40 mins to fix

        Method session.newManifest has 6 return statements (exceeds 4 allowed).
        Open

        func (s *session) newManifest(rec *sessionRecord, v *version) (err error) {
            fd := storage.FileDesc{Type: storage.TypeManifest, Num: s.allocFileNum()}
            writer, err := s.stor.Create(fd)
            if err != nil {
                return
        Severity: Major
        Found in leveldb/session_util.go - About 40 mins to fix

          Method session.refLoop has 5 return statements (exceeds 4 allowed).
          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 35 mins to fix

            Method session.newManifest has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
            Open

            func (s *session) newManifest(rec *sessionRecord, v *version) (err error) {
                fd := storage.FileDesc{Type: storage.TypeManifest, Num: s.allocFileNum()}
                writer, err := s.stor.Create(fd)
                if err != nil {
                    return
            Severity: Minor
            Found in leveldb/session_util.go - About 25 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