symphonycms/symphony-2

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

Summary

Maintainability
F
1 wk
Test Coverage

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

<?php
/**
 * @package toolkit
 */
/**
Severity: Major
Found in symphony/lib/toolkit/class.field.php - About 2 days to fix

    Field has 80 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Field implements ArrayAccess
    {
        /**
         * The desired result when creating a field in the section editor
         * @var integer
    Severity: Major
    Found in symphony/lib/toolkit/class.field.php - About 1 day to fix

      Function appendAssociationInterfaceSelect has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function appendAssociationInterfaceSelect(XMLElement &$wrapper)
          {
              $wrapper->setAttribute('data-condition', 'associative');
      
              $interfaces = Symphony::ExtensionManager()->getProvidersOf(iProvider::ASSOCIATION_UI);
      Severity: Minor
      Found in symphony/lib/toolkit/class.field.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 buildDSRetrievalSQL has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false)
          {
              if (Symphony::Log()) {
                  Symphony::Log()->pushDeprecateWarningToLog(
                      get_called_class() . '::buildDSRetrievalSQL()',
      Severity: Minor
      Found in symphony/lib/toolkit/class.field.php - About 1 hr to fix

        Function checkFields has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function checkFields(array &$errors, $checkForDuplicates = true)
            {
                $parent_section = $this->get('parent_section');
                $label = $this->get('label');
                $element_name = $this->get('element_name');
        Severity: Minor
        Found in symphony/lib/toolkit/class.field.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 appendAssociationInterfaceSelect has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function appendAssociationInterfaceSelect(XMLElement &$wrapper)
            {
                $wrapper->setAttribute('data-condition', 'associative');
        
                $interfaces = Symphony::ExtensionManager()->getProvidersOf(iProvider::ASSOCIATION_UI);
        Severity: Minor
        Found in symphony/lib/toolkit/class.field.php - About 1 hr to fix

          Method buildRegexSQL has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function buildRegexSQL($filter, array $columns, &$joins, &$where)
              {
                  if (Symphony::Log()) {
                      Symphony::Log()->pushDeprecateWarningToLog(
                          get_called_class() . '::buildRegexSQL()',
          Severity: Minor
          Found in symphony/lib/toolkit/class.field.php - About 1 hr to fix

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

                public function getAssociationContext()
                {
                    $context = Symphony::Engine()->Page->getContext();
                    $associations = $context['associations']['parent'];
                    $field_association = array();
            Severity: Minor
            Found in symphony/lib/toolkit/class.field.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 fetchFilterableOperators has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function fetchFilterableOperators()
                {
                    return array(
                        array(
                            'title' => 'is',
            Severity: Minor
            Found in symphony/lib/toolkit/class.field.php - About 1 hr to fix

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

                  public function buildFilterSQL($filter, array $columns, &$joins, &$where)
                  {
                      if (Symphony::Log()) {
                          Symphony::Log()->pushDeprecateWarningToLog(
                              get_called_class() . '::buildFilterSQL()',
              Severity: Minor
              Found in symphony/lib/toolkit/class.field.php - About 1 hr to fix

                Method exists has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function exists()
                    {
                        if (!$this->get('id') || !$this->_handle) {
                            return false;
                        }
                Severity: Minor
                Found in symphony/lib/toolkit/class.field.php - About 1 hr to fix

                  Method checkFields has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function checkFields(array &$errors, $checkForDuplicates = true)
                      {
                          $parent_section = $this->get('parent_section');
                          $label = $this->get('label');
                          $element_name = $this->get('element_name');
                  Severity: Minor
                  Found in symphony/lib/toolkit/class.field.php - About 1 hr to fix

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

                        public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false)
                        {
                            if (Symphony::Log()) {
                                Symphony::Log()->pushDeprecateWarningToLog(
                                    get_called_class() . '::buildDSRetrievalSQL()',
                    Severity: Minor
                    Found in symphony/lib/toolkit/class.field.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

                    Method displayPublishPanel has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null)
                    Severity: Minor
                    Found in symphony/lib/toolkit/class.field.php - About 45 mins to fix

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

                          public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = null, $entry_id = null)
                      Severity: Minor
                      Found in symphony/lib/toolkit/class.field.php - About 35 mins to fix

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

                            public function processRawFieldData($data, &$status, &$message = null, $simulate = false, $entry_id = null)
                        Severity: Minor
                        Found in symphony/lib/toolkit/class.field.php - About 35 mins to fix

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

                              public function buildValidationSelect(XMLElement &$wrapper, $selected = null, $name = 'fields[validator]', $type = 'input', array $errors = null)
                          Severity: Minor
                          Found in symphony/lib/toolkit/class.field.php - About 35 mins to fix

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

                                public function displayDatasourceFilterPanel(XMLElement &$wrapper, $data = null, $errors = null, $fieldnamePrefix = null, $fieldnamePostfix = null)
                            Severity: Minor
                            Found in symphony/lib/toolkit/class.field.php - About 35 mins to fix

                              Function exists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function exists()
                                  {
                                      if (!$this->get('id') || !$this->_handle) {
                                          return false;
                                      }
                              Severity: Minor
                              Found in symphony/lib/toolkit/class.field.php - About 25 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 buildRegexSQL has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function buildRegexSQL($filter, array $columns, &$joins, &$where)
                                  {
                                      if (Symphony::Log()) {
                                          Symphony::Log()->pushDeprecateWarningToLog(
                                              get_called_class() . '::buildRegexSQL()',
                              Severity: Minor
                              Found in symphony/lib/toolkit/class.field.php - About 25 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

                                          if (!empty($editors)) {
                                              $label = Widget::Label(__('Association Editor'), null, 'column');
                                              $label->appendChild(new XMLElement('i', __('Optional')));
                              
                                              $options = array(
                              Severity: Major
                              Found in symphony/lib/toolkit/class.field.php and 1 other location - About 5 hrs to fix
                              symphony/lib/toolkit/class.field.php on lines 791..805

                              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 183.

                              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 (!empty($interfaces)) {
                                              $label = Widget::Label(__('Association Interface'), null, 'column');
                                              $label->appendChild(new XMLElement('i', __('Optional')));
                              
                                              $options = array(
                              Severity: Major
                              Found in symphony/lib/toolkit/class.field.php and 1 other location - About 5 hrs to fix
                              symphony/lib/toolkit/class.field.php on lines 808..822

                              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 183.

                              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 (preg_match('/^regexp:\s*/i', $filter)) {
                                          $pattern = preg_replace('/^regexp:\s*/i', null, $filter);
                                          $regex = 'REGEXP';
                                          $op = 'OR';
                                      } elseif (preg_match('/^not-?regexp:\s*/i', $filter)) {
                              Severity: Major
                              Found in symphony/lib/toolkit/class.field.php and 1 other location - About 1 hr to fix
                              symphony/lib/toolkit/class.entryqueryfieldadapter.php on lines 105..115

                              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 120.

                              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 findParentRelatedEntries($parent_field_id, $entry_id)
                                  {
                                      try {
                                          $ids = Symphony::Database()
                                              ->select(['relation_id'])
                              Severity: Major
                              Found in symphony/lib/toolkit/class.field.php and 1 other location - About 1 hr to fix
                              symphony/lib/toolkit/class.field.php on lines 2101..2116

                              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 115.

                              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 createTable()
                                  {
                                      return Symphony::Database()
                                          ->create('tbl_entries_data_' . General::intval($this->get('id')))
                                          ->ifNotExists()
                              Severity: Major
                              Found in symphony/lib/toolkit/class.field.php and 1 other location - About 1 hr to fix
                              symphony/lib/toolkit/fields/field.date.php on lines 148..171

                              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 115.

                              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 findRelatedEntries($entry_id, $parent_field_id)
                                  {
                                      try {
                                          $ids = Symphony::Database()
                                              ->select(['entry_id'])
                              Severity: Major
                              Found in symphony/lib/toolkit/class.field.php and 1 other location - About 1 hr to fix
                              symphony/lib/toolkit/class.field.php on lines 2128..2143

                              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 115.

                              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 buildSortingSQL(&$joins, &$where, &$sort, $order = 'ASC')
                                  {
                                      if (Symphony::Log()) {
                                          Symphony::Log()->pushDeprecateWarningToLog(
                                              get_called_class() . '::buildSortingSQL()',
                              Severity: Major
                              Found in symphony/lib/toolkit/class.field.php and 1 other location - About 1 hr to fix
                              symphony/lib/toolkit/fields/field.author.php on lines 575..592

                              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 114.

                              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