pkg/api/events.go
Method eventsController.registerCoudEvent
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
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)
- Read upRead up
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
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)
Function sseHandlefunc
has 7 return statements (exceeds 4 allowed). Open
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")
}
Method eventsController.registerCoudEvent
has 6 return statements (exceeds 4 allowed). Open
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)
Function sseHandlefunc
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func sseHandlefunc(ctx context.Context, r *http.Request, c *eventsController, cursorTime time.Time, params []string) ([]CoursoredEvent, error) {
Function extractEventFilterParams
has 5 return statements (exceeds 4 allowed). Open
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)