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") {
- Create a ticketCreate a ticket
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")
- Create a ticketCreate a ticket
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
- 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 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{}
- Create a ticketCreate a ticket
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")
- Create a ticketCreate a ticket
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 {
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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 {
- Create a ticketCreate a ticket
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{}
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Multiple consecutive blank lines Open
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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.
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
- Create a ticketCreate a ticket
- Exclude checks
Your code does not pass gofmt in 1 place. Go fmt your code! Open
// +build !debug
- Create a ticketCreate a ticket
- Exclude checks
exported function RandStringBytes should have comment or be unexported Open
func RandStringBytes(n int) string {
- Create a ticketCreate a ticket
- Exclude checks
Line length Open
Download the binaries from the [latest release](https://github.com/pstuifzand/ekster/releases/) on Github.
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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"
- Create a ticketCreate a ticket
- Exclude checks