gdbots/common-php

View on GitHub

Showing 16 of 137 total issues

Function create has a Cognitive Complexity of 272 (exceeds 5 allowed). Consider refactoring.
Open

    public static function create($string, $allowSlashes = false)
    {
        $slug = '';
        $string = html_entity_decode($string, ENT_QUOTES);

Severity: Minor
Found in src/Common/Util/SlugUtils.php - About 5 days 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 xmlEscape has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    public static function xmlEscape($str)
    {
        // array used to figure what number to decrement from character order value
        // according to number of characters used to map unicode to ascii by utf-8
        $decrement = [];
Severity: Minor
Found in src/Common/Util/StringUtils.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 URLUtils.php has 310 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Gdbots\Common\Util;

final class URLUtils
Severity: Minor
Found in src/Common/Util/URLUtils.php - About 3 hrs to fix

    Method xmlEscape has 79 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function xmlEscape($str)
        {
            // array used to figure what number to decrement from character order value
            // according to number of characters used to map unicode to ascii by utf-8
            $decrement = [];
    Severity: Major
    Found in src/Common/Util/StringUtils.php - About 3 hrs to fix

      Method create has 79 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function create($string, $allowSlashes = false)
          {
              $slug = '';
              $string = html_entity_decode($string, ENT_QUOTES);
      
      
      Severity: Major
      Found in src/Common/Util/SlugUtils.php - About 3 hrs to fix

        Consider simplifying this complex logical expression.
        Open

                    } else if (($c >= 8219 && $c <= 8223) || $c == 8242 || $c == 8243 || $c == 8216 || $c == 8217 || $c == 168 || $c == 180 || $c == 729 || $c == 733) {
                        //all the strange curly single and double quotes
                        // Ignore them
                    } else if ($c == 188) {
                        $slug .= '-one-quarter-';
        Severity: Critical
        Found in src/Common/Util/SlugUtils.php - About 2 hrs to fix

          Method create has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function create($str, $camelize = true)
              {
                  // remove special chars (accents, etc.)
                  $str = trim(self::normalize($str));
                  $str = ltrim($str, '#_ ');
          Severity: Minor
          Found in src/Common/Util/HashtagUtils.php - About 1 hr to fix

            Function varToString has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function varToString($var)
                {
                    if (is_object($var)) {
                        return sprintf('Object(%s)', get_class($var));
                    }
            Severity: Minor
            Found in src/Common/Util/StringUtils.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

            Function create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function create($str, $camelize = true)
                {
                    // remove special chars (accents, etc.)
                    $str = trim(self::normalize($str));
                    $str = ltrim($str, '#_ ');
            Severity: Minor
            Found in src/Common/Util/HashtagUtils.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

            Consider simplifying this complex logical expression.
            Open

                        if (($c >= 224 && $c <= 229) || ($c >= 192 && $c <= 198) || ($c >= 281 && $c <= 286)) {
                            $slug .= 'a';
                        } else if (($c >= 232 && $c <= 235) || ($c >= 200 && $c <= 203)) {
                            $slug .= 'e';
                        } else if (($c >= 236 && $c <= 239) || ($c >= 204 && $c <= 207)) {
            Severity: Major
            Found in src/Common/Util/SlugUtils.php - About 40 mins to fix

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

                  public static function isValid($hashtag)
                  {
                      $hashtag = ltrim($hashtag, '#');
                      if (empty($hashtag)) {
                          return false;
              Severity: Minor
              Found in src/Common/Util/HashtagUtils.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 false;
              Severity: Major
              Found in src/Common/Util/HashtagUtils.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return (string)$var;
                Severity: Major
                Found in src/Common/Util/StringUtils.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return true;
                  Severity: Major
                  Found in src/Common/Util/HashtagUtils.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return 'false';
                    Severity: Major
                    Found in src/Common/Util/StringUtils.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return 'true';
                      Severity: Major
                      Found in src/Common/Util/StringUtils.php - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language