classes/yf_dir.class.php

Summary

Maintainability
F
1 wk
Test Coverage

File yf_dir.class.php has 625 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Filesystem utils.
 *
Severity: Major
Found in classes/yf_dir.class.php - About 1 day to fix

    Function _skip_by_pattern has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

        public function _skip_by_pattern($path = '', $_is_dir = false, $pattern_include = '', $pattern_exclude = '')
        {
            if ( ! $path) {
                return false;
            }
    Severity: Minor
    Found in classes/yf_dir.class.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

    Function mkdir_m has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        public function mkdir_m($dir_name, $dir_mode = 0755, $create_index_htmls = 0, $start_folder = '')
        {
            if ( ! $dir_name || ! strlen($dir_name)) {
                return 0;
            }
    Severity: Minor
    Found in classes/yf_dir.class.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

    yf_dir has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class yf_dir
    {
        /** @var bool */
        public $CHECK_IF_READABLE = true;
        /** @var bool */
    Severity: Minor
    Found in classes/yf_dir.class.php - About 3 hrs to fix

      Method _skip_by_pattern has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function _skip_by_pattern($path = '', $_is_dir = false, $pattern_include = '', $pattern_exclude = '')
          {
              if ( ! $path) {
                  return false;
              }
      Severity: Major
      Found in classes/yf_dir.class.php - About 2 hrs to fix

        Function copy_dir has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public function copy_dir($path1, $path2, $pattern_include = '', $pattern_exclude = '', $level = null)
            {
                if ( ! $path1 || ! file_exists($path1)) {
                    return false;
                }
        Severity: Minor
        Found in classes/yf_dir.class.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

        Function grep has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public function grep($pattern_find, $start_dirs, $pattern_path = '*', $extra = [])
            {
                if ( ! $pattern_find) {
                    return false;
                }
        Severity: Minor
        Found in classes/yf_dir.class.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

        Function scan_dir has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public function scan_dir($start_dir, $_tmp = 1, $pattern_include = '', $pattern_exclude = '')
            {
                $func = __FUNCTION__;
                // Here we accept several start folders, result will be merged
                if (is_array($start_dir)) {
        Severity: Minor
        Found in classes/yf_dir.class.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

        Function replace has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public function replace($start_dirs, $pattern_include = '', $pattern_exclude = '', $pattern_find, $pattern_replace)
            {
                $files = [];
                if ( ! is_array($start_dirs)) {
                    $start_dirs = [$start_dirs];
        Severity: Minor
        Found in classes/yf_dir.class.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

        Function move_dir has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            public function move_dir($path1, $path2, $pattern_include = '', $pattern_exclude = '')
            {
                if ( ! $path1 || ! file_exists($path1)) {
                    return false;
                }
        Severity: Minor
        Found in classes/yf_dir.class.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 mkdir_m has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function mkdir_m($dir_name, $dir_mode = 0755, $create_index_htmls = 0, $start_folder = '')
            {
                if ( ! $dir_name || ! strlen($dir_name)) {
                    return 0;
                }
        Severity: Minor
        Found in classes/yf_dir.class.php - About 1 hr to fix

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

              public function tail($file, $lines = 10)
              {
                  if ( ! $file || ! file_exists($file)) {
                      return false;
                  }
          Severity: Minor
          Found in classes/yf_dir.class.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 search has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function search($start_dirs, $pattern_include = '', $pattern_exclude = '', $pattern_find)
              {
                  if ( ! is_array($start_dirs)) {
                      $start_dirs = [$start_dirs];
                  }
          Severity: Minor
          Found in classes/yf_dir.class.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 dirsize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function dirsize($start_dir, $pattern_include = '', $pattern_exclude = '')
              {
                  if ( ! $start_dir || ! file_exists($start_dir)) {
                      return false;
                  }
          Severity: Minor
          Found in classes/yf_dir.class.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 count_files has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function count_files($start_dir, $pattern_include = '', $pattern_exclude = '')
              {
                  if ( ! $start_dir || ! file_exists($start_dir)) {
                      return false;
                  }
          Severity: Minor
          Found in classes/yf_dir.class.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 grep has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function grep($pattern_find, $start_dirs, $pattern_path = '*', $extra = [])
              {
                  if ( ! $pattern_find) {
                      return false;
                  }
          Severity: Minor
          Found in classes/yf_dir.class.php - About 1 hr to fix

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

                public function replace($start_dirs, $pattern_include = '', $pattern_exclude = '', $pattern_find, $pattern_replace)
                {
                    $files = [];
                    if ( ! is_array($start_dirs)) {
                        $start_dirs = [$start_dirs];
            Severity: Minor
            Found in classes/yf_dir.class.php - About 1 hr to fix

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

                  public function copy_dir($path1, $path2, $pattern_include = '', $pattern_exclude = '', $level = null)
                  {
                      if ( ! $path1 || ! file_exists($path1)) {
                          return false;
                      }
              Severity: Minor
              Found in classes/yf_dir.class.php - About 1 hr to fix

                Method scan_dir has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function scan_dir($start_dir, $_tmp = 1, $pattern_include = '', $pattern_exclude = '')
                    {
                        $func = __FUNCTION__;
                        // Here we accept several start folders, result will be merged
                        if (is_array($start_dir)) {
                Severity: Minor
                Found in classes/yf_dir.class.php - About 1 hr to fix

                  Function delete_dir has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function delete_dir($start_dir, $delete_start_dir = false)
                      {
                          if ( ! $start_dir || ! file_exists($start_dir)) {
                              return false;
                          }
                  Severity: Minor
                  Found in classes/yf_dir.class.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 chmod_dir has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function chmod_dir($start_dir, $new_mode = 0755, $pattern_include = '', $pattern_exclude = '')
                      {
                          if ( ! $start_dir || ! file_exists($start_dir) || empty($new_mode)) {
                              return false;
                          }
                  Severity: Minor
                  Found in classes/yf_dir.class.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 scan_fast has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function scan_fast($start_dir, $pattern = '~.+~')
                      {
                          $files = [];
                          $dh = @opendir($start_dir);
                          if ( ! $dh) {
                  Severity: Minor
                  Found in classes/yf_dir.class.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 move_dir has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function move_dir($path1, $path2, $pattern_include = '', $pattern_exclude = '')
                      {
                          if ( ! $path1 || ! file_exists($path1)) {
                              return false;
                          }
                  Severity: Minor
                  Found in classes/yf_dir.class.php - About 1 hr to fix

                    Method tail has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function tail($file, $lines = 10)
                        {
                            if ( ! $file || ! file_exists($file)) {
                                return false;
                            }
                    Severity: Minor
                    Found in classes/yf_dir.class.php - About 1 hr to fix

                      Method search has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function search($start_dirs, $pattern_include = '', $pattern_exclude = '', $pattern_find)
                          {
                              if ( ! is_array($start_dirs)) {
                                  $start_dirs = [$start_dirs];
                              }
                      Severity: Minor
                      Found in classes/yf_dir.class.php - About 1 hr to fix

                        Method delete_dir has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function delete_dir($start_dir, $delete_start_dir = false)
                            {
                                if ( ! $start_dir || ! file_exists($start_dir)) {
                                    return false;
                                }
                        Severity: Minor
                        Found in classes/yf_dir.class.php - About 1 hr to fix

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

                              public function copy($path1, $path2, $pattern_include = '', $pattern_exclude = '', $level = null)
                          Severity: Minor
                          Found in classes/yf_dir.class.php - About 35 mins to fix

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

                                public function copy_dir($path1, $path2, $pattern_include = '', $pattern_exclude = '', $level = null)
                            Severity: Minor
                            Found in classes/yf_dir.class.php - About 35 mins to fix

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

                                  public function _gen_dir_path($id, $path = '', $make = false, $dir_mode = 0755, $create_index_htmls = 1)
                              Severity: Minor
                              Found in classes/yf_dir.class.php - About 35 mins to fix

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

                                    public function replace($start_dirs, $pattern_include = '', $pattern_exclude = '', $pattern_find, $pattern_replace)
                                Severity: Minor
                                Found in classes/yf_dir.class.php - About 35 mins to fix

                                  Function rglob has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function rglob($folder, $pattern = '*')
                                      {
                                          $folder = rtrim($folder, '/');
                                          if (false === strpos($pattern, '[')) {
                                              $pattern = $this->_sql_regcase($pattern);
                                  Severity: Minor
                                  Found in classes/yf_dir.class.php - 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

                                  Avoid too many return statements within this method.
                                  Open

                                              return -2;
                                  Severity: Major
                                  Found in classes/yf_dir.class.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return 0;
                                    Severity: Major
                                    Found in classes/yf_dir.class.php - About 30 mins to fix

                                      There are no issues that match your filters.

                                      Category
                                      Status