kitabisa/buroq

View on GitHub

Showing 9 of 9 total issues

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

var migrateDownCmd = &cobra.Command{
    Use:   "migratedown",
    Short: "Migrate Up DB Sekawan",
    Long:  `Please you know what are you doing by using this command`,
    Run: func(cmd *cobra.Command, args []string) {
Severity: Major
Found in cmd/migration.go and 1 other location - About 2 hrs to fix
cmd/migration.go on lines 15..33

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

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 migrateUpCmd = &cobra.Command{
    Use:   "migrate",
    Short: "Migrate Up DB Sekawan",
    Long:  `Please you know what are you doing by using this command`,
    Run: func(cmd *cobra.Command, args []string) {
Severity: Major
Found in cmd/migration.go and 1 other location - About 2 hrs to fix
cmd/migration.go on lines 35..53

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

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 start has 60 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func start() {
    cfg := config.Config()
    logger := log.NewLogger("buroq")

    app := appcontext.NewAppContext(cfg)
Severity: Minor
Found in cmd/root.go - About 1 hr to fix

    Function NewCache has 8 return statements (exceeds 4 allowed).
    Open

    func NewCache(option CacheOption) *redis.Pool {
        dialConnectTimeoutOption := redis.DialConnectTimeout(option.DialConnectTimeout)
        readTimeoutOption := redis.DialReadTimeout(option.ReadTimeout)
        writeTimeoutOption := redis.DialWriteTimeout(option.WriteTimeout)
    
    
    Severity: Major
    Found in internal/app/driver/redis.go - About 50 mins to fix

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

      func doMigrate(appCtx *appcontext.AppContext, logger *log.Logger, mSource migrate.FileMigrationSource, dbDialect string, direction migrate.MigrationDirection) error {
      Severity: Minor
      Found in cmd/migration.go - About 35 mins to fix

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

        func start() {
            cfg := config.Config()
            logger := log.NewLogger("buroq")
        
            app := appcontext.NewAppContext(cfg)
        Severity: Major
        Found in cmd/root.go - About 35 mins to fix

          Method HealthCheckHandler.HealthCheck has 5 return statements (exceeds 4 allowed).
          Open

          func (h HealthCheckHandler) HealthCheck(w http.ResponseWriter, r *http.Request) (data interface{}, pageToken *string, err error) {
              if h.HandlerOption.Config.GetBool("mysql.is_enabled") {
                  err = h.Services.HealthCheck.HealthCheckDbMysql()
                  if err != nil {
                      return
          Severity: Major
          Found in internal/app/handler/health_check.go - About 35 mins to fix

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

            func (h *healthCheck) HealthCheckDbMysql() (err error) {
                err = h.opt.DbMysql.Db.Ping()
                if err != nil {
                    h.opt.Logger.AddMessage(log.FatalLevel, err.Error())
                    err = commons.ErrDBConn
            Severity: Minor
            Found in internal/app/service/health_check.go and 1 other location - About 30 mins to fix
            internal/app/service/health_check.go on lines 36..43

            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

            func (h *healthCheck) HealthCheckDbPostgres() (err error) {
                err = h.opt.DbPostgre.Db.Ping()
                if err != nil {
                    h.opt.Logger.AddMessage(log.FatalLevel, err.Error())
                    err = commons.ErrDBConn
            Severity: Minor
            Found in internal/app/service/health_check.go and 1 other location - About 30 mins to fix
            internal/app/service/health_check.go on lines 27..34

            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

            Severity
            Category
            Status
            Source
            Language