File db_compaction.go
has 750 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.
//
Method DB.tCompaction
has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring. Open
func (db *DB) tCompaction() {
var (
x cCmd
waitQ []cCmd
)
- Read upRead up
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.compactionTransact
has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring. Open
func (db *DB) compactionTransact(name string, t compactionTransactInterface) {
defer func() {
if x := recover(); x != nil {
if x == errCompactionTransactExiting {
if err := t.revert(); err != nil {
- Read upRead up
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 tableCompactionBuilder.run
has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring. Open
func (b *tableCompactionBuilder) run(cnt *compactionTransactCounter) (err error) {
snapResumed := b.snapIter > 0
hasLastUkey := b.snapHasLastUkey // The key might has zero length, so this is necessary.
lastUkey := append([]byte{}, b.snapLastUkey...)
lastSeq := b.snapLastSeq
- Read upRead up
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.compactionError
has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring. Open
func (db *DB) compactionError() {
var err error
noerr:
// No error.
for {
- Read upRead up
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.compactionTransact
has 80 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (db *DB) compactionTransact(name string, t compactionTransactInterface) {
defer func() {
if x := recover(); x != nil {
if x == errCompactionTransactExiting {
if err := t.revert(); err != nil {
Method DB.tCompaction
has 77 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (db *DB) tCompaction() {
var (
x cCmd
waitQ []cCmd
)
Method tableCompactionBuilder.run
has 74 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (b *tableCompactionBuilder) run(cnt *compactionTransactCounter) (err error) {
snapResumed := b.snapIter > 0
hasLastUkey := b.snapHasLastUkey // The key might has zero length, so this is necessary.
lastUkey := append([]byte{}, b.snapLastUkey...)
lastSeq := b.snapLastSeq
Method DB.memCompaction
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (db *DB) memCompaction() {
mdb := db.getFrozenMem()
if mdb == nil {
return
}
Method DB.tableRangeCompaction
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (db *DB) tableRangeCompaction(level int, umin, umax []byte) error {
db.logf("table@compaction range L%d %q:%q", level, umin, umax)
if level >= 0 {
if c := db.s.getCompactionRange(level, umin, umax, true); c != nil {
db.tableCompaction(c, true)
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if err := b.flush(b.stash(hasLastUkey, lastUkey, lastSeq, i)); err != nil {
return err
}
Avoid deeply nested control flow statements. Open
if db.resumeWrite() {
x.ack(nil)
} else {
waitQ = append(waitQ, x)
}
Method tableCompactionBuilder.run
has 6 return statements (exceeds 4 allowed). Open
func (b *tableCompactionBuilder) run(cnt *compactionTransactCounter) (err error) {
snapResumed := b.snapIter > 0
hasLastUkey := b.snapHasLastUkey // The key might has zero length, so this is necessary.
lastUkey := append([]byte{}, b.snapLastUkey...)
lastSeq := b.snapLastSeq
Method DB.memCompaction
has 5 return statements (exceeds 4 allowed). Open
func (db *DB) memCompaction() {
mdb := db.getFrozenMem()
if mdb == nil {
return
}