Showing 30 of 70 total issues

Function parseValue has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring.
Open

    protected static function parseValue($json, &$pos, $assoc = false, $variables = [], $options = 0)
    {
        $length = strlen($json);
        $result = '';

Severity: Minor
Found in src/LJSON.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 parseValue has 211 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected static function parseValue($json, &$pos, $assoc = false, $variables = [], $options = 0)
    {
        $length = strlen($json);
        $result = '';

Severity: Major
Found in src/LJSON.php - About 1 day to fix

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

<?php
namespace LJSON;

/**
 * Class LJSON
Severity: Minor
Found in src/LJSON.php - About 4 hrs to fix

Function stringify has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public static function stringify($value, $parameterCount = 0)
    {
        if (is_null($value) || is_bool($value)
            || is_int($value) || is_float($value) || is_double($value) || is_numeric($value)
            || is_string($value)
Severity: Minor
Found in src/LJSON.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

Method stringify has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function stringify($value, $parameterCount = 0)
    {
        if (is_null($value) || is_bool($value)
            || is_int($value) || is_float($value) || is_double($value) || is_numeric($value)
            || is_string($value)
Severity: Major
Found in src/LJSON.php - About 2 hrs to fix

Consider simplifying this complex logical expression.
Open

        if (is_null($value) || is_bool($value)
            || is_int($value) || is_float($value) || is_double($value) || is_numeric($value)
            || is_string($value)
        ) {
            return json_encode($value);
Severity: Major
Found in src/LJSON.php - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

                        if (strlen($use) > 0) {
                            $use = 'use(' . $use . ')';
                        }
Severity: Major
Found in src/LJSON.php - About 45 mins to fix

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

    public function __construct($message, $file, $line, $code = 0, $previous = null)
Severity: Minor
Found in src/StringifyException.php - About 35 mins to fix

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

    protected static function parseValue($json, &$pos, $assoc = false, $variables = [], $options = 0)
Severity: Minor
Found in src/LJSON.php - About 35 mins to fix

Avoid too many return statements within this method.
Open

                    return $parameter1 / $parameter2;
Severity: Major
Found in src/LJSON.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return '"' . str_replace('"', '\"', $result) . '"';
Severity: Major
Found in src/LJSON.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return '[]';
Severity: Major
Found in src/LJSON.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                    return $result;
Severity: Major
Found in src/LJSON.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

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

Avoid too many return statements within this method.
Open

                return rtrim($result, ',') . '}';
Severity: Major
Found in src/LJSON.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return $result;
Severity: Major
Found in src/LJSON.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return '[' . implode(',', $value) . ']';
Severity: Major
Found in src/LJSON.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return $value->getParameterResult();
Severity: Major
Found in src/LJSON.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                    return $parameter1 * $parameter2;
Severity: Major
Found in src/LJSON.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return "false";
Severity: Major
Found in src/LJSON.php - About 30 mins to fix
Severity
Category
Status
Source
Language