johnsonjh/jleveldb

View on GitHub
leveldb/db.go

Summary

Maintainability
F
6 days
Test Coverage

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

    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

    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

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

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

            Function recoverTable has 18 return statements (exceeds 4 allowed).
            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 1 hr to fix

              Method DB.recoverJournal has 12 return statements (exceeds 4 allowed).
              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 1 hr to fix

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

                  Method DB.has has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func (db *DB) has(auxm *memdb.DB, auxt tFiles, key []byte, seq uint64, ro *opt.ReadOptions) (ret bool, err error) {
                  Severity: Minor
                  Found in leveldb/db.go - About 35 mins to fix

                    Method DB.get has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    func (db *DB) get(auxm *memdb.DB, auxt tFiles, key []byte, seq uint64, ro *opt.ReadOptions) (value []byte, err error) {
                    Severity: Minor
                    Found in leveldb/db.go - About 35 mins to fix

                      Function Open has 5 return statements (exceeds 4 allowed).
                      Open

                      func Open(stor storage.Storage, o *opt.Options) (db *DB, err error) {
                          s, err := newSession(stor, o)
                          if err != nil {
                              return
                          }
                      Severity: Major
                      Found in leveldb/db.go - About 35 mins to fix

                        There are no issues that match your filters.

                        Category
                        Status