labo86/staty

View on GitHub

Showing 6 of 6 total issues

Function cleanTarget has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function cleanTarget(string $filename) {
        if ( is_link($filename) ) {
            if ( !unlink($filename) ) {
                throw new ExceptionWithData(ErrMsg::ERROR_UNLINKING_SYMLINK,
                    [
Severity: Minor
Found in src/PageSymlink.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 cleanTarget has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function cleanTarget(string $filename) {
        if ( is_link($filename) ) {
            if ( !unlink($filename) ) {
                throw new ExceptionWithData(ErrMsg::ERROR_UNLINKING_SYMLINK,
                    [
Severity: Minor
Found in src/PageSymlink.php - About 1 hr to fix

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

        public function generate(string $filename) {
    
            $img = Image::createFromFile($this->source->getFilename(), $this->width ?? 1000);
    
            if ( $this->resize_mode == self::RESIZE_MODE_CONTAIN ) {
    Severity: Minor
    Found in src/PageImage.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 getNormalizedPath has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getNormalizedPath(string $path) {
            $path = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path);
    
            /** se separa por el separador de directorio */
            $parts = explode(DIRECTORY_SEPARATOR, $path);
    Severity: Minor
    Found in modules/core/src/Util.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

    Avoid too many return statements within this method.
    Open

            return implode(DIRECTORY_SEPARATOR, $dir_stack);
    Severity: Major
    Found in modules/core/src/Util.php - About 30 mins to fix

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

          public function sprintf(string $str, ...$args) : string {
              foreach ( $args as &$arg ) {
                  if ( is_null($arg) ) return "";
                  if ( is_string($arg))
                      $arg = htmlentities($arg);
      Severity: Minor
      Found in src/Block.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