bnkamalesh/verifier

View on GitHub

Showing 8 of 8 total issues

Method Postgres.ReadLastPending has 70 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (pgs *Postgres) ReadLastPending(ctype verifier.CommType, recipient string) (*verifier.Request, error) {
    query, args, err := pgs.qbuilder.Select(
        "id",
        "type",
        "sender",
Severity: Minor
Found in stores/postgres.go - About 1 hr to fix

    Function notifyWithCustomRequest has 51 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func notifyWithCustomRequest(vsvc *verifier.Verifier) {
        req, err := vsvc.NewRequest(
            verifier.CommTypeMobile,
            "+919876543210",
        )
    Severity: Minor
    Found in cmd/main.go - About 1 hr to fix

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

      func (ris *Redis) Create(ver *verifier.Request) (*verifier.Request, error) {
          key := fmt.Sprintf(
              "%s-%s",
              ver.Type,
              ver.Recipient,
      Severity: Major
      Found in stores/redis.go and 1 other location - About 1 hr to fix
      stores/redis.go on lines 87..113

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

      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 (ris *Redis) Update(verID string, ver *verifier.Request) (*verifier.Request, error) {
          key := fmt.Sprintf(
              "%s-%s",
              ver.Type,
              ver.Recipient,
      Severity: Major
      Found in stores/redis.go and 1 other location - About 1 hr to fix
      stores/redis.go on lines 29..56

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

      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 Verifier.verifyAndUpdate has 6 return statements (exceeds 4 allowed).
      Open

      func (ver *Verifier) verifyAndUpdate(secret string, verreq *Request) error {
          var err error
          now := time.Now()
          verreq.UpdatedAt = &now
          verreq.Attempts++
      Severity: Major
      Found in verifier.go - About 40 mins to fix

        Function notifyWithCustomRequest has 6 return statements (exceeds 4 allowed).
        Open

        func notifyWithCustomRequest(vsvc *verifier.Verifier) {
            req, err := vsvc.NewRequest(
                verifier.CommTypeMobile,
                "+919876543210",
            )
        Severity: Major
        Found in cmd/main.go - About 40 mins to fix

          Method Verifier.NewMobileWithReq has 5 return statements (exceeds 4 allowed).
          Open

          func (ver *Verifier) NewMobileWithReq(verreq *Request, body string) error {
              err := validateMobile(verreq.Recipient)
              if err != nil {
                  return err
              }
          Severity: Major
          Found in verifier.go - About 35 mins to fix

            Method Verifier.NewEmailWithReq has 5 return statements (exceeds 4 allowed).
            Open

            func (ver *Verifier) NewEmailWithReq(verreq *Request, subject, body string) error {
                err := validateEmailAddress(verreq.Recipient)
                if err != nil {
                    return err
                }
            Severity: Major
            Found in verifier.go - About 35 mins to fix
              Severity
              Category
              Status
              Source
              Language