gboudreau/Greyhole

View on GitHub

Showing 334 of 371 total issues

Method balance_share has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function balance_share($share, $share_options, $min_file_size) {
        Log::debug("├┐ Balancing share: $share ({$min_file_size}MB or + files)");

        /** @var $drives_selectors PoolDriveSelector[] */
        $drives_selectors = Config::get(CONFIG_DRIVE_SELECTION_ALGORITHM);
Severity: Minor
Found in includes/Tasks/BalanceTask.php - About 1 hr to fix

    Method get_new_share_defaults has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function get_new_share_defaults($all_samba_shares) {
        // Default path for new share: find the most-used path in existing shares
        $prefixes = [];
        $prefix_shares = [];
        $options = [];
    Severity: Minor
    Found in web-app/functions.inc.php - About 1 hr to fix

      Function success has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              success: function(data, textStatus, jqXHR) {
                  if (data.result === 'success') {
                      let $table = $('#table-sp tbody').text('');
                      for (let sp_drive in data.sp_stats) {
                          if (sp_drive === 'Total') {
      Severity: Minor
      Found in web-app/scripts.js - About 1 hr to fix

        Function parse_line has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function parse_line($name, $value) {
                if ($name[0] == '#') {
                    return;
                }
        
        
        Severity: Minor
        Found in includes/ConfigHelper.php - About 1 hr 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 gh_wild_mb_strpos has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        function gh_wild_mb_strpos($haystack, $needle) {
            /** @noinspection PhpSuspiciousNameCombinationInspection */
            $is_wild = string_contains($needle, "*");
            if (!$is_wild) {
                return mb_strpos($haystack, $needle);
        Severity: Minor
        Found in includes/common.php - About 1 hr 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 rrmdir has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        function rrmdir($dir) {
            // recursive remove directory
            if (is_dir($dir)) {
                $objects = scandir($dir);
                foreach ($objects as $object) {
        Severity: Minor
        Found in web-app/views/trash.php - About 1 hr 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 run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function run() {
                $num_dproc = static::get_num_daemon_proc();
                if ($num_dproc == 0) {
                    $this->log();
                    $this->log("Greyhole daemon is currently stopped.");
        Severity: Minor
        Found in includes/CLI/StatusCliRunner.php - About 1 hr to fix

          Method get_file_copies_inodes has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function get_file_copies_inodes($share, $file_path, $filename, &$file_metafiles, $one_is_enough = FALSE) {
                  $file_copies_inodes = [];
          
                  foreach (Config::storagePoolDrives() as $sp_drive) {
                      $clean_full_path = clean_dir("$sp_drive/$share/$file_path/$filename");
          Severity: Minor
          Found in includes/StoragePool.php - About 1 hr to fix

            Method gh_write_process_metafiles has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function gh_write_process_metafiles($num_copies_required, $existing_metafiles, $share, $full_path, $source_file, $filesize, $task_id, $keys_to_remove=NULL) {
                    $landing_zone = get_share_landing_zone($share);
                    list($path, $filename) = explode_full_path($full_path);
            
                    // Only need to check for locking if we have something to do!
            Severity: Minor
            Found in includes/Tasks/WriteTask.php - About 1 hr to fix

              Method connect has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function connect($retry_until_successful=FALSE, $throw_exception_on_error=FALSE, $timeout = 10) {
                      $connect_string = 'mysql:host=' . self::$options->host . ';dbname=' . self::$options->name . ';charset=utf8mb4';
              
                      try {
                          self::$handle = @new PDO($connect_string, self::$options->user, self::$options->pass, array(PDO::ATTR_TIMEOUT => $timeout, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
              Severity: Minor
              Found in includes/DB.php - About 1 hr to fix

                Method getDBLogs has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function getDBLogs($filename) {
                        $this->log("From DB");
                        $this->log("=======");
                
                        $query = "SELECT id, action, share, full_path, additional_info, event_date FROM tasks_completed WHERE full_path LIKE :filename ORDER BY id";
                Severity: Minor
                Found in includes/CLI/DebugCliRunner.php - About 1 hr to fix

                  Function taskCompleted has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function taskCompleted($task_id, $send_email) {
                          $fsck_work_log = static::getFromDisk();
                          foreach ($fsck_work_log->tasks as $task) {
                              if ($task->id == $task_id) {
                                  $task->status = static::STATUS_COMPLETE;
                  Severity: Minor
                  Found in includes/common.php - About 1 hr 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 parse_line_share_option has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private static function parse_line_share_option($name, $value) {
                          if (!string_starts_with($name, [CONFIG_NUM_COPIES, CONFIG_DELETE_MOVES_TO_TRASH, CONFIG_MODIFIED_MOVES_TO_TRASH, CONFIG_DRIVE_SELECTION_GROUPS, CONFIG_DRIVE_SELECTION_ALGORITHM])) {
                              return FALSE;
                          }
                          if (!preg_match('/^(.*)\[\s*(.*)\s*]$/', $name, $matches)) {
                  Severity: Minor
                  Found in includes/ConfigHelper.php - About 1 hr 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 confirmRemoveDrive has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function confirmRemoveDrive() {
                      let drive = $('#inputremove_drive').val();
                      if (drive === '0') {
                          alert('meh!');
                          return;
                  Severity: Minor
                  Found in web-app/scripts.js - About 1 hr 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 getDBLogs has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function getDBLogs($filename) {
                          $this->log("From DB");
                          $this->log("=======");
                  
                          $query = "SELECT id, action, share, full_path, additional_info, event_date FROM tasks_completed WHERE full_path LIKE :filename ORDER BY id";
                  Severity: Minor
                  Found in includes/CLI/DebugCliRunner.php - About 1 hr 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 execute has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function execute() {
                          $share = $this->share;
                          $full_path = $this->full_path;
                  
                          $landing_zone = get_share_landing_zone($share);
                  Severity: Minor
                  Found in includes/Tasks/RmdirTask.php - About 1 hr 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 restart_service has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function restart_service() {
                          if (is_file('/etc/init.d/greyhole')) {
                              exec("/etc/init.d/greyhole restart");
                              return TRUE;
                          } else if (is_file('/etc/init/greyhole.conf')) {
                  Severity: Minor
                  Found in includes/DaemonRunner.php - About 1 hr 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 get_metastores has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function get_metastores($use_cache=TRUE) {
                          if (!$use_cache) {
                              static::$metastores = [];
                          }
                          if (empty(static::$metastores)) {
                  Severity: Minor
                  Found in includes/Metastores.php - About 1 hr 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 wait has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function wait($wait_num = 0, $i = 0, $quiet = FALSE) {
                      global $config;
                      if (@$config->dont_wait) {
                          return;
                      }
                  Severity: Minor
                  Found in test_cases.php - About 1 hr 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 get_metafile_data_filenames has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function get_metafile_data_filenames($share, $path, $filename, $first_only=FALSE) {
                          $filenames = array();
                  
                          if ($first_only) {
                              $share_file = get_share_landing_zone($share) . "/$path/$filename";
                  Severity: Minor
                  Found in includes/Metastores.php - About 1 hr 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

                  Severity
                  Category
                  Status
                  Source
                  Language