Showing 86 of 159 total issues
Function parseAtom
has 74 lines of code (exceeds 50 allowed). Consider refactoring. Open
func parseAtom(data []byte) (*Feed, error) {
warnings := false
feed := atomFeed{}
p := xml.NewDecoder(bytes.NewReader(data))
p.CharsetReader = charsetReader
- Create a ticketCreate a ticket
Function main
has 72 lines of code (exceeds 50 allowed). Consider refactoring. Open
func main() {
flag.Parse()
flag.Usage = func() {
fmt.Print(`Ek is a tool for managing Microsub servers.
- Create a ticketCreate a ticket
Method microsubHandler.ServeHTTP
has 20 return statements (exceeds 4 allowed). 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
Method postgresStream.Items
has 70 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *postgresStream) Items(before, after string) (microsub.Timeline, error) {
ctx := context.Background()
conn, err := p.database.Conn(ctx)
if err != nil {
return microsub.Timeline{}, err
- Create a ticketCreate a ticket
Function simplifyToItem
has 69 lines of code (exceeds 50 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"
- Create a ticketCreate a ticket
Function CleanHTML
has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring. Open
func CleanHTML(s string) (string, error) {
doc, err := html.Parse(strings.NewReader(s))
if err != nil {
return "", 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.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{}
- 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 FeedHeader
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
func FeedHeader(fetcher FetcherFunc, fetchURL, contentType string, body io.Reader) (microsub.Feed, error) {
log.Printf("ProcessContent %s\n", fetchURL)
log.Println("Found " + contentType)
feed := microsub.Feed{}
- Create a ticketCreate a ticket
Method redisSortedSetTimeline.Items
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (timeline *redisSortedSetTimeline) Items(before, after string) (microsub.Timeline, error) {
conn := timeline.pool.Get()
defer conn.Close()
items := []microsub.Item{}
- Create a ticketCreate a ticket
Function importOPMLIntoMicrosub
has 62 lines of code (exceeds 50 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)
- Create a ticketCreate a ticket
Method hubIncomingBackend.Feeds
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
func (h *hubIncomingBackend) Feeds() ([]Feed, error) {
conn := h.pool.Get()
defer conn.Close()
feeds := []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
Function main
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
func main() {
log.Println("eksterd - microsub server")
var options AppOptions
- Create a ticketCreate a ticket
Method incomingHandler.ServeHTTP
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (h *incomingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
err := r.ParseForm()
if err != nil {
- Create a ticketCreate a ticket
Method micropubHandler.ServeHTTP
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (h *micropubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer func() {
err := r.Body.Close()
if err != nil {
log.Printf("could not close request body: %v", err)
- Create a ticketCreate a ticket
Function FeedHeader
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func FeedHeader(fetcher FetcherFunc, fetchURL, contentType string, body io.Reader) (microsub.Feed, error) {
log.Printf("ProcessContent %s\n", fetchURL)
log.Println("Found " + contentType)
feed := 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
Function Authorize
has a Cognitive Complexity of 26 (exceeds 20 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 {
- 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 Authorize
has 11 return statements (exceeds 4 allowed). 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 parseBodyLinks
has 11 return statements (exceeds 4 allowed). Open
func parseBodyLinks(client *http.Client, topic string) (string, error) {
resp, err := client.Get(topic)
if err != nil {
return "", err
- Create a ticketCreate a ticket
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{}
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket