outboundSender.go
Method CaduceusOutboundSender.send
has 87 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (obs *CaduceusOutboundSender) send(urls *ring.Ring, secret, acceptType string, msg *wrp.Message) {
defer func() {
if r := recover(); nil != r {
obs.droppedPanic.Add(1.0)
obs.logger.Error("goroutine send() panicked", zap.String("id", obs.id), zap.Any("panic", r))
File outboundSender.go
has 519 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
// SPDX-FileCopyrightText: 2021 Comcast Cable Communications Management, LLC
// SPDX-License-Identifier: Apache-2.0
package main
import (
Method CaduceusOutboundSender.Update
has 72 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (obs *CaduceusOutboundSender) Update(wh ancla.InternalWebhook) (err error) {
// Validate the failure URL, if present
if "" != wh.Webhook.FailureURL {
if _, err = url.ParseRequestURI(wh.Webhook.FailureURL); nil != err {
Method CaduceusOutboundSender.Queue
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (obs *CaduceusOutboundSender) Queue(msg *wrp.Message) {
obs.mutex.RLock()
deliverUntil := obs.deliverUntil
dropUntil := obs.dropUntil
events := obs.events
Method OutboundSenderFactory.New
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (osf OutboundSenderFactory) New() (obs OutboundSender, err error) {
if _, err = url.ParseRequestURI(osf.Listener.Webhook.Config.URL); nil != err {
return
}
Method CaduceusOutboundSender.Update
has 6 return statements (exceeds 4 allowed). Open
Open
func (obs *CaduceusOutboundSender) Update(wh ancla.InternalWebhook) (err error) {
// Validate the failure URL, if present
if "" != wh.Webhook.FailureURL {
if _, err = url.ParseRequestURI(wh.Webhook.FailureURL); nil != err {
Method OutboundSenderFactory.New
has 6 return statements (exceeds 4 allowed). Open
Open
func (osf OutboundSenderFactory) New() (obs OutboundSender, err error) {
if _, err = url.ParseRequestURI(osf.Listener.Webhook.Config.URL); nil != err {
return
}
Method CaduceusOutboundSender.queueOverflow
has 6 return statements (exceeds 4 allowed). Open
Open
func (obs *CaduceusOutboundSender) queueOverflow() {
obs.mutex.Lock()
if time.Now().Before(obs.dropUntil) {
obs.mutex.Unlock()
return
Method CaduceusOutboundSender.Update
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
Open
func (obs *CaduceusOutboundSender) Update(wh ancla.InternalWebhook) (err error) {
// Validate the failure URL, if present
if "" != wh.Webhook.FailureURL {
if _, err = url.ParseRequestURI(wh.Webhook.FailureURL); nil != err {
- 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
error strings should not be capitalized or end with punctuation or a newline Open
Open
err = errors.New("events must not be empty.")
- Exclude checks
exported type OutboundSender should have comment or be unexported Open
Open
type OutboundSender interface {
- Exclude checks