vorteil/direktiv

View on GitHub
pkg/api/events.go

Summary

Maintainability
B
4 hrs
Test Coverage

Method eventsController.registerCoudEvent has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
Open

func (c *eventsController) registerCoudEvent(w http.ResponseWriter, r *http.Request) {
    ns := extractContextNamespace(r)
    cType := r.Header.Get("Content-type")
    limit := int64(1024 * 1024 * 32)

Severity: Minor
Found in pkg/api/events.go - About 1 hr 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 eventsController.registerCoudEvent has 52 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *eventsController) registerCoudEvent(w http.ResponseWriter, r *http.Request) {
    ns := extractContextNamespace(r)
    cType := r.Header.Get("Content-type")
    limit := int64(1024 * 1024 * 32)

Severity: Minor
Found in pkg/api/events.go - About 1 hr to fix

    Function sseHandlefunc has 7 return statements (exceeds 4 allowed).
    Open

    func sseHandlefunc(ctx context.Context, r *http.Request, c *eventsController, cursorTime time.Time, params []string) ([]CoursoredEvent, error) {
        ns := chi.URLParam(r, "namespace")
        if ns == "" {
            return nil, fmt.Errorf("namespace can not be empty")
        }
    Severity: Major
    Found in pkg/api/events.go - About 45 mins to fix

      Method eventsController.registerCoudEvent has 6 return statements (exceeds 4 allowed).
      Open

      func (c *eventsController) registerCoudEvent(w http.ResponseWriter, r *http.Request) {
          ns := extractContextNamespace(r)
          cType := r.Header.Get("Content-type")
          limit := int64(1024 * 1024 * 32)
      
      
      Severity: Major
      Found in pkg/api/events.go - About 40 mins to fix

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

        func sseHandlefunc(ctx context.Context, r *http.Request, c *eventsController, cursorTime time.Time, params []string) ([]CoursoredEvent, error) {
        Severity: Minor
        Found in pkg/api/events.go - About 35 mins to fix

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

          func extractEventFilterParams(r *http.Request) ([]string, error) {
              params := make([]string, 0)
              if v := chi.URLParam(r, "namespace"); v != "" {
                  params = append(params, "namespace")
                  params = append(params, v)
          Severity: Major
          Found in pkg/api/events.go - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status