timoth-y/kicksware-api

View on GitHub

Showing 60 of 60 total issues

Identical blocks of code found in 6 locations. Consider refactoring.
Open

package env

import (
    "log"
    "os"
Severity: Major
Found in services/references/env/envConfig.go and 5 other locations - About 2 hrs to fix
services/cdn/env/envConfig.go on lines 1..32
services/orders/env/envConfig.go on lines 1..32
services/products/env/envConfig.go on lines 1..32
services/rating/env/envConfig.go on lines 1..32
services/search/env/envConfig.go on lines 1..32

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

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

Identical blocks of code found in 6 locations. Consider refactoring.
Open

package env

import (
    "log"
    "os"
Severity: Major
Found in services/cdn/env/envConfig.go and 5 other locations - About 2 hrs to fix
services/orders/env/envConfig.go on lines 1..32
services/products/env/envConfig.go on lines 1..32
services/rating/env/envConfig.go on lines 1..32
services/references/env/envConfig.go on lines 1..32
services/search/env/envConfig.go on lines 1..32

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

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

Identical blocks of code found in 6 locations. Consider refactoring.
Open

package env

import (
    "log"
    "os"
Severity: Major
Found in services/rating/env/envConfig.go and 5 other locations - About 2 hrs to fix
services/cdn/env/envConfig.go on lines 1..32
services/orders/env/envConfig.go on lines 1..32
services/products/env/envConfig.go on lines 1..32
services/references/env/envConfig.go on lines 1..32
services/search/env/envConfig.go on lines 1..32

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

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

Identical blocks of code found in 6 locations. Consider refactoring.
Open

package env

import (
    "log"
    "os"
Severity: Major
Found in services/orders/env/envConfig.go and 5 other locations - About 2 hrs to fix
services/cdn/env/envConfig.go on lines 1..32
services/products/env/envConfig.go on lines 1..32
services/rating/env/envConfig.go on lines 1..32
services/references/env/envConfig.go on lines 1..32
services/search/env/envConfig.go on lines 1..32

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

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

Identical blocks of code found in 6 locations. Consider refactoring.
Open

package env

import (
    "log"
    "os"
Severity: Major
Found in services/search/env/envConfig.go and 5 other locations - About 2 hrs to fix
services/cdn/env/envConfig.go on lines 1..32
services/orders/env/envConfig.go on lines 1..32
services/products/env/envConfig.go on lines 1..32
services/rating/env/envConfig.go on lines 1..32
services/references/env/envConfig.go on lines 1..32

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

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

Identical blocks of code found in 6 locations. Consider refactoring.
Open

package env

import (
    "log"
    "os"
Severity: Major
Found in services/products/env/envConfig.go and 5 other locations - About 2 hrs to fix
services/cdn/env/envConfig.go on lines 1..32
services/orders/env/envConfig.go on lines 1..32
services/rating/env/envConfig.go on lines 1..32
services/references/env/envConfig.go on lines 1..32
services/search/env/envConfig.go on lines 1..32

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

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

Method repository.buildQueryPipeline has 84 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (r *repository) buildQueryPipeline(matchQuery bson.M, param *meta.RequestParams) mongo.Pipeline {
    pipe := mongo.Pipeline{}
    pipe = append(pipe, bson.D{{"$match", matchQuery}})

    pipe = append(pipe, bson.D{
Severity: Major
Found in services/references/usecase/storage/mongo/repository.go - About 2 hrs to fix

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

    func appendInCondition(query *meta.RequestQuery, keys []string) {
        in := meta.RequestQuery{ "$in": keys }
        inQuery := meta.RequestQuery{
            uniqueIdFieldName: in,
        }
    Severity: Major
    Found in services/orders/usecase/business/orderService.go and 2 other locations - About 1 hr to fix
    services/products/usecase/business/sneakerProductService.go on lines 119..135
    services/references/usecase/business/sneakerReferenceService.go on lines 113..129

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

    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

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

    func appendInCondition(query *meta.RequestQuery, keys []string) {
        in := meta.RequestQuery{ "$in": keys }
        inQuery := meta.RequestQuery{
            uniqueIdFieldName: in,
        }
    services/orders/usecase/business/orderService.go on lines 128..144
    services/products/usecase/business/sneakerProductService.go on lines 119..135

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

    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

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

    func appendInCondition(query *meta.RequestQuery, keys []string) {
        in := meta.RequestQuery{ "$in": keys }
        inQuery := meta.RequestQuery{
            uniqueIdFieldName: in,
        }
    services/orders/usecase/business/orderService.go on lines 128..144
    services/references/usecase/business/sneakerReferenceService.go on lines 113..129

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

    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

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

    func newMongoClient(config config.DataStoreConfig) (*mongo.Client, error) {
        ctx, cancel := context.WithTimeout(context.Background(), time.Duration(config.Timeout)*time.Second)
        defer cancel()
        client, err := mongo.Connect(ctx, options.Client().
            ApplyURI(config.URL),
    Severity: Major
    Found in services/users/usecase/storage/mongo/repository.go and 1 other location - About 1 hr to fix
    services/products/usecase/storage/mongo/repository.go on lines 49..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 166.

    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

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

    func newMongoClient(config config.DataStoreConfig) (*mongo.Client, error) {
        ctx, cancel := context.WithTimeout(context.Background(), time.Duration(config.Timeout)*time.Second)
        defer cancel()
        client, err := mongo.Connect(ctx, options.Client().
            ApplyURI(config.URL),
    Severity: Major
    Found in services/products/usecase/storage/mongo/repository.go and 1 other location - About 1 hr to fix
    services/users/usecase/storage/mongo/repository.go on lines 48..62

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

    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 toBson has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
    Open

    func toBson(v interface{}) (m bson.M, err error) {
        dict, err := toMap(v)
        if err != nil {
            return
        }
    Severity: Minor
    Found in shared/core/meta/requestQuery.go - About 1 hr 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

    Identical blocks of code found in 4 locations. Consider refactoring.
    Open

    func newPostgresClient(url string) (*sqlx.DB, error) {
        ctx, cancel := context.WithCancel(context.Background())
        defer cancel()
        db, err := sqlx.ConnectContext(ctx,"pgx", url)
        if err != nil {
    Severity: Major
    Found in services/references/usecase/storage/postgres/repository.go and 3 other locations - About 1 hr to fix
    services/orders/usecase/storage/postgres/repository.go on lines 37..48
    services/products/usecase/storage/postgres/repository.go on lines 38..49
    services/users/usecase/storage/postgres/repository.go on lines 37..48

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

    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

    Identical blocks of code found in 4 locations. Consider refactoring.
    Open

    func newPostgresClient(url string) (*sqlx.DB, error) {
        ctx, cancel := context.WithCancel(context.Background())
        defer cancel()
        db, err := sqlx.ConnectContext(ctx,"pgx", url)
        if err != nil {
    Severity: Major
    Found in services/products/usecase/storage/postgres/repository.go and 3 other locations - About 1 hr to fix
    services/orders/usecase/storage/postgres/repository.go on lines 37..48
    services/references/usecase/storage/postgres/repository.go on lines 37..48
    services/users/usecase/storage/postgres/repository.go on lines 37..48

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

    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

    Identical blocks of code found in 4 locations. Consider refactoring.
    Open

    func newPostgresClient(url string) (*sqlx.DB, error) {
        ctx, cancel := context.WithCancel(context.Background())
        defer cancel()
        db, err := sqlx.ConnectContext(ctx,"pgx", url)
        if err != nil {
    Severity: Major
    Found in services/users/usecase/storage/postgres/repository.go and 3 other locations - About 1 hr to fix
    services/orders/usecase/storage/postgres/repository.go on lines 37..48
    services/products/usecase/storage/postgres/repository.go on lines 38..49
    services/references/usecase/storage/postgres/repository.go on lines 37..48

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

    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

    Identical blocks of code found in 4 locations. Consider refactoring.
    Open

    func newPostgresClient(url string) (*sqlx.DB, error) {
        ctx, cancel := context.WithCancel(context.Background())
        defer cancel()
        db, err := sqlx.ConnectContext(ctx,"pgx", url)
        if err != nil {
    Severity: Major
    Found in services/orders/usecase/storage/postgres/repository.go and 3 other locations - About 1 hr to fix
    services/products/usecase/storage/postgres/repository.go on lines 38..49
    services/references/usecase/storage/postgres/repository.go on lines 37..48
    services/users/usecase/storage/postgres/repository.go on lines 37..48

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

    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

    Method communicator.PostMessage has 7 return statements (exceeds 4 allowed).
    Open

    func (c *communicator) PostMessage(endpoint string, query interface{}, response interface{}, params ...*meta.RequestParams) error {
        url := fmt.Sprintf(c.endpointFormat, endpoint)
        body, err := json.Marshal(query); if err != nil {
            return err
        }
    Severity: Major
    Found in shared/api/rest/innerServiceCommunicator.go - About 45 mins to fix

      Function trySendMail has 7 return statements (exceeds 4 allowed).
      Open

      func trySendMail(config env.MailConfig, subject string, msg string, to string) error {
          client, err := mailClient(config); if err != nil {
              return err
          }
      
      
      Severity: Major
      Found in services/users/usecase/business/mailService.go - About 45 mins to fix

        Method repository.FetchQuery has 7 return statements (exceeds 4 allowed).
        Open

        func (r *repository) FetchQuery(query meta.RequestQuery, params *meta.RequestParams) ([]*model.SneakerProduct, error) {
            ctx, cancel := context.WithTimeout(context.Background(), r.timeout)
            defer cancel()
        
            filter, err := query.ToBson(); if err != nil {
        Severity: Major
        Found in services/products/usecase/storage/mongo/repository.go - About 45 mins to fix
          Severity
          Category
          Status
          Source
          Language