stk2k/file-system

View on GitHub

Showing 11 of 17 total issues

Function put has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    public function put($contents, bool $ex_lock = false) : self
    {
        if (!is_string($contents)){
            if (is_array($contents)){
                $contents = implode(PHP_EOL, $contents);
Severity: Minor
Found in src/File.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

File has 36 functions (exceeds 20 allowed). Consider refactoring.
Open

class File
{
    const DS = DIRECTORY_SEPARATOR;

    const MAKEDIRECTORY_DEFAULT_MODE = 0777;
Severity: Minor
Found in src/File.php - About 4 hrs to fix

    Function write has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function write(string $filename, array $data, string $line_end = "\r\n")
        {
            $fp = fopen($filename, 'w');
            if (!$fp){
                throw new FileOpenException(new File($filename));
    Severity: Minor
    Found in src/Util/IniFileWriter.php - About 4 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 listFiles has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        public function listFiles( $filter = null ) : array
        {
            $path = $this->path;
    
            if ( !file_exists($path) )    return [];
    Severity: Minor
    Found in src/File.php - About 4 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

    FileSystem has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class FileSystem
    {
        /**
         * Returns file hash
         *
    Severity: Minor
    Found in src/FileSystem.php - About 4 hrs to fix

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

      <?php
      declare(strict_types=1);
      
      namespace stk2k\filesystem;
      
      
      Severity: Minor
      Found in src/File.php - About 2 hrs to fix

        Method write has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function write(string $filename, array $data, string $line_end = "\r\n")
            {
                $fp = fopen($filename, 'w');
                if (!$fp){
                    throw new FileOpenException(new File($filename));
        Severity: Minor
        Found in src/Util/IniFileWriter.php - About 1 hr to fix

          Method listFiles has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function listFiles( $filter = null ) : array
              {
                  $path = $this->path;
          
                  if ( !file_exists($path) )    return [];
          Severity: Minor
          Found in src/File.php - About 1 hr to fix

            Method put has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function put($contents, bool $ex_lock = false) : self
                {
                    if (!is_string($contents)){
                        if (is_array($contents)){
                            $contents = implode(PHP_EOL, $contents);
            Severity: Minor
            Found in src/File.php - About 1 hr to fix

              Function rmdirRecursive has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function rmdirRecursive() : self
                  {
                      if ( !file_exists($this->path) ){
                          return $this;
                      }
              Severity: Minor
              Found in src/File.php - About 55 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 mkdir has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function mkdir(int $mode = self::MAKEDIRECTORY_DEFAULT_MODE) : self
                  {
                      if ( file_exists($this->path) ){
                          if ( is_file($this->path) ){
                              throw new MakeDirectoryException($this);
              Severity: Minor
              Found in src/File.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

              Severity
              Category
              Status
              Source
              Language