pstuifzand/ekster

View on GitHub

Showing 86 of 159 total issues

Method mainHandler.ServeHTTP has a Cognitive Complexity of 159 (exceeds 20 allowed). Consider refactoring.
Open

func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
    conn := h.pool.Get()
    defer conn.Close()

    err := r.ParseForm()
Severity: Minor
Found in cmd/eksterd/http.go - About 2 days 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 microsubHandler.ServeHTTP has a Cognitive Complexity of 109 (exceeds 20 allowed). Consider refactoring.
Open

func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
    r.ParseForm()

    // log.Printf("Incoming request: %s %s\n", r.Method, r.URL)
    // log.Println(r.URL.Query())
Severity: Minor
Found in pkg/server/microsub.go - About 1 day 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 mainHandler.ServeHTTP has 350 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
    conn := h.pool.Get()
    defer conn.Close()

    err := r.ParseForm()
Severity: Major
Found in cmd/eksterd/http.go - About 1 day to fix

Function performCommands has a Cognitive Complexity of 89 (exceeds 20 allowed). Consider refactoring.
Open

func performCommands(sub microsub.Microsub, commands []string) {
    if len(commands) == 0 {
        flag.Usage()
        return
    }
Severity: Minor
Found in cmd/ek/main.go - About 1 day 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

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 microsubHandler.ServeHTTP has 192 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
    r.ParseForm()

    // log.Printf("Incoming request: %s %s\n", r.Method, r.URL)
    // log.Println(r.URL.Query())
Severity: Major
Found in pkg/server/microsub.go - About 6 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

Function simplifyToItem has a Cognitive Complexity of 57 (exceeds 20 allowed). Consider refactoring.
Open

func simplifyToItem(itemType string, item map[string][]interface{}, author microsub.Card) microsub.Item {
    var feedItem microsub.Item

    if itemType == "cite" {
        itemType = "entry"
Severity: Minor
Found in pkg/jf2/simplify.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

File http.go has 639 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package main

import (
    "embed"
    "encoding/json"
Severity: Minor
Found in cmd/eksterd/http.go - About 5 hrs to fix

Function performCommands has 153 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func performCommands(sub microsub.Microsub, commands []string) {
    if len(commands) == 0 {
        flag.Usage()
        return
    }
Severity: Major
Found in cmd/ek/main.go - About 5 hrs to fix

Function convertItemProps has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
Open

func convertItemProps(item interface{}, props map[string][]interface{}) {
    sv := reflect.ValueOf(item).Elem()
    st := reflect.TypeOf(item).Elem()

    for i := 0; i < st.NumField(); i++ {
Severity: Minor
Found in pkg/jf2/reflect.go - About 4 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

Function FeedItems has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
Open

func FeedItems(fetcher FetcherFunc, fetchURL, contentType string, body io.Reader) ([]microsub.Item, error) {
    log.Printf("ProcessContent %s\n", fetchURL)
    log.Println("Found " + contentType)

    items := []microsub.Item{}
Severity: Minor
Found in pkg/fetch/fetch.go - About 4 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 mainHandler.ServeHTTP has 40 return statements (exceeds 4 allowed).
Open

func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
    conn := h.pool.Get()
    defer conn.Close()

    err := r.ParseForm()
Severity: Major
Found in cmd/eksterd/http.go - About 3 hrs to fix

Function FeedItems has 102 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func FeedItems(fetcher FetcherFunc, fetchURL, contentType string, body io.Reader) ([]microsub.Item, error) {
    log.Printf("ProcessContent %s\n", fetchURL)
    log.Println("Found " + contentType)

    items := []microsub.Item{}
Severity: Major
Found in pkg/fetch/fetch.go - About 3 hrs to fix

File main.go has 526 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// Ek is a microsub client.
package main

import (
    "encoding/json"
Severity: Minor
Found in cmd/ek/main.go - About 2 hrs to fix

Function Authorize has 88 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func Authorize(me *url.URL, endpoints Endpoints, clientID, scope string) (TokenResponse, error) {
    var tokenResponse TokenResponse

    authURL, err := url.Parse(endpoints.AuthorizationEndpoint)
    if err != nil {
Severity: Major
Found in pkg/indieauth/auth.go - About 2 hrs to fix

Function importOPMLIntoMicrosub has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
Open

func importOPMLIntoMicrosub(sub microsub.Microsub, filename string) {
    channelMap := make(map[string]microsub.Channel)
    channels, err := sub.ChannelsGetList()
    if err != nil {
        log.Fatalf("an error occurred: %s\n", err)
Severity: Minor
Found in cmd/ek/main.go - About 2 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 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 hubIncomingBackend.run has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
Open

func (h *hubIncomingBackend) run() error {
    ticker := time.NewTicker(10 * time.Minute)
    quit := make(chan struct{})

    go func() {
Severity: Minor
Found in cmd/eksterd/hubbackend.go - About 2 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

Severity
Category
Status
Source
Language