agent/session.go
Method session.watch
has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring. Open
Open
func (s *session) watch(ctx context.Context) error {
logger := log.G(ctx).WithFields(log.Fields{"method": "(*session).watch"})
logger.Debugf("")
var (
resp *api.AssignmentsMessage
- 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 session.watch
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *session) watch(ctx context.Context) error {
logger := log.G(ctx).WithFields(log.Fields{"method": "(*session).watch"})
logger.Debugf("")
var (
resp *api.AssignmentsMessage
Method session.sendTaskStatuses
has 6 return statements (exceeds 4 allowed). Open
Open
func (s *session) sendTaskStatuses(ctx context.Context, updates ...*api.UpdateTaskStatusRequest_TaskStatusUpdate) ([]*api.UpdateTaskStatusRequest_TaskStatusUpdate, error) {
if len(updates) < 1 {
return nil, nil
}
Method session.watch
has 6 return statements (exceeds 4 allowed). Open
Open
func (s *session) watch(ctx context.Context) error {
logger := log.G(ctx).WithFields(log.Fields{"method": "(*session).watch"})
logger.Debugf("")
var (
resp *api.AssignmentsMessage
Method session.logSubscriptions
has 6 return statements (exceeds 4 allowed). Open
Open
func (s *session) logSubscriptions(ctx context.Context) error {
logger := log.G(ctx).WithFields(log.Fields{"method": "(*session).logSubscriptions"})
logger.Debugf("")
client := api.NewLogBrokerClient(s.conn.ClientConn)
Function newSession
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func newSession(ctx context.Context, agent *Agent, delay time.Duration, sessionID string, description *api.NodeDescription) *session {