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 {
- 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 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 {
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
- 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 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 {
- 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 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
Avoid deeply nested control flow statements. Open
goto miss1
Avoid deeply nested control flow statements. Open
if delete(kc.cache, e.cmd); len(kc.cache) == 0 {
delete(c.store, kc.key)
}