johnsonjh/jleveldb

View on GitHub
leveldb/testutil/storage.go

Summary

Maintainability
D
2 days
Test Coverage

File storage.go has 625 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// Copyright © 2014, Suryandaru Triandana <syndtr@gmail.com>
// Copyright © 2021, Jeffrey H. Johnson <trnsz@pobox.com>
//
// All rights reserved.
//
Severity: Minor
Found in leveldb/testutil/storage.go - About 5 hrs to fix

    Storage has 32 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type Storage struct {
        storage.Storage
        path    string
        onClose func() (preserve bool, err error)
        onLog   func(str string)
    Severity: Minor
    Found in leveldb/testutil/storage.go - About 4 hrs to fix

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

      func (s *Storage) Create(fd storage.FileDesc) (w storage.Writer, err error) {
          err = s.emulateError(ModeCreate, fd.Type)
          if err == nil {
              s.stall(ModeCreate, fd.Type)
          }
      Severity: Major
      Found in leveldb/testutil/storage.go and 1 other location - About 2 hrs to fix
      leveldb/testutil/storage.go on lines 411..431

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

      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) Open(fd storage.FileDesc) (r storage.Reader, err error) {
          err = s.emulateError(ModeOpen, fd.Type)
          if err == nil {
              s.stall(ModeOpen, fd.Type)
          }
      Severity: Major
      Found in leveldb/testutil/storage.go and 1 other location - About 2 hrs to fix
      leveldb/testutil/storage.go on lines 433..453

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

      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 (r *reader) Read(p []byte) (n int, err error) {
          err = r.s.emulateError(ModeRead, r.fd.Type)
          if err == nil {
              r.s.stall(ModeRead, r.fd.Type)
              n, err = r.Reader.Read(p)
      Severity: Major
      Found in leveldb/testutil/storage.go and 1 other location - About 2 hrs to fix
      leveldb/testutil/storage.go on lines 218..229

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

      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 (w *writer) Write(p []byte) (n int, err error) {
          err = w.s.emulateError(ModeWrite, w.fd.Type)
          if err == nil {
              w.s.stall(ModeWrite, w.fd.Type)
              n, err = w.Writer.Write(p)
      Severity: Major
      Found in leveldb/testutil/storage.go and 1 other location - About 2 hrs to fix
      leveldb/testutil/storage.go on lines 182..193

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

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

      There are no issues that match your filters.

      Category
      Status