symphonycms/symphony-2

View on GitHub
symphony/lib/toolkit/class.entryquery.php

Summary

Maintainability
F
3 days
Test Coverage

File class.entryquery.php has 350 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * @package toolkit
 */
Severity: Minor
Found in symphony/lib/toolkit/class.entryquery.php - About 4 hrs to fix

    Function filter has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        public function filter($field, array $values, $operator = 'or')
        {
            General::ensureType([
                'operator' => ['var' => $operator, 'type' => 'string'],
            ]);
    Severity: Minor
    Found in symphony/lib/toolkit/class.entryquery.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 sort has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public function sort($field, $direction = 'ASC')
        {
            General::ensureType([
                'field' => ['var' => $field, 'type' => 'string'],
                'direction' => ['var' => $direction, 'type' => 'string'],
    Severity: Minor
    Found in symphony/lib/toolkit/class.entryquery.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 filter has 79 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function filter($field, array $values, $operator = 'or')
        {
            General::ensureType([
                'operator' => ['var' => $operator, 'type' => 'string'],
            ]);
    Severity: Major
    Found in symphony/lib/toolkit/class.entryquery.php - About 3 hrs to fix

      EntryQuery has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class EntryQuery extends DatabaseQuery
      {
          /**
           * The requested schema. Items names must the the fields' labels.
           * @var array
      Severity: Minor
      Found in symphony/lib/toolkit/class.entryquery.php - About 3 hrs to fix

        Method sort has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function sort($field, $direction = 'ASC')
            {
                General::ensureType([
                    'field' => ['var' => $field, 'type' => 'string'],
                    'direction' => ['var' => $direction, 'type' => 'string'],
        Severity: Major
        Found in symphony/lib/toolkit/class.entryquery.php - About 2 hrs to fix

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

              public function finalize()
              {
                  // Get a flatten projection
                  $projection = $this->getSQLParts('projection');
                  General::flattenArray($projection);
          Severity: Minor
          Found in symphony/lib/toolkit/class.entryquery.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

          Avoid too many return statements within this method.
          Open

                  return $this;
          Severity: Major
          Found in symphony/lib/toolkit/class.entryquery.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return $this;
            Severity: Major
            Found in symphony/lib/toolkit/class.entryquery.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return array_merge($memo, array_map(function ($val) {
                                  $val = General::intval($val);
              
                                  // General::intval can return -1, so reset that to 0
                                  // so there are no side effects for the following
              Severity: Major
              Found in symphony/lib/toolkit/class.entryquery.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return ['e.id' => [$op => $v]];
                Severity: Major
                Found in symphony/lib/toolkit/class.entryquery.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return $this->where($conditions);
                  Severity: Major
                  Found in symphony/lib/toolkit/class.entryquery.php - About 30 mins to fix

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

                        public function joinField($field_id)
                        {
                            General::ensureType([
                                'field_id' => ['var' => $field_id, 'type' => 'int'],
                            ]);
                    Severity: Major
                    Found in symphony/lib/toolkit/class.entryquery.php and 4 other locations - About 45 mins to fix
                    symphony/lib/toolkit/class.entryquery.php on lines 256..268
                    symphony/lib/toolkit/class.entryquery.php on lines 304..316
                    symphony/lib/toolkit/class.entryquery.php on lines 328..340
                    symphony/lib/toolkit/class.entryquery.php on lines 352..364

                    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 5 locations. Consider refactoring.
                    Open

                        public function leftJoinField($field_id)
                        {
                            General::ensureType([
                                'field_id' => ['var' => $field_id, 'type' => 'int'],
                            ]);
                    Severity: Major
                    Found in symphony/lib/toolkit/class.entryquery.php and 4 other locations - About 45 mins to fix
                    symphony/lib/toolkit/class.entryquery.php on lines 256..268
                    symphony/lib/toolkit/class.entryquery.php on lines 280..292
                    symphony/lib/toolkit/class.entryquery.php on lines 328..340
                    symphony/lib/toolkit/class.entryquery.php on lines 352..364

                    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 5 locations. Consider refactoring.
                    Open

                        public function innerJoinField($field_id)
                        {
                            General::ensureType([
                                'field_id' => ['var' => $field_id, 'type' => 'int'],
                            ]);
                    Severity: Major
                    Found in symphony/lib/toolkit/class.entryquery.php and 4 other locations - About 45 mins to fix
                    symphony/lib/toolkit/class.entryquery.php on lines 280..292
                    symphony/lib/toolkit/class.entryquery.php on lines 304..316
                    symphony/lib/toolkit/class.entryquery.php on lines 328..340
                    symphony/lib/toolkit/class.entryquery.php on lines 352..364

                    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 5 locations. Consider refactoring.
                    Open

                        public function outerJoinField($field_id)
                        {
                            General::ensureType([
                                'field_id' => ['var' => $field_id, 'type' => 'int'],
                            ]);
                    Severity: Major
                    Found in symphony/lib/toolkit/class.entryquery.php and 4 other locations - About 45 mins to fix
                    symphony/lib/toolkit/class.entryquery.php on lines 256..268
                    symphony/lib/toolkit/class.entryquery.php on lines 280..292
                    symphony/lib/toolkit/class.entryquery.php on lines 304..316
                    symphony/lib/toolkit/class.entryquery.php on lines 352..364

                    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 5 locations. Consider refactoring.
                    Open

                        public function rightJoinField($field_id)
                        {
                            General::ensureType([
                                'field_id' => ['var' => $field_id, 'type' => 'int'],
                            ]);
                    Severity: Major
                    Found in symphony/lib/toolkit/class.entryquery.php and 4 other locations - About 45 mins to fix
                    symphony/lib/toolkit/class.entryquery.php on lines 256..268
                    symphony/lib/toolkit/class.entryquery.php on lines 280..292
                    symphony/lib/toolkit/class.entryquery.php on lines 304..316
                    symphony/lib/toolkit/class.entryquery.php on lines 328..340

                    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

                    There are no issues that match your filters.

                    Category
                    Status