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()
- 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 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())
- 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 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()
- Create a ticketCreate a ticket
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
}
- 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
File memory.go
has 743 lines of code (exceeds 500 allowed). Consider refactoring. Open
package main
import (
"bufio"
"bytes"
- Create a ticketCreate a ticket
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())
- Create a ticketCreate a ticket
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"
- 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.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
- 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
File http.go
has 639 lines of code (exceeds 500 allowed). Consider refactoring. Open
package main
import (
"embed"
"encoding/json"
- Create a ticketCreate a ticket
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
}
- Create a ticketCreate a ticket
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++ {
- 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
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{}
- 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
type memoryBackend struct {
hubIncomingBackend
lock sync.RWMutex
Channels map[string]microsub.Channel
- Create a ticketCreate a ticket
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()
- Create a ticketCreate a ticket
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{}
- Create a ticketCreate a ticket
File main.go
has 526 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Ek is a microsub client.
package main
import (
"encoding/json"
- Create a ticketCreate a ticket
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 {
- Create a ticketCreate a ticket
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)
- 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.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
- Create a ticketCreate a ticket
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() {
- 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"