rueian/rueidis

View on GitHub
internal/cmds/gen_transactions.go

Summary

Maintainability
A
2 hrs
Test Coverage
A
100%

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

func (c Watch) Key(key ...string) WatchKey {
    if c.ks&NoSlot == NoSlot {
        for _, k := range key {
            c.ks = NoSlot | slot(k)
            break
Severity: Major
Found in internal/cmds/gen_transactions.go and 45 other locations - About 1 hr to fix
internal/cmds/gen_bitmap.go on lines 378..391
internal/cmds/gen_cms.go on lines 186..199
internal/cmds/gen_generic.go on lines 81..94
internal/cmds/gen_generic.go on lines 151..164
internal/cmds/gen_generic.go on lines 1755..1768
internal/cmds/gen_generic.go on lines 1860..1873
internal/cmds/gen_hyperloglog.go on lines 55..68
internal/cmds/gen_hyperloglog.go on lines 112..125
internal/cmds/gen_json.go on lines 668..681
internal/cmds/gen_list.go on lines 143..156
internal/cmds/gen_list.go on lines 197..210
internal/cmds/gen_list.go on lines 249..262
internal/cmds/gen_list.go on lines 591..604
internal/cmds/gen_pubsub.go on lines 263..276
internal/cmds/gen_pubsub.go on lines 333..346
internal/cmds/gen_scripting.go on lines 61..74
internal/cmds/gen_scripting.go on lines 150..163
internal/cmds/gen_scripting.go on lines 248..261
internal/cmds/gen_scripting.go on lines 337..350
internal/cmds/gen_scripting.go on lines 442..455
internal/cmds/gen_scripting.go on lines 538..551
internal/cmds/gen_set.go on lines 82..95
internal/cmds/gen_set.go on lines 139..152
internal/cmds/gen_set.go on lines 184..197
internal/cmds/gen_set.go on lines 270..283
internal/cmds/gen_set.go on lines 305..318
internal/cmds/gen_set.go on lines 675..688
internal/cmds/gen_set.go on lines 732..745
internal/cmds/gen_sorted_set.go on lines 56..69
internal/cmds/gen_sorted_set.go on lines 110..123
internal/cmds/gen_sorted_set.go on lines 162..175
internal/cmds/gen_sorted_set.go on lines 489..502
internal/cmds/gen_sorted_set.go on lines 560..573
internal/cmds/gen_sorted_set.go on lines 715..728
internal/cmds/gen_sorted_set.go on lines 821..834
internal/cmds/gen_sorted_set.go on lines 929..942
internal/cmds/gen_sorted_set.go on lines 1067..1080
internal/cmds/gen_sorted_set.go on lines 2379..2392
internal/cmds/gen_sorted_set.go on lines 2529..2542
internal/cmds/gen_stream.go on lines 1116..1129
internal/cmds/gen_stream.go on lines 1240..1253
internal/cmds/gen_string.go on lines 575..588
internal/cmds/gen_tdigest.go on lines 293..306
internal/cmds/gen_triggers_and_functions.go on lines 68..81
internal/cmds/gen_triggers_and_functions.go on lines 154..167

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

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 46 locations. Consider refactoring.
Open

func (c WatchKey) Key(key ...string) WatchKey {
    if c.ks&NoSlot == NoSlot {
        for _, k := range key {
            c.ks = NoSlot | slot(k)
            break
Severity: Major
Found in internal/cmds/gen_transactions.go and 45 other locations - About 1 hr to fix
internal/cmds/gen_bitmap.go on lines 395..408
internal/cmds/gen_cms.go on lines 203..216
internal/cmds/gen_generic.go on lines 98..111
internal/cmds/gen_generic.go on lines 168..181
internal/cmds/gen_generic.go on lines 1772..1785
internal/cmds/gen_generic.go on lines 1877..1890
internal/cmds/gen_hyperloglog.go on lines 72..85
internal/cmds/gen_hyperloglog.go on lines 134..147
internal/cmds/gen_json.go on lines 685..698
internal/cmds/gen_list.go on lines 116..129
internal/cmds/gen_list.go on lines 214..227
internal/cmds/gen_list.go on lines 266..279
internal/cmds/gen_list.go on lines 564..577
internal/cmds/gen_pubsub.go on lines 280..293
internal/cmds/gen_pubsub.go on lines 355..368
internal/cmds/gen_scripting.go on lines 34..47
internal/cmds/gen_scripting.go on lines 118..131
internal/cmds/gen_scripting.go on lines 221..234
internal/cmds/gen_scripting.go on lines 305..318
internal/cmds/gen_scripting.go on lines 415..428
internal/cmds/gen_scripting.go on lines 506..519
internal/cmds/gen_set.go on lines 99..112
internal/cmds/gen_set.go on lines 156..169
internal/cmds/gen_set.go on lines 201..214
internal/cmds/gen_set.go on lines 236..249
internal/cmds/gen_set.go on lines 322..335
internal/cmds/gen_set.go on lines 692..705
internal/cmds/gen_set.go on lines 749..762
internal/cmds/gen_sorted_set.go on lines 29..42
internal/cmds/gen_sorted_set.go on lines 127..140
internal/cmds/gen_sorted_set.go on lines 179..192
internal/cmds/gen_sorted_set.go on lines 462..475
internal/cmds/gen_sorted_set.go on lines 538..551
internal/cmds/gen_sorted_set.go on lines 665..678
internal/cmds/gen_sorted_set.go on lines 787..800
internal/cmds/gen_sorted_set.go on lines 884..897
internal/cmds/gen_sorted_set.go on lines 1040..1053
internal/cmds/gen_sorted_set.go on lines 2329..2342
internal/cmds/gen_sorted_set.go on lines 2484..2497
internal/cmds/gen_stream.go on lines 1094..1107
internal/cmds/gen_stream.go on lines 1211..1224
internal/cmds/gen_string.go on lines 592..605
internal/cmds/gen_tdigest.go on lines 317..330
internal/cmds/gen_triggers_and_functions.go on lines 34..47
internal/cmds/gen_triggers_and_functions.go on lines 120..133

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

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