opcotech/elemo

View on GitHub

Showing 170 of 170 total issues

Function TodoDrawer has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
Open

export function TodoDrawer() {
  const [showNewTodoForm, setShowNewTodoForm] = useState(false);

  const [todos, show, toggleDrawer, fetchingTodos, fetchTodos, updateTodo] = useStore((state) => [
    state.todos,
Severity: Minor
Found in web/components/todos/TodoDrawer.tsx - About 45 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

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

    if err := c.roleService.Create(ctx, ownedBy, organizationID, role); err != nil {
        if errors.Is(err, service.ErrNoPermission) {
            return api.V1OrganizationRolesCreate403JSONResponse{N403JSONResponse: permissionDenied}, nil
        }
        if errors.Is(err, repository.ErrNotFound) {
Severity: Major
Found in internal/transport/http/organization.go and 2 other locations - About 45 mins to fix
internal/transport/http/organization.go on lines 486..496
internal/transport/http/organization.go on lines 522..532

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

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 NewRouter has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
Open

func NewRouter(strictServer StrictServer, serverConfig *config.ServerConfig, tracer tracing.Tracer) (http.Handler, error) {
    if serverConfig == nil {
        return nil, config.ErrNoConfig
    }

Severity: Minor
Found in internal/transport/http/server.go - About 45 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

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

    if err := c.roleService.AddMember(ctx, roleID, userID, organizationID); err != nil {
        if errors.Is(err, service.ErrNoPermission) {
            return api.V1OrganizationRoleMembersAdd403JSONResponse{N403JSONResponse: permissionDenied}, nil
        }
        if errors.Is(err, repository.ErrNotFound) {
Severity: Major
Found in internal/transport/http/organization.go and 2 other locations - About 45 mins to fix
internal/transport/http/organization.go on lines 287..297
internal/transport/http/organization.go on lines 522..532

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

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 3 locations. Consider refactoring.
Open

    if err := c.roleService.RemoveMember(ctx, roleID, userID, organizationID); err != nil {
        if errors.Is(err, service.ErrNoPermission) {
            return api.V1OrganizationRoleMemberRemove403JSONResponse{N403JSONResponse: permissionDenied}, nil
        }
        if errors.Is(err, repository.ErrNotFound) {
Severity: Major
Found in internal/transport/http/organization.go and 2 other locations - About 45 mins to fix
internal/transport/http/organization.go on lines 287..297
internal/transport/http/organization.go on lines 486..496

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

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

    router.Route(PathMetrics, func(r chi.Router) {
        r.Handle(PathRoot, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
            ctx, span := tracer.Start(r.Context(), "transport.http.handler/GetPrometheusMetrics")
            defer span.End()

Severity: Minor
Found in internal/transport/async/worker.go and 1 other location - About 45 mins to fix
internal/transport/http/server.go on lines 237..244

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

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

    router.Route(PathMetrics, func(r chi.Router) {
        r.Handle(PathRoot, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
            ctx, span := tracer.Start(r.Context(), "transport.http.handler/GetPrometheusMetrics")
            defer span.End()

Severity: Minor
Found in internal/transport/http/server.go and 1 other location - About 45 mins to fix
internal/transport/async/worker.go on lines 186..193

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

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 NewServer has 9 return statements (exceeds 7 allowed).
Open

func NewServer(opts ...ControllerOption) (StrictServer, error) {
    var err error

    c, err := newController(opts...)
    if err != nil {
Severity: Major
Found in internal/transport/http/server.go - About 40 mins to fix

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

    func (s *permissionService) GetBySubject(ctx context.Context, id model.ID) ([]*model.Permission, error) {
        ctx, span := s.tracer.Start(ctx, "service.permissionService/GetBySubject")
        defer span.End()
    
        permissions, err := s.permissionRepo.GetBySubject(ctx, id)
    Severity: Minor
    Found in internal/service/permission.go and 1 other location - About 40 mins to fix
    internal/service/permission.go on lines 137..147

    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 (s *permissionService) GetByTarget(ctx context.Context, id model.ID) ([]*model.Permission, error) {
        ctx, span := s.tracer.Start(ctx, "service.permissionService/GetByTarget")
        defer span.End()
    
        permissions, err := s.permissionRepo.GetByTarget(ctx, id)
    Severity: Minor
    Found in internal/service/permission.go and 1 other location - About 40 mins to fix
    internal/service/permission.go on lines 125..135

    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 (r *CachedProjectRepository) Create(ctx context.Context, namespaceID model.ID, project *model.Project) error {
        if err := clearProjectsAllGetAll(ctx, r.cacheRepo); err != nil {
            return err
        }
        if err := clearProjectsAllCrossCache(ctx, r.cacheRepo); err != nil {
    Severity: Minor
    Found in internal/repository/redis/project.go and 1 other location - About 40 mins to fix
    internal/repository/redis/namespace.go on lines 43..52

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

    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 (r *CachedNamespaceRepository) Create(ctx context.Context, orgID model.ID, namespace *model.Namespace) error {
        if err := clearNamespacesAllGetAll(ctx, r.cacheRepo); err != nil {
            return err
        }
        if err := clearNamespaceAllCrossCache(ctx, r.cacheRepo); err != nil {
    Severity: Minor
    Found in internal/repository/redis/namespace.go and 1 other location - About 40 mins to fix
    internal/repository/redis/project.go on lines 47..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 129.

    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 NewUserService(opts ...Option) (UserService, error) {
        s, err := newService(opts...)
        if err != nil {
            return nil, err
        }
    Severity: Minor
    Found in internal/service/user.go and 1 other location - About 40 mins to fix
    internal/service/todo.go on lines 154..177

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

    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 NewTodoService(opts ...Option) (TodoService, error) {
        s, err := newService(opts...)
        if err != nil {
            return nil, err
        }
    Severity: Minor
    Found in internal/service/todo.go and 1 other location - About 40 mins to fix
    internal/service/user.go on lines 208..231

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

    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 systemService.checkStatus has 7 arguments (exceeds 6 allowed). Consider refactoring.
    Open

        ctx context.Context,
        name model.HealthCheckComponent,
        resource Pingable,
        response map[model.HealthCheckComponent]model.HealthStatus,
        errCh chan error,
    Severity: Major
    Found in internal/service/system.go - About 35 mins to fix

      Method ProjectRepository.scan has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
      Open

      func (r *ProjectRepository) scan(pp, dp, tp, ip string) func(rec *neo4j.Record) (*model.Project, error) {
          return func(rec *neo4j.Record) (*model.Project, error) {
              p := new(model.Project)
      
              val, _, err := neo4j.GetRecordValue[neo4j.Node](rec, pp)
      Severity: Minor
      Found in internal/repository/neo4j/project.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

      Method userService.Delete has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
      Open

      func (s *userService) Delete(ctx context.Context, id model.ID, force bool) error {
          ctx, span := s.tracer.Start(ctx, "service.userService/Delete")
          defer span.End()
      
          if expired, err := s.licenseService.Expired(ctx); expired || err != nil {
      Severity: Minor
      Found in internal/service/user.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

      Method userService.Update has 8 return statements (exceeds 7 allowed).
      Open

      func (s *userService) Update(ctx context.Context, id model.ID, patch map[string]any) (*model.User, error) {
          ctx, span := s.tracer.Start(ctx, "service.userService/Update")
          defer span.End()
      
          if expired, err := s.licenseService.Expired(ctx); expired || err != nil {
      Severity: Major
      Found in internal/service/user.go - About 35 mins to fix

        Function NewLicense has 8 return statements (exceeds 7 allowed).
        Open

        func NewLicense(licenseKey, pubKey string) (*License, error) {
            var err error
        
            key, err := lk.PublicKeyFromB32String(pubKey)
            if err != nil {
        Severity: Major
        Found in internal/license/license.go - About 35 mins to fix

          Method OrganizationRepository.scan has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
          Open

          func (r *OrganizationRepository) scan(op, np, tp, mp string) func(rec *neo4j.Record) (*model.Organization, error) {
              return func(rec *neo4j.Record) (*model.Organization, error) {
                  org := new(model.Organization)
          
                  val, _, err := neo4j.GetRecordValue[neo4j.Node](rec, op)
          Severity: Minor
          Found in internal/repository/neo4j/organization.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

          Severity
          Category
          Status
          Source
          Language