swaggest/json-diff

View on GitHub

Showing 32 of 32 total issues

Function add has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
Open

    public static function add(&$holder, $pathItems, $value, $flags = self::RECURSIVE_KEY_CREATION)
    {
        $ref = &$holder;
        while (null !== $key = array_shift($pathItems)) {
            if ($ref instanceof \stdClass || is_object($ref)) {
Severity: Minor
Found in src/JsonPointer.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

Function process has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

    private function process($original, $new)
    {
        $merge = !($this->options & self::SKIP_JSON_MERGE_PATCH);

        if ($this->options & self::TOLERATE_ASSOCIATIVE_ARRAYS) {
Severity: Minor
Found in src/JsonDiff.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

Function rearrangeArray has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

    private function rearrangeArray(array $original, array $new)
    {
        $first = reset($original);
        if (!$first instanceof \stdClass) {
            return $this->rearrangeEqualItems($original, $new);
Severity: Minor
Found in src/JsonDiff.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

Function remove has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    public static function remove(&$holder, $pathItems, $flags = 0)
    {
        $ref = &$holder;
        while (null !== $key = array_shift($pathItems)) {
            $parent = &$ref;
Severity: Minor
Found in src/JsonPointer.php - About 6 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 import has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public static function import(array $data)
    {
        $result = new JsonPatch();
        foreach ($data as $operation) {
            /** @var OpPath|OpPathValue|OpPathFrom|array $operation */
Severity: Minor
Found in src/JsonPatch.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

Method process has 113 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function process($original, $new)
    {
        $merge = !($this->options & self::SKIP_JSON_MERGE_PATCH);

        if ($this->options & self::TOLERATE_ASSOCIATIVE_ARRAYS) {
Severity: Major
Found in src/JsonDiff.php - About 4 hrs to fix

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

    <?php
    
    namespace Swaggest\JsonDiff;
    
    use Swaggest\JsonDiff\JsonPatch\Add;
    Severity: Minor
    Found in src/JsonDiff.php - About 4 hrs to fix

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

          public function xorHash($data, $path = '')
          {
              $xorHash = '';
      
              if (!$data instanceof \stdClass && !is_array($data)) {
      Severity: Minor
      Found in src/JsonHash.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

      Method rearrangeArray has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function rearrangeArray(array $original, array $new)
          {
              $first = reset($original);
              if (!$first instanceof \stdClass) {
                  return $this->rearrangeEqualItems($original, $new);
      Severity: Major
      Found in src/JsonDiff.php - About 3 hrs to fix

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

            public static function get($holder, $pathItems)
            {
                $ref = $holder;
                while (null !== $key = array_shift($pathItems)) {
                    if ($ref instanceof \stdClass) {
        Severity: Minor
        Found in src/JsonPointer.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

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

            public function apply(&$original, $stopOnError = true)
            {
                $errors = array();
                foreach ($this->operations as $opIndex => $operation) {
                    try {
        Severity: Minor
        Found in src/JsonPatch.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 apply has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function apply(&$original, $stopOnError = true)
            {
                $errors = array();
                foreach ($this->operations as $opIndex => $operation) {
                    try {
        Severity: Major
        Found in src/JsonPatch.php - About 2 hrs to fix

          Method init has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              static function init()
              {
                  self::$simpleOriginal = (object)(array("root" => (object)array("a" => 1, "b" => 2)));
                  self::$simpleNew = (object)(array("root" => (object)array("b" => 3, "c" => 4)));
                  self::$original = json_decode(<<<'JSON'
          Severity: Major
          Found in benchmarks/DiffBench.php - About 2 hrs to fix

            Method import has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function import(array $data)
                {
                    $result = new JsonPatch();
                    foreach ($data as $operation) {
                        /** @var OpPath|OpPathValue|OpPathFrom|array $operation */
            Severity: Major
            Found in src/JsonPatch.php - About 2 hrs to fix

              Method add has 60 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function add(&$holder, $pathItems, $value, $flags = self::RECURSIVE_KEY_CREATION)
                  {
                      $ref = &$holder;
                      while (null !== $key = array_shift($pathItems)) {
                          if ($ref instanceof \stdClass || is_object($ref)) {
              Severity: Major
              Found in src/JsonPointer.php - About 2 hrs to fix

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

                    public static function apply(&$original, $patch)
                    {
                        if (null === $patch) {
                            $original = null;
                        } elseif (is_object($patch)) {
                Severity: Minor
                Found in src/JsonMergePatch.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 xorHash has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function xorHash($data, $path = '')
                    {
                        $xorHash = '';
                
                        if (!$data instanceof \stdClass && !is_array($data)) {
                Severity: Minor
                Found in src/JsonHash.php - About 1 hr to fix

                  Method remove has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function remove(&$holder, $pathItems, $flags = 0)
                      {
                          $ref = &$holder;
                          while (null !== $key = array_shift($pathItems)) {
                              $parent = &$ref;
                  Severity: Minor
                  Found in src/JsonPointer.php - About 1 hr to fix

                    Method process has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function process($data)
                        {
                            $check = true;
                            if ($this->pathFilterRegex && !preg_match($this->pathFilterRegex, $this->path)) {
                                $check = false;
                    Severity: Minor
                    Found in src/JsonValueReplace.php - About 1 hr to fix

                      Method rearrangeEqualItems has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function rearrangeEqualItems(array $original, array $new)
                          {
                              if ($this->jsonHash === null) {
                                  $this->jsonHash = new JsonHash($this->options);
                              }
                      Severity: Minor
                      Found in src/JsonDiff.php - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language