chdemko/php-sorted-collections

View on GitHub

Showing 69 of 69 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if ($ceiling) {
            switch ($this->fromOption) {
                case self::INCLUSIVE:
                    if (call_user_func($this->map->comparator(), $ceiling->key, $this->fromKey) < 0) {
                          $ceiling = $this->first();
Severity: Major
Found in src/SortedCollection/SubMap.php and 1 other location - About 1 hr to fix
src/SortedCollection/SubMap.php on lines 747..760

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 109.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if ($higher) {
            switch ($this->fromOption) {
                case self::INCLUSIVE:
                    if (call_user_func($this->map->comparator(), $higher->key, $this->fromKey) < 0) {
                          $higher = $this->first();
Severity: Major
Found in src/SortedCollection/SubMap.php and 1 other location - About 1 hr to fix
src/SortedCollection/SubMap.php on lines 692..705

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 109.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if ($lower) {
            switch ($this->toOption) {
                case self::INCLUSIVE:
                    if (call_user_func($this->map->comparator(), $lower->key, $this->toKey) > 0) {
                          $lower = $this->last();
Severity: Major
Found in src/SortedCollection/SubMap.php and 1 other location - About 1 hr to fix
src/SortedCollection/SubMap.php on lines 595..608

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 109.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if ($floor) {
            switch ($this->toOption) {
                case self::INCLUSIVE:
                    if (call_user_func($this->map->comparator(), $floor->key, $this->toKey) > 0) {
                          $floor = $this->last();
Severity: Major
Found in src/SortedCollection/SubMap.php and 1 other location - About 1 hr to fix
src/SortedCollection/SubMap.php on lines 540..553

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 109.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function __set has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function __set($property, $value)
    {
        switch ($property) {
            case 'fromKey':
                $this->fromKey = $value;
Severity: Minor
Found in src/SortedCollection/SubMap.php - About 1 hr 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 __set has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __set($property, $value)
    {
        switch ($property) {
            case 'fromKey':
                $this->fromKey = $value;
Severity: Minor
Found in src/SortedCollection/SubMap.php - About 1 hr to fix

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

        public function insert($key, $value, $comparator)
        {
            $node = $this;
            $cmp = call_user_func($comparator, $key, $this->key);
    
    
    Severity: Minor
    Found in src/SortedCollection/TreeNode.php - About 1 hr to fix

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

          public function __get($property)
          {
              switch ($property) {
                  case 'fromKey':
                      if ($this->fromOption == self::UNUSED) {
      Severity: Minor
      Found in src/SortedCollection/SubMap.php - About 1 hr to fix

        Function data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function data($params)
            {
                if (isset($params['type'])) {
                    switch ($params['type']) {
                        case 'tree':
        Severity: Minor
        Found in benchmarks/TreeMapBench.php - About 1 hr 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 find has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function find($key)
            {
                switch ($this->fromOption) {
                    case self::INCLUSIVE:
                        if (call_user_func($this->map->comparator(), $key, $this->fromKey) < 0) {
        Severity: Minor
        Found in src/SortedCollection/SubMap.php - About 1 hr 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 data has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function data($params)
            {
                if (isset($params['type'])) {
                    switch ($params['type']) {
                        case 'tree':
        Severity: Minor
        Found in benchmarks/TreeMapBench.php - About 1 hr to fix

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

              public function __get($property)
              {
                  switch ($property) {
                      case 'fromKey':
                          if ($this->fromOption == self::UNUSED) {
          Severity: Minor
          Found in src/SortedCollection/SubMap.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 successor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function successor($element)
              {
                  $successor = $this->map->successor($element);
          
                  if ($successor) {
          Severity: Minor
          Found in src/SortedCollection/SubMap.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 jsonSerialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function jsonSerialize(): array
              {
                  if (isset($this->from)) {
                      if (isset($this->to)) {
                          return array(
          Severity: Minor
          Found in src/SortedCollection/SubSet.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 jsonSerialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function jsonSerialize(): array
              {
                  if ($this->fromOption == self::UNUSED) {
                      if ($this->toOption == self::UNUSED) {
                          return array(
          Severity: Minor
          Found in src/SortedCollection/SubMap.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 predecessor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function predecessor($element)
              {
                  $predecessor = $this->map->predecessor($element);
          
                  if ($predecessor) {
          Severity: Minor
          Found in src/SortedCollection/SubMap.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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              public function first()
              {
                  if ($this->empty) {
                      throw new \OutOfBoundsException('First element unexisting');
                  }
          Severity: Minor
          Found in src/SortedCollection/SubMap.php and 1 other location - About 45 mins to fix
          src/SortedCollection/SubMap.php on lines 416..435

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 95.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              public function last()
              {
                  if ($this->empty) {
                      throw new \OutOfBoundsException('Last element unexisting');
                  }
          Severity: Minor
          Found in src/SortedCollection/SubMap.php and 1 other location - About 45 mins to fix
          src/SortedCollection/SubMap.php on lines 386..405

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 95.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  } elseif ($cmp > 0) {
                      if ($this->information & 1) {
                          $rightBalance = $this->right->information & ~3;
                          $this->right = $this->right->remove($key, $comparator);
          
          
          Severity: Minor
          Found in src/SortedCollection/TreeNode.php and 1 other location - About 40 mins to fix
          src/SortedCollection/TreeNode.php on lines 520..568

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 94.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  if ($cmp < 0) {
                      if ($this->information & 2) {
                          $leftBalance = $this->left->information & ~3;
                          $this->left = $this->left->remove($key, $comparator);
          
          
          Severity: Minor
          Found in src/SortedCollection/TreeNode.php and 1 other location - About 40 mins to fix
          src/SortedCollection/TreeNode.php on lines 529..538

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 94.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language