pstuifzand/ekster

View on GitHub

Showing 145 of 159 total issues

Function isFeedContentType has 5 return statements (exceeds 4 allowed).
Open

func isFeedContentType(contentType string) bool {
    if strings.HasPrefix(contentType, "application/rss+xml") {
        return true
    }
    if strings.HasPrefix(contentType, "application/atom+xml") {
Severity: Major
Found in pkg/websub/subscribe.go - About 35 mins to fix

Function ValidateHubSignature has 5 return statements (exceeds 4 allowed).
Open

func ValidateHubSignature(sig string, feedContent, secret []byte) error {
    parts := strings.Split(sig, "=")

    if len(parts) != 2 {
        return errors.New("signature format is not like sha1=signature")
Severity: Major
Found in pkg/websub/signature.go - About 35 mins to fix

Function parseBodyLinks has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
Open

func parseBodyLinks(client *http.Client, topic string) (string, error) {
    resp, err := client.Get(topic)

    if err != nil {
        return "", err
Severity: Minor
Found in pkg/websub/subscribe.go - About 35 mins 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 FeedHeader has 5 return statements (exceeds 4 allowed).
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{}
Severity: Major
Found in pkg/fetch/fetch.go - About 35 mins to fix

Function cachedCheckAuthToken has 5 return statements (exceeds 4 allowed).
Open

func cachedCheckAuthToken(conn redis.Conn, header string, tokenEndpoint string, r *auth.TokenResponse) (bool, error) {
    tokens := authHeaderRegex.FindStringSubmatch(header)

    if len(tokens) != 2 {
        return false, fmt.Errorf("could not find token in header")
Severity: Major
Found in cmd/eksterd/auth.go - About 35 mins to fix

Method Client.FollowGetList has 5 return statements (exceeds 4 allowed).
Open

func (c *Client) FollowGetList(channel string) ([]microsub.Feed, error) {
    args := make(map[string]string)
    args["channel"] = channel
    res, err := c.microsubGetRequest("follow", args)
    if err != nil {
Severity: Major
Found in pkg/client/requests.go - About 35 mins to fix

Method Client.TimelineGet has 5 return statements (exceeds 4 allowed).
Open

func (c *Client) TimelineGet(before, after, channel string) (microsub.Timeline, error) {
    args := make(map[string]string)
    args["after"] = after
    args["before"] = before
    args["channel"] = channel
Severity: Major
Found in pkg/client/requests.go - About 35 mins to fix

Method Client.PreviewURL has 5 return statements (exceeds 4 allowed).
Open

func (c *Client) PreviewURL(url string) (microsub.Timeline, error) {
    args := make(map[string]string)
    args["url"] = url
    res, err := c.microsubPostRequest("preview", args)
    if err != nil {
Severity: Major
Found in pkg/client/requests.go - About 35 mins to fix

Function FeedItems has 5 return statements (exceeds 4 allowed).
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 35 mins to fix

Method postgresStream.AddItem has 5 return statements (exceeds 4 allowed).
Open

func (p *postgresStream) AddItem(item microsub.Item) (bool, error) {
    ctx := context.Background()
    conn, err := p.database.Conn(ctx)
    if err != nil {
        return false, err
Severity: Major
Found in pkg/timeline/postgres.go - About 35 mins to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if ch, e := channelMap[c.Text]; !e {
            channelCreated, err := sub.ChannelsCreate(c.Text)
            if err != nil {
                log.Printf("An error occurred: %q\n", err)
                continue
Severity: Minor
Found in cmd/ek/main.go and 1 other location - About 30 mins to fix
cmd/ek/main.go on lines 509..520

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 101.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if ch, e := channelMap[c.Name]; !e {
            channelCreated, err := sub.ChannelsCreate(c.Name)
            if err != nil {
                log.Printf("An error occurred: %q\n", err)
                continue
Severity: Minor
Found in cmd/ek/main.go and 1 other location - About 30 mins to fix
cmd/ek/main.go on lines 571..582

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 101.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Multiple consecutive blank lines
Open


Severity: Info
Found in README.md by markdownlint

MD012 - Multiple consecutive blank lines

Tags: whitespace, blank_lines

Aliases: no-multiple-blanks

This rule is triggered when there are multiple consecutive blank lines in the document:

Some text here


Some more text here

To fix this, delete the offending lines:

Some text here

Some more text here

Note: this rule will not be triggered if there are multiple consecutive blank lines inside code blocks.

Line length
Open

This will first pull the Docker image from the Docker hub. Then run the image to generate a default backend.json file.
Severity: Info
Found in README.md by markdownlint

MD013 - Line length

Tags: line_length

Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

Code block style
Open

    go get -u p83.nl/go/ekster/cmd/eksterd
Severity: Info
Found in README.md by markdownlint

Your code does not pass gofmt in 1 place. Go fmt your code!
Open

// +build !debug
Severity: Minor
Found in pkg/rss/rss_default.go by gofmt

exported function RandStringBytes should have comment or be unexported
Open

func RandStringBytes(n int) string {
Severity: Minor
Found in pkg/util/randkey.go by golint

Line length
Open

Download the binaries from the [latest release](https://github.com/pstuifzand/ekster/releases/) on Github.
Severity: Info
Found in README.md by markdownlint

MD013 - Line length

Tags: line_length

Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

Line length
Open

It's also possible to visit the microsub server with your browser, there are a few ways to
Severity: Info
Found in README.md by markdownlint

MD013 - Line length

Tags: line_length

Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

2: cannot find package "github.com/gilliek/go-opml/opml" in any of:
Open

    "github.com/gilliek/go-opml/opml"
Severity: Minor
Found in cmd/ek/main.go by govet
Severity
Category
Status
Source
Language