gboudreau/Greyhole

View on GitHub
includes/Trash.php

Summary

Maintainability
C
1 day
Test Coverage

Function trash_file has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    public static function trash_file($real_path, $file_was_modified = FALSE) {
        $is_symlink = FALSE;
        clearstatcache();
        if (is_link($real_path)) {
            $is_symlink = TRUE;
Severity: Minor
Found in includes/Trash.php - About 5 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 trash_file has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function trash_file($real_path, $file_was_modified = FALSE) {
        $is_symlink = FALSE;
        clearstatcache();
        if (is_link($real_path)) {
            $is_symlink = TRUE;
Severity: Major
Found in includes/Trash.php - About 2 hrs to fix

    Function create_trash_share_symlink has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function create_trash_share_symlink($filepath_in_trash, $trash_path) {
            $trash_share = SharesConfig::getConfigForShare(CONFIG_TRASH_SHARE);
            if ($trash_share) {
                $filepath_in_trash = clean_dir($filepath_in_trash);
                $filepath_in_trash_share = str_replace($trash_path, $trash_share[CONFIG_LANDING_ZONE], $filepath_in_trash);
    Severity: Minor
    Found in includes/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 create_trash_share_symlink has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function create_trash_share_symlink($filepath_in_trash, $trash_path) {
            $trash_share = SharesConfig::getConfigForShare(CONFIG_TRASH_SHARE);
            if ($trash_share) {
                $filepath_in_trash = clean_dir($filepath_in_trash);
                $filepath_in_trash_share = str_replace($trash_path, $trash_share[CONFIG_LANDING_ZONE], $filepath_in_trash);
    Severity: Minor
    Found in includes/Trash.php - About 1 hr to fix

      Avoid too many return statements within this method.
      Open

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

        There are no issues that match your filters.

        Category
        Status