jkawamoto/roadie

View on GitHub
cloud/gcp/queue.go

Summary

Maintainability
B
6 hrs
Test Coverage

Method QueueService.Queues has 67 lines of code (exceeds 50 allowed). Consider refactoring.
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)

Severity: Minor
Found in cloud/gcp/queue.go - About 1 hr to fix

    Method QueueService.Queues has 7 return statements (exceeds 4 allowed).
    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)
    
    
    Severity: Major
    Found in cloud/gcp/queue.go - About 45 mins to fix

      Method QueueService.deleteTask has 6 return statements (exceeds 4 allowed).
      Open

      func (s *QueueService) deleteTask(ctx context.Context, query *datastore.Query) (err error) {
      
          client, err := s.newClient(ctx)
          if err != nil {
              return
      Severity: Major
      Found in cloud/gcp/queue.go - About 40 mins to fix

        Method QueueService.CreateWorkers has 6 return statements (exceeds 4 allowed).
        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)
        
        
        Severity: Major
        Found in cloud/gcp/queue.go - About 40 mins to fix

          Method QueueService.UpdateTask has 6 return statements (exceeds 4 allowed).
          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)
          
          
          Severity: Major
          Found in cloud/gcp/queue.go - About 40 mins to fix

            Method QueueService.Restart has 6 return statements (exceeds 4 allowed).
            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 {
            Severity: Major
            Found in cloud/gcp/queue.go - About 40 mins to fix

              Method QueueService.Enqueue has 6 return statements (exceeds 4 allowed).
              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)
              Severity: Major
              Found in cloud/gcp/queue.go - About 40 mins to fix

                Method QueueService.Fetch has 5 return statements (exceeds 4 allowed).
                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)
                
                
                Severity: Major
                Found in cloud/gcp/queue.go - About 35 mins to fix

                  Method QueueService.Queues has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                  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)
                  
                  
                  Severity: Minor
                  Found in cloud/gcp/queue.go - About 35 mins 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

                  There are no issues that match your filters.

                  Category
                  Status