cmd/eksterd/memory.go
File memory.go
has 743 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
package main
import (
"bufio"
"bytes"
- Create a ticketCreate a ticket
Method memoryBackend.channelAddItemWithMatcher
has a Cognitive Complexity of 57 (exceeds 20 allowed). Consider refactoring. Open
Open
func (b *memoryBackend) channelAddItemWithMatcher(channel string, item microsub.Item) error {
// an item is posted
// check for all channels as channel
// if regex matches item
// - add item to channel
- Read upRead up
- Create a ticketCreate a ticket
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
memoryBackend
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type memoryBackend struct {
hubIncomingBackend
lock sync.RWMutex
Channels map[string]microsub.Channel
- Create a ticketCreate a ticket
Method memoryBackend.channelAddItemWithMatcher
has 78 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (b *memoryBackend) channelAddItemWithMatcher(channel string, item microsub.Item) error {
// an item is posted
// check for all channels as channel
// if regex matches item
// - add item to channel
- Create a ticketCreate a ticket
Method memoryBackend.Search
has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring. Open
Open
func (b *memoryBackend) Search(query string) ([]microsub.Feed, error) {
urls := getPossibleURLs(query)
// needs to be like this, because we get a null result otherwise in the json output
feeds := []microsub.Feed{}
- Read upRead up
- Create a ticketCreate a ticket
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 memoryBackend.Search
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (b *memoryBackend) Search(query string) ([]microsub.Feed, error) {
urls := getPossibleURLs(query)
// needs to be like this, because we get a null result otherwise in the json output
feeds := []microsub.Feed{}
- Create a ticketCreate a ticket
Method memoryBackend.channelAddItemWithMatcher
has 10 return statements (exceeds 4 allowed). Open
Open
func (b *memoryBackend) channelAddItemWithMatcher(channel string, item microsub.Item) error {
// an item is posted
// check for all channels as channel
// if regex matches item
// - add item to channel
- Create a ticketCreate a ticket
FIXME found Open
Open
TokenEndpoint string // FIXME: should be removed
- Create a ticketCreate a ticket
- Exclude checks
TODO found Open
Open
// TODO: Only include the feed if it contains some items
- Create a ticketCreate a ticket
- Exclude checks
TODO found Open
Open
// TODO: Combine FeedHeader and FeedItems so we can use it here
- Create a ticketCreate a ticket
- Exclude checks
FIXME found Open
Open
// FIXME: don't defer in for loop (possible memory leak)
- Create a ticketCreate a ticket
- Exclude checks