rueian/rueidis

View on GitHub
lru.go

Summary

Maintainability
C
1 day
Test Coverage
A
100%

Method lru.Flights has a Cognitive Complexity of 50 (exceeds 20 allowed). Consider refactoring.
Open

func (c *lru) Flights(now time.Time, multi []CacheableTTL, results []RedisResult, entries map[int]CacheEntry) (missed []int) {
    var moves []*list.Element

    c.mu.RLock()
    for i, ct := range multi {
Severity: Minor
Found in lru.go - About 5 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 lru.Flights has 82 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *lru) Flights(now time.Time, multi []CacheableTTL, results []RedisResult, entries map[int]CacheEntry) (missed []int) {
    var moves []*list.Element

    c.mu.RLock()
    for i, ct := range multi {
Severity: Major
Found in lru.go - About 2 hrs to fix

    Method lru.Flight has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
    Open

    func (c *lru) Flight(key, cmd string, ttl time.Duration, now time.Time) (v RedisMessage, ce CacheEntry) {
        var ok bool
        var kc *keyCache
        var ele, back *list.Element
        var e *cacheEntry
    Severity: Minor
    Found in lru.go - About 1 hr 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 lru.Update has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
    Open

    func (c *lru) Update(key, cmd string, value RedisMessage) (pxat int64) {
        var ch chan struct{}
        c.mu.Lock()
        if kc, ok := c.store[key]; ok {
            if ele := kc.cache[cmd]; ele != nil {
    Severity: Minor
    Found in lru.go - About 1 hr 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 lru.Flight has 52 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (c *lru) Flight(key, cmd string, ttl time.Duration, now time.Time) (v RedisMessage, ce CacheEntry) {
        var ok bool
        var kc *keyCache
        var ele, back *list.Element
        var e *cacheEntry
    Severity: Minor
    Found in lru.go - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                          goto miss1
      Severity: Major
      Found in lru.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if delete(kc.cache, e.cmd); len(kc.cache) == 0 {
                                delete(c.store, kc.key)
                            }
        Severity: Major
        Found in lru.go - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status