pstuifzand/ekster

View on GitHub
cmd/eksterd/memory.go

Summary

Maintainability
D
3 days
Test Coverage

File memory.go has 743 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package main

import (
    "bufio"
    "bytes"
Severity: Minor
Found in cmd/eksterd/memory.go - About 7 hrs to fix

Method memoryBackend.channelAddItemWithMatcher has a Cognitive Complexity of 57 (exceeds 20 allowed). Consider refactoring.
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
Severity: Minor
Found in cmd/eksterd/memory.go - About 6 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

memoryBackend has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

type memoryBackend struct {
    hubIncomingBackend

    lock     sync.RWMutex
    Channels map[string]microsub.Channel
Severity: Minor
Found in cmd/eksterd/memory.go - About 3 hrs to fix

Method memoryBackend.channelAddItemWithMatcher has 78 lines of code (exceeds 50 allowed). Consider refactoring.
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
Severity: Major
Found in cmd/eksterd/memory.go - About 2 hrs to fix

Method memoryBackend.Search has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
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{}
Severity: Minor
Found in cmd/eksterd/memory.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 memoryBackend.Search has 51 lines of code (exceeds 50 allowed). Consider refactoring.
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{}
Severity: Minor
Found in cmd/eksterd/memory.go - About 1 hr to fix

Method memoryBackend.channelAddItemWithMatcher has 10 return statements (exceeds 4 allowed).
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
Severity: Major
Found in cmd/eksterd/memory.go - About 1 hr to fix

FIXME found
Open

    TokenEndpoint string // FIXME: should be removed
Severity: Minor
Found in cmd/eksterd/memory.go by fixme

TODO found
Open

        // TODO: Only include the feed if it contains some items
Severity: Minor
Found in cmd/eksterd/memory.go by fixme

FIXME found
Open

    Me            string // FIXME: should be removed
Severity: Minor
Found in cmd/eksterd/memory.go by fixme

TODO found
Open

        // TODO: Combine FeedHeader and FeedItems so we can use it here
Severity: Minor
Found in cmd/eksterd/memory.go by fixme

FIXME found
Open

                    // FIXME: don't defer in for loop (possible memory leak)
Severity: Minor
Found in cmd/eksterd/memory.go by fixme

FIXME found
Open

    // FIXME: can't be used in Backend
Severity: Minor
Found in cmd/eksterd/memory.go by fixme

There are no issues that match your filters.

Category
Status