johnsonjh/jleveldb

View on GitHub

Showing 166 of 166 total issues

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

    Function newCompaction has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func newCompaction(s *session, v *version, sourceLevel int, t0 tFiles, typ int) *compaction {
    Severity: Minor
    Found in leveldb/session_compaction.go - About 35 mins to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (s *Storage) EmulateErrorOnce(m StorageMode, t storage.FileType, err error) {
          s.mu.Lock()
          defer s.mu.Unlock()
          for _, x := range listFlattenType(m, t) {
              s.emulatedError[x] = err
      Severity: Minor
      Found in leveldb/testutil/storage.go and 1 other location - About 35 mins to fix
      leveldb/testutil/storage.go on lines 610..617

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 107.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (s *Storage) EmulateError(m StorageMode, t storage.FileType, err error) {
          s.mu.Lock()
          defer s.mu.Unlock()
          for _, x := range listFlattenType(m, t) {
              s.emulatedError[x] = err
      Severity: Minor
      Found in leveldb/testutil/storage.go and 1 other location - About 35 mins to fix
      leveldb/testutil/storage.go on lines 619..626

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 107.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

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

        func BytesSeparator(a, b []byte) []byte {
            if bytes.Equal(a, b) {
                return b
            }
            i, n := 0, len(a)
        Severity: Major
        Found in leveldb/testutil/util.go - About 35 mins to fix

          Method Cache.Get has 5 return statements (exceeds 4 allowed).
          Open

          func (r *Cache) Get(ns, key uint64, setFunc func() (size int, value Value)) *Handle {
              r.mu.RLock()
              defer r.mu.RUnlock()
              if r.closed {
                  return nil
          Severity: Major
          Found in leveldb/cache/cache.go - About 35 mins to fix

            Function KeyValueTesting has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
            Open

            func KeyValueTesting(rnd *rand.Rand, kv KeyValue, p DB, setup func(KeyValue) DB, teardown func(DB)) {
                if rnd == nil {
                    rnd = NewRand()
                }
            
            
            Severity: Minor
            Found in leveldb/testutil/kvtest.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

            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

              Method session.recover has 5 return statements (exceeds 4 allowed).
              Open

              func (s *session) recover() (err error) {
                  defer func() {
                      if os.IsNotExist(err) {
                          // Don't return os.ErrNotExist if the underlying storage contains
                          // other files that belong to LevelDB. So the DB won't get trashed.
              Severity: Major
              Found in leveldb/session.go - About 35 mins to fix

                Method memStorage.Rename has 5 return statements (exceeds 4 allowed).
                Open

                func (ms *memStorage) Rename(oldfd, newfd FileDesc) error {
                    if !FileDescOk(oldfd) || !FileDescOk(newfd) {
                        return ErrInvalidFile
                    }
                    if oldfd == newfd {
                Severity: Major
                Found in leveldb/storage/mem_storage.go - About 35 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

                    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

                      Method DB.writeJournal has 5 return statements (exceeds 4 allowed).
                      Open

                      func (db *DB) writeJournal(batches []*Batch, seq uint64, sync bool) error {
                          wr, err := db.journal.Next()
                          if err != nil {
                              return err
                          }
                      Severity: Major
                      Found in leveldb/db_write.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

                        Method Reader.OffsetOf has 5 return statements (exceeds 4 allowed).
                        Open

                        func (r *Reader) OffsetOf(key []byte) (offset int64, err error) {
                            r.mu.RLock()
                            defer r.mu.RUnlock()
                        
                            if r.err != nil {
                        Severity: Major
                        Found in leveldb/table/reader.go - About 35 mins to fix

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

                          func (r *Cache) Close() error {
                              r.mu.Lock()
                              if !r.closed {
                                  r.closed = true
                          
                          
                          Severity: Minor
                          Found in leveldb/cache/cache.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

                          Method dbIter.Prev has 5 return statements (exceeds 4 allowed).
                          Open

                          func (i *dbIter) Prev() bool {
                              if i.dir == dirSOI || i.err != nil {
                                  return false
                              } else if i.dir == dirReleased {
                                  i.err = ErrIterReleased
                          Severity: Major
                          Found in leveldb/db_iter.go - About 35 mins to fix

                            Method mergedIterator.Next has 5 return statements (exceeds 4 allowed).
                            Open

                            func (i *mergedIterator) Next() bool {
                                if i.dir == dirEOI || i.err != nil {
                                    return false
                                } else if i.dir == dirReleased {
                                    i.err = ErrIterReleased
                            Severity: Major
                            Found in leveldb/iterator/merged_iter.go - About 35 mins to fix

                              Method blockIter.Seek has 5 return statements (exceeds 4 allowed).
                              Open

                              func (i *blockIter) Seek(key []byte) bool {
                                  if i.err != nil {
                                      return false
                                  } else if i.dir == dirReleased {
                                      i.err = ErrIterReleased
                              Severity: Major
                              Found in leveldb/table/reader.go - About 35 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language