bnkamalesh/goapp

View on GitHub

Showing 8 of 8 total issues

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

func (h *Handlers) CreateUserNote(w http.ResponseWriter, r *http.Request) error {
    unote := new(usernotes.Note)
    err := json.NewDecoder(r.Body).Decode(unote)
    if err != nil {
        return errors.InputBodyErr(err, "invalid JSON provided")
Severity: Minor
Found in cmd/server/http/handlers_usernotes.go and 1 other location - About 45 mins to fix
cmd/server/http/handlers_users.go on lines 15..30

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

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 *Handlers) CreateUser(w http.ResponseWriter, r *http.Request) error {
    u := new(users.User)
    err := json.NewDecoder(r.Body).Decode(u)
    if err != nil {
        return errors.InputBodyErr(err, "invalid JSON provided")
Severity: Minor
Found in cmd/server/http/handlers_users.go and 1 other location - About 45 mins to fix
cmd/server/http/handlers_usernotes.go on lines 12..27

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

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 NewService has 5 return statements (exceeds 4 allowed).
Open

func NewService(cfg *Config, apis api.Server) (*HTTP, error) {
    home, err := loadHomeTemplate(cfg.TemplatesBasePath)
    if err != nil {
        return nil, err
    }
Severity: Major
Found in cmd/server/http/http.go - About 35 mins to fix

    Method APM.Shutdown has 5 return statements (exceeds 4 allowed).
    Open

    func (s *APM) Shutdown(ctx context.Context) error {
        ctx, cancel := context.WithTimeout(ctx, shutdownTimeout)
        defer cancel()
    
        g := errgroup.Group{}
    Severity: Major
    Found in internal/pkg/apm/apm.go - About 35 mins to fix

      Method Note.ValidateForCreate has 5 return statements (exceeds 4 allowed).
      Open

      func (note *Note) ValidateForCreate() error {
          if note == nil {
              return errors.Validation("empty note")
          }
      
      
      Severity: Major
      Found in internal/usernotes/usernotes.go - About 35 mins to fix

        Method GoApp.CreateUser has 5 return statements (exceeds 4 allowed).
        Open

        func (ht *GoApp) CreateUser(ctx context.Context, us *User) (*User, error) {
            payload, err := json.Marshal(us)
            if err != nil {
                return nil, errors.Wrap(err, "failed marshaling to json")
            }
        Severity: Major
        Found in lib/goapp/goapp.go - About 35 mins to fix

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

          func (m *Meter) HistogramRecord(ctx context.Context, name string, value float64, attrs ...attribute.KeyValue) {
              histogram, err := m.Float64Histogram(name)
              if err != nil {
                  return
              }
          Severity: Minor
          Found in internal/pkg/apm/meter.go and 1 other location - About 30 mins to fix
          internal/pkg/apm/meter.go on lines 34..40

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

          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 (m *Meter) CounterAdd(ctx context.Context, name string, amount float64, attrs ...attribute.KeyValue) {
              counter, err := m.Float64Counter(name)
              if err != nil {
                  return
              }
          Severity: Minor
          Found in internal/pkg/apm/meter.go and 1 other location - About 30 mins to fix
          internal/pkg/apm/meter.go on lines 44..50

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

          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