wp-plugins/all-in-one-seo-pack

View on GitHub
JSON.php

Summary

Maintainability
F
6 days
Test Coverage

Function decode has a Cognitive Complexity of 88 (exceeds 5 allowed). Consider refactoring.
Open

    function decode($str)
    {
        $str = $this->reduce_string($str);

        switch (strtolower($str)) {
Severity: Minor
Found in JSON.php - About 1 day 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 decode has 171 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function decode($str)
    {
        $str = $this->reduce_string($str);

        switch (strtolower($str)) {
Severity: Major
Found in JSON.php - About 6 hrs to fix

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

    <?php
    /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
    
    /**
     * Converts to and from JSON format.
    Severity: Minor
    Found in JSON.php - About 5 hrs to fix

      Method encode has 121 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function encode($var)
          {
              switch (gettype($var)) {
                  case 'boolean':
                      return $var ? 'true' : 'false';
      Severity: Major
      Found in JSON.php - About 4 hrs to fix

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

            function encode($var)
            {
                switch (gettype($var)) {
                    case 'boolean':
                        return $var ? 'true' : 'false';
        Severity: Minor
        Found in JSON.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

        Consider simplifying this complex logical expression.
        Open

                                if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
                                    // found a comma that is not inside a string, array, etc.,
                                    // OR we've reached the end of the character list
                                    $slice = substr($chrs, $top['where'], ($c - $top['where']));
                                    array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
        Severity: Critical
        Found in JSON.php - About 3 hrs to fix

          Avoid deeply nested control flow statements.
          Open

                                      if (reset($stk) == SERVICES_JSON_IN_ARR) {
                                          // we are in an array, so just push an element onto the stack
                                          array_push($arr, $this->decode($slice));
          
                                      } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
          Severity: Major
          Found in JSON.php - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                            if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
                                               ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
                                                $utf8 .= $chrs{++$c};
                                            }
            Severity: Major
            Found in JSON.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          for ($i = $top['where']; $i <= $c; ++$i)
                                              $chrs = substr_replace($chrs, ' ', $i, 1);
              Severity: Major
              Found in JSON.php - About 45 mins to fix

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

                        function Services_JSON_Error($message = 'unknown error', $code = null,
                                                     $mode = null, $options = null, $userinfo = null)
                Severity: Minor
                Found in JSON.php - About 35 mins to fix

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

                          function Services_JSON_Error($message = 'unknown error', $code = null,
                                                       $mode = null, $options = null, $userinfo = null)
                  Severity: Minor
                  Found in JSON.php - About 35 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
                                        ? 'null'
                                        : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
                    Severity: Major
                    Found in JSON.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return '{' . join(',', $properties) . '}';
                      Severity: Major
                      Found in JSON.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return $utf8;
                        Severity: Major
                        Found in JSON.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                                      return $obj;
                          Severity: Major
                          Found in JSON.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                return '{' . join(',', $properties) . '}';
                            Severity: Major
                            Found in JSON.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                          return $property;
                              Severity: Major
                              Found in JSON.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                            return $arr;
                                Severity: Major
                                Found in JSON.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                          return '';
                                  Severity: Major
                                  Found in JSON.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                            return $element;
                                    Severity: Major
                                    Found in JSON.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                              return '';
                                      Severity: Major
                                      Found in JSON.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                                return $property;
                                        Severity: Major
                                        Found in JSON.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                                  return $arr;
                                          Severity: Major
                                          Found in JSON.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                            return '[' . join(',', $elements) . ']';
                                            Severity: Major
                                            Found in JSON.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                                      return $obj;
                                              Severity: Major
                                              Found in JSON.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                return '"'.$ascii.'"';
                                                Severity: Major
                                                Found in JSON.php - About 30 mins to fix

                                                  There are no issues that match your filters.

                                                  Category
                                                  Status