ezeql/koding-challange

View on GitHub

Showing 23 of 23 total issues

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

var (
    rabbitHost     = flag.String("rabbit-host", "127.0.0.1", "RabbitMQ host")
    rabbitPort     = flag.Int("rabbit-port", 5672, "RabbitMQ port")
    rabbitUser     = flag.String("rabbit-user", "guest", "RabbitMQ username")
    rabbitPassword = flag.String("rabbit-password", "guest", "RabbitMQ password")
Severity: Major
Found in cmd/hourlylog/main.go and 1 other location - About 1 hr to fix
cmd/distinctname/main.go on lines 14..24

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

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

var (
    rabbitHost     = flag.String("rabbit-host", "127.0.0.1", "RabbitMQ host")
    rabbitPort     = flag.Int("rabbit-port", 5672, "RabbitMQ port")
    rabbitUser     = flag.String("rabbit-user", "guest", "RabbitMQ username")
    rabbitPassword = flag.String("rabbit-password", "guest", "RabbitMQ password")
Severity: Major
Found in cmd/distinctname/main.go and 1 other location - About 1 hr to fix
cmd/hourlylog/main.go on lines 13..23

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

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 openDB has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

func openDB(host string, port int, user string, password string, dbName string) (*pgdb, error) {
Severity: Minor
Found in cmd/accountname/main.go - About 35 mins to fix

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

    func BuildRabbitMQConnector(host string, port int, user string, password string, exchange string) (*RabbitMQConnector, error) {
    Severity: Minor
    Found in common/amqpconnector.go - About 35 mins to fix

      Method RabbitMQConnector.open has 5 return statements (exceeds 4 allowed).
      Open

      func (m *RabbitMQConnector) open() error {
          var err error
          if m.conn, err = amqp.Dial(m.url); err != nil {
              return fmt.Errorf("Dial: %v", err)
          }
      Severity: Major
      Found in common/amqpconnector.go - About 35 mins to fix

        Your code does not pass gofmt in 2 places. Go fmt your code!
        Open

        package common
        Severity: Minor
        Found in common/metric.go by gofmt

        exported type RabbitMQConnector should have comment or be unexported
        Open

        type RabbitMQConnector struct {
        Severity: Minor
        Found in common/amqpconnector.go by golint

        exported func OpenMongo returns unexported type *main.mongo, which can be annoying to use
        Open

        func OpenMongo(host string, port int) (*mongo, error) {
        Severity: Minor
        Found in cmd/hourlylog/main.go by golint

        exported function BuildRabbitMQConnector should have comment or be unexported
        Open

        func BuildRabbitMQConnector(host string, port int, user string, password string, exchange string) (*RabbitMQConnector, error) {
        Severity: Minor
        Found in common/amqpconnector.go by golint

        exported method RabbitMQConnector.Close should have comment or be unexported
        Open

        func (m *RabbitMQConnector) Close() error {
        Severity: Minor
        Found in common/amqpconnector.go by golint

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

        package main
        Severity: Minor
        Found in cmd/accountname/main.go by gofmt

        exported function OpenRedis should have comment or be unexported
        Open

        func OpenRedis(host string, port int) (*redisPool, error) {
        Severity: Minor
        Found in cmd/distinctname/main.go by golint

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

        package main
        Severity: Minor
        Found in cmd/distinctname/main.go by gofmt

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

        package common
        Severity: Minor
        Found in common/logger.go by gofmt

        2: cannot find package "github.com/ezeql/koding-challange/common" in any of:
        Open

            "github.com/ezeql/koding-challange/common"
        Severity: Minor
        Found in cmd/accountname/main.go by govet

        exported method RabbitMQConnector.Handle should have comment or be unexported
        Open

        func (m *RabbitMQConnector) Handle(queueName string, f ProcesorFunc) error {
        Severity: Minor
        Found in common/amqpconnector.go by golint

        exported func OpenRedis returns unexported type *main.redisPool, which can be annoying to use
        Open

        func OpenRedis(host string, port int) (*redisPool, error) {
        Severity: Minor
        Found in cmd/distinctname/main.go by golint

        exported type ProcesorFunc should have comment or be unexported
        Open

        type ProcesorFunc func([]byte) bool
        Severity: Minor
        Found in common/amqpconnector.go by golint

        comment on exported type MetricEntry should be of the form "MetricEntry ..." (with optional leading article)
        Open

        //MetricData
        Severity: Minor
        Found in common/metric.go by golint

        exported method RabbitMQConnector.Publish should have comment or be unexported
        Open

        func (m *RabbitMQConnector) Publish(b []byte) error {
        Severity: Minor
        Found in common/amqpconnector.go by golint
        Severity
        Category
        Status
        Source
        Language