dstpierre/gosaas

View on GitHub

Showing 29 of 29 total issues

Method Billing.Start has 6 return statements (exceeds 4 allowed).
Open

func (b Billing) Start(bc BillingNewCustomer) error {
    p := &stripe.CustomerParams{Email: stripe.String(bc.Email)}
    p.SetSource(bc.StripeToken)

    c, err := customer.New(p)
Severity: Major
Found in billing.go - About 40 mins to fix

    Method Users.GetDetail has 5 return statements (exceeds 4 allowed).
    Open

    func (u *Users) GetDetail(id int64) (*model.Account, error) {
        account := &model.Account{}
        row := u.DB.QueryRow("SELECT * FROM gosaas_accounts WHERE id = $1", id)
        err := row.Scan(&account.ID,
            &account.Email,
    Severity: Major
    Found in data/postgres/users.go - About 35 mins to fix

      Method Billing.stripe has 5 return statements (exceeds 4 allowed).
      Open

      func (b Billing) stripe(w http.ResponseWriter, r *http.Request) {
          ctx := r.Context()
          db := ctx.Value(ContextDatabase).(*data.DB)
      
          // no matter what happen, Stripe wants us to send a 200
      Severity: Major
      Found in billing.go - About 35 mins to fix

        Function Authenticator has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
        Open

        func Authenticator(next http.Handler) http.Handler {
            return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                ctx := r.Context()
                mr := ctx.Value(ContextMinimumRole).(model.Roles)
        
        
        Severity: Minor
        Found in auth.go - About 35 mins 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

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

        func increaseThrottle(key string, expire time.Duration) (int64, error) {
            i, err := rc.Incr(key).Result()
            if err != nil {
                return 0, err
            }
        Severity: Major
        Found in cache/throttling.go - About 35 mins to fix

          Method Billing.Overview has 5 return statements (exceeds 4 allowed).
          Open

          func (b Billing) Overview(accountID int64) (*BillingOverview, error) {
              // this struct will be returned should we be a paid customer or not
              ov := &BillingOverview{}
          
              // Get the current account
          Severity: Major
          Found in billing.go - About 35 mins to fix

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

            func setupCron() {
                if _, err := os.Stat("tasks.cron"); os.IsNotExist(err) {
                    log.Println("no tasks.cron file found, skipping scheduler setup")
                    return
                }
            Severity: Major
            Found in queue/queue.go - About 35 mins to fix

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

                          ov.Cards = append(ov.Cards, BillingCardData{
                              ID:         c.ID,
                              Name:       c.Name,
                              Number:     c.Last4,
                              Month:      fmt.Sprintf("%d", c.ExpMonth),
              Severity: Minor
              Found in billing.go and 1 other location - About 35 mins to fix
              billing.go on lines 513..521

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

              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

                      card := BillingCardData{
                          ID:         c.ID,
                          Name:       c.Name,
                          Number:     c.Last4,
                          Month:      fmt.Sprintf("%d", c.ExpMonth),
              Severity: Minor
              Found in billing.go and 1 other location - About 35 mins to fix
              billing.go on lines 146..154

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

              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