cloud/gcp/queue.go
Method QueueService.Queues
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *QueueService) Queues(ctx context.Context, handler cloud.QueueStatusHandler) (err error) {
s.Logger.Println("Retrieving queue names")
statusSet := make(map[string]cloud.QueueStatus)
Method QueueService.Queues
has 7 return statements (exceeds 4 allowed). Open
Open
func (s *QueueService) Queues(ctx context.Context, handler cloud.QueueStatusHandler) (err error) {
s.Logger.Println("Retrieving queue names")
statusSet := make(map[string]cloud.QueueStatus)
Method QueueService.deleteTask
has 6 return statements (exceeds 4 allowed). Open
Open
func (s *QueueService) deleteTask(ctx context.Context, query *datastore.Query) (err error) {
client, err := s.newClient(ctx)
if err != nil {
return
Method QueueService.CreateWorkers
has 6 return statements (exceeds 4 allowed). Open
Open
func (s *QueueService) CreateWorkers(ctx context.Context, queue string, n int, handler cloud.QueueManagerNameHandler) (err error) {
s.Logger.Println("Creating worker instances for queue", queue)
cService := NewComputeService(s.Config, s.Logger)
Method QueueService.UpdateTask
has 6 return statements (exceeds 4 allowed). Open
Open
func (s *QueueService) UpdateTask(ctx context.Context, queue string, modifier func(*Task) *Task) (err error) {
s.Logger.Println("Updating tasks' status in queue", queue)
query := datastore.NewQuery(QueueKind).Filter("QueueName=", queue)
Method QueueService.Restart
has 6 return statements (exceeds 4 allowed). Open
Open
func (s *QueueService) Restart(ctx context.Context, queue string) (err error) {
s.Logger.Println("Restarting queue", queue)
err = s.UpdateTask(ctx, queue, func(task *Task) *Task {
if task.Status == TaskStatusPending {
Method QueueService.Enqueue
has 6 return statements (exceeds 4 allowed). Open
Open
func (s *QueueService) Enqueue(ctx context.Context, queue string, task *script.Script) (err error) {
s.Logger.Println("Enqueuing a task to queue", queue)
id := time.Now().Unix()
key := datastore.IDKey(QueueKind, id, nil)
Method QueueService.Fetch
has 5 return statements (exceeds 4 allowed). Open
Open
func (s *QueueService) Fetch(ctx context.Context, queue string) (task *Task, err error) {
s.Logger.Println("Retrieving a task in queue", queue)
query := datastore.NewQuery(QueueKind).Filter("QueueName=", queue).Filter("Status=", TaskStatusWaiting).Limit(1)
Method QueueService.Queues
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (s *QueueService) Queues(ctx context.Context, handler cloud.QueueStatusHandler) (err error) {
s.Logger.Println("Retrieving queue names")
statusSet := make(map[string]cloud.QueueStatus)
- 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"