CGA1123/bissy-api

View on GitHub

Showing 18 of 19 total issues

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

func (c *Config) apikeysCreate(claims *auth.Claims, w http.ResponseWriter, r *http.Request) error {
    handlerutils.ContentType(w, handlerutils.ContentTypeJSON)

    var create Create
    if err := utils.ParseJSONBody(r.Body, &create); err != nil {
Severity: Major
Found in auth/apikey/handlers.go and 2 other locations - About 2 hrs to fix
querycache/datasource_handlers.go on lines 28..44
querycache/query_handlers.go on lines 29..45

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 220.

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 3 locations. Consider refactoring.
Open

func (c *Config) datasourcesCreate(claims *auth.Claims, w http.ResponseWriter, r *http.Request) error {
    handlerutils.ContentType(w, handlerutils.ContentTypeJSON)

    var createDatasource CreateDatasource
    if err := utils.ParseJSONBody(r.Body, &createDatasource); err != nil {
Severity: Major
Found in querycache/datasource_handlers.go and 2 other locations - About 2 hrs to fix
auth/apikey/handlers.go on lines 64..80
querycache/query_handlers.go on lines 29..45

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 220.

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 3 locations. Consider refactoring.
Open

func (c *Config) queriesCreate(claims *auth.Claims, w http.ResponseWriter, r *http.Request) error {
    handlerutils.ContentType(w, handlerutils.ContentTypeJSON)

    var createQuery CreateQuery
    if err := utils.ParseJSONBody(r.Body, &createQuery); err != nil {
Severity: Major
Found in querycache/query_handlers.go and 2 other locations - About 2 hrs to fix
auth/apikey/handlers.go on lines 64..80
querycache/datasource_handlers.go on lines 28..44

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 220.

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

func (c *Config) datasourcesList(claims *auth.Claims, w http.ResponseWriter, r *http.Request) error {
    handlerutils.ContentType(w, handlerutils.ContentTypeJSON)

    params := handlerutils.Params(r)
    page := params.MaybeInt("page", 1)
Severity: Major
Found in querycache/datasource_handlers.go and 1 other location - About 2 hrs to fix
querycache/query_handlers.go on lines 13..27

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 194.

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

func (c *Config) queriesList(claims *auth.Claims, w http.ResponseWriter, r *http.Request) error {
    handlerutils.ContentType(w, handlerutils.ContentTypeJSON)

    params := handlerutils.Params(r)
    page := params.MaybeInt("page", 1)
Severity: Major
Found in querycache/query_handlers.go and 1 other location - About 2 hrs to fix
querycache/datasource_handlers.go on lines 12..26

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 194.

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

func (c *Config) queryUpdate(claims *auth.Claims, id string, w http.ResponseWriter, r *http.Request) error {
    var updateQuery UpdateQuery
    if err := utils.ParseJSONBody(r.Body, &updateQuery); err != nil {
        return &handlerutils.HandlerError{
            Err: err, Status: http.StatusUnprocessableEntity}
Severity: Major
Found in querycache/query_handlers.go and 1 other location - About 1 hr to fix
querycache/datasource_handlers.go on lines 64..77

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 187.

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

func (c *Config) datasourceUpdate(claims *auth.Claims, id string, w http.ResponseWriter, r *http.Request) error {
    var updateDatasource UpdateDatasource
    if err := utils.ParseJSONBody(r.Body, &updateDatasource); err != nil {
        return &handlerutils.HandlerError{
            Err: err, Status: http.StatusUnprocessableEntity}
Severity: Major
Found in querycache/datasource_handlers.go and 1 other location - About 1 hr to fix
querycache/query_handlers.go on lines 65..78

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 187.

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

type QueryStore interface {
    Get(string, string) (*Query, error)
    Create(string, *CreateQuery) (*Query, error)
    List(string, int, int) ([]*Query, error)
    Delete(string, string) (*Query, error)
Severity: Major
Found in querycache/query_store.go and 1 other location - About 1 hr to fix
querycache/datasource_store.go on lines 34..40

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 151.

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

type DatasourceStore interface {
    Get(string, string) (*Datasource, error)
    Create(string, *CreateDatasource) (*Datasource, error)
    List(string, int, int) ([]*Datasource, error)
    Delete(string, string) (*Datasource, error)
Severity: Major
Found in querycache/datasource_store.go and 1 other location - About 1 hr to fix
querycache/query_store.go on lines 76..82

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 151.

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

func (s *SQLDatasourceStore) List(userID string, page, per int) ([]*Datasource, error) {
    if page < 1 || per < 1 {
        return nil,
            fmt.Errorf("page and per must be greater than 0 (page %v) (per %v)",
                page, per)
Severity: Major
Found in querycache/datasource_sql_store.go and 1 other location - About 1 hr to fix
querycache/query_sql_store.go on lines 97..118

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 149.

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

func (s *SQLQueryStore) List(userID string, page, per int) ([]*Query, error) {
    if page < 1 || per < 1 {
        return nil,
            fmt.Errorf("page and per must be greater than 0 (page %v) (per %v)",
                page, per)
Severity: Major
Found in querycache/query_sql_store.go and 1 other location - About 1 hr to fix
querycache/datasource_sql_store.go on lines 67..89

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 149.

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 4 locations. Consider refactoring.
Open

func (c *Config) queryGet(claims *auth.Claims, id string, w http.ResponseWriter, r *http.Request) error {
    query, err := c.QueryStore.Get(claims.UserID, id)
    if err != nil {
        return err
    }
Severity: Major
Found in querycache/query_handlers.go and 3 other locations - About 50 mins to fix
querycache/datasource_handlers.go on lines 46..53
querycache/datasource_handlers.go on lines 55..62
querycache/query_handlers.go on lines 56..63

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 118.

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 4 locations. Consider refactoring.
Open

func (c *Config) datasourceDelete(claims *auth.Claims, id string, w http.ResponseWriter, r *http.Request) error {
    datasource, err := c.DatasourceStore.Delete(claims.UserID, id)
    if err != nil {
        return err
    }
Severity: Major
Found in querycache/datasource_handlers.go and 3 other locations - About 50 mins to fix
querycache/datasource_handlers.go on lines 46..53
querycache/query_handlers.go on lines 47..54
querycache/query_handlers.go on lines 56..63

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 118.

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 4 locations. Consider refactoring.
Open

func (c *Config) queryDelete(claims *auth.Claims, id string, w http.ResponseWriter, r *http.Request) error {
    query, err := c.QueryStore.Delete(claims.UserID, id)
    if err != nil {
        return err
    }
Severity: Major
Found in querycache/query_handlers.go and 3 other locations - About 50 mins to fix
querycache/datasource_handlers.go on lines 46..53
querycache/datasource_handlers.go on lines 55..62
querycache/query_handlers.go on lines 47..54

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 118.

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 4 locations. Consider refactoring.
Open

func (c *Config) datasourceGet(claims *auth.Claims, id string, w http.ResponseWriter, r *http.Request) error {
    datasource, err := c.DatasourceStore.Get(claims.UserID, id)
    if err != nil {
        return err
    }
Severity: Major
Found in querycache/datasource_handlers.go and 3 other locations - About 50 mins to fix
querycache/datasource_handlers.go on lines 55..62
querycache/query_handlers.go on lines 47..54
querycache/query_handlers.go on lines 56..63

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 118.

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

Function TestConfig has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

func TestConfig(jwtConfig *jwtprovider.Config, store auth.UserStore, stateStore cache.StateStore, githubApp *App, now time.Time) *Config {
Severity: Minor
Found in auth/github/handlers.go - About 35 mins to fix

Method Config.callback has 5 return statements (exceeds 4 allowed).
Open

func (c *Config) callback(w http.ResponseWriter, r *http.Request) error {
    params := handlerutils.Params(r)
    if err := params.Require("code", "state"); err != nil {
        return err
    }
Severity: Major
Found in auth/github/handlers.go - About 35 mins to fix

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

// +build tools
Severity: Minor
Found in tools.go by gofmt
Severity
Category
Status
Source
Language