gboudreau/Greyhole

View on GitHub
includes/DBSpool.php

Summary

Maintainability
F
4 days
Test Coverage

Function execute_next_task has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute_next_task() {
        if (!empty($this->next_tasks)) {
            $task = array_shift($this->next_tasks);
        } else {
            $this->next_tasks = $this->fetch_next_tasks(TRUE, TRUE);
Severity: Minor
Found in includes/DBSpool.php - About 6 hrs 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

File DBSpool.php has 401 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*
Copyright 2009-2020 Guillaume Boudreau

This file is part of Greyhole.
Severity: Minor
Found in includes/DBSpool.php - About 5 hrs to fix

    Method execute_next_task has 103 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function execute_next_task() {
            if (!empty($this->next_tasks)) {
                $task = array_shift($this->next_tasks);
            } else {
                $this->next_tasks = $this->fetch_next_tasks(TRUE, TRUE);
    Severity: Major
    Found in includes/DBSpool.php - About 4 hrs to fix

      Function close_task has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          public function close_task($act, $share, $fd, $fullpath, &$tasks) {
              if (!empty($fullpath)) {
                  $prop = 'full_path';
                  $prop_value = $fullpath;
              } else {
      Severity: Minor
      Found in includes/DBSpool.php - About 3 hrs 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

      Function close_all_tasks has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public function close_all_tasks($tasks) {
              $q = "SELECT COUNT(*) FROM tasks WHERE complete = 'no'";
              $has_incomplete_tasks = (int) DB::getFirstValue($q);
      
              $q = "SELECT COUNT(*) FROM tasks WHERE complete = 'written'";
      Severity: Minor
      Found in includes/DBSpool.php - About 2 hrs 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

      Method close_all_tasks has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function close_all_tasks($tasks) {
              $q = "SELECT COUNT(*) FROM tasks WHERE complete = 'no'";
              $has_incomplete_tasks = (int) DB::getFirstValue($q);
      
              $q = "SELECT COUNT(*) FROM tasks WHERE complete = 'written'";
      Severity: Minor
      Found in includes/DBSpool.php - About 2 hrs to fix

        Method close_task has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function close_task($act, $share, $fd, $fullpath, &$tasks) {
                if (!empty($fullpath)) {
                    $prop = 'full_path';
                    $prop_value = $fullpath;
                } else {
        Severity: Minor
        Found in includes/DBSpool.php - About 1 hr to fix

          Method isFileLocked has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function isFileLocked($share, $full_path) {
                  $db_spool = static::getInstance();
                  $idx = clean_dir("$share/$full_path");
                  if (isset($db_spool->locked_files[$idx])) {
                      return $db_spool->locked_files[$idx];
          Severity: Minor
          Found in includes/DBSpool.php - About 1 hr to fix

            Function delete_tasks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function delete_tasks($task_ids) {
                    if (empty($task_ids)) {
                        return;
                    }
                    if (is_string($task_ids)) {
            Severity: Minor
            Found in includes/DBSpool.php - About 45 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

            Method close_task has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function close_task($act, $share, $fd, $fullpath, &$tasks) {
            Severity: Minor
            Found in includes/DBSpool.php - About 35 mins to fix

              Method insert has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function insert($action, $share, $full_path, $additional_info, $fd) {
              Severity: Minor
              Found in includes/DBSpool.php - About 35 mins to fix

                Avoid too many return statements within this method.
                Open

                            return FALSE;
                Severity: Major
                Found in includes/DBSpool.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return;
                  Severity: Major
                  Found in includes/DBSpool.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return;
                    Severity: Major
                    Found in includes/DBSpool.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return FALSE;
                      Severity: Major
                      Found in includes/DBSpool.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return $result;
                        Severity: Major
                        Found in includes/DBSpool.php - About 30 mins to fix

                          Function fetch_next_tasks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function fetch_next_tasks($incl_md5, $update_idle, $include_written = TRUE) {
                                  $where_clause = "";
                                  if (!empty($this->locked_shares)) {
                                      $where_clause .= " AND share NOT IN ('" . implode("','", array_keys($this->locked_shares)) . "')";
                                  }
                          Severity: Minor
                          Found in includes/DBSpool.php - About 25 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

                          Function isFileLocked has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public static function isFileLocked($share, $full_path) {
                                  $db_spool = static::getInstance();
                                  $idx = clean_dir("$share/$full_path");
                                  if (isset($db_spool->locked_files[$idx])) {
                                      return $db_spool->locked_files[$idx];
                          Severity: Minor
                          Found in includes/DBSpool.php - About 25 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