symphonycms/symphony-2

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

Summary

Maintainability
F
1 wk
Test Coverage

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

<?php

/**
 * @package toolkit
 */
Severity: Major
Found in symphony/lib/toolkit/class.extensionmanager.php - About 1 day to fix

    ExtensionManager has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ExtensionManager implements FileResource
    {
        /**
         * An array of all the objects that the Manager is responsible for.
         * Defaults to an empty array.
    Severity: Minor
    Found in symphony/lib/toolkit/class.extensionmanager.php - About 3 hrs to fix

      Function fetch has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function fetch(array $select = array(), array $where = array(), $order_by = null)
          {
              $extensions = self::listAll();
              $data = array();
      
      
      Severity: Minor
      Found in symphony/lib/toolkit/class.extensionmanager.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 about has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function about($name, $rawXML = false)
          {
              // See if the extension has the new meta format
              if (file_exists(self::__getClassPath($name) . '/extension.meta.xml')) {
                  try {
      Severity: Minor
      Found in symphony/lib/toolkit/class.extensionmanager.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 canUninstallOrDisable has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          protected static function canUninstallOrDisable(Extension $obj)
          {
              $extension_handle = strtolower(preg_replace('/^extension_/i', null, get_class($obj)));
              $about = self::about($extension_handle);
      
      
      Severity: Minor
      Found in symphony/lib/toolkit/class.extensionmanager.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 about has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function about($name, $rawXML = false)
          {
              // See if the extension has the new meta format
              if (file_exists(self::__getClassPath($name) . '/extension.meta.xml')) {
                  try {
      Severity: Major
      Found in symphony/lib/toolkit/class.extensionmanager.php - About 3 hrs to fix

        Function notifyMembers has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function notifyMembers($delegate, $page, array $context = array())
            {
                // Make sure $page is an array
                if (!is_array($page)) {
                    $page = array($page);
        Severity: Minor
        Found in symphony/lib/toolkit/class.extensionmanager.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 canUninstallOrDisable has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected static function canUninstallOrDisable(Extension $obj)
            {
                $extension_handle = strtolower(preg_replace('/^extension_/i', null, get_class($obj)));
                $about = self::about($extension_handle);
        
        
        Severity: Minor
        Found in symphony/lib/toolkit/class.extensionmanager.php - About 1 hr to fix

          Method fetch has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function fetch(array $select = array(), array $where = array(), $order_by = null)
              {
                  $extensions = self::listAll();
                  $data = array();
          
          
          Severity: Minor
          Found in symphony/lib/toolkit/class.extensionmanager.php - About 1 hr to fix

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

                public static function getProvidersOf($type = null)
                {
                    // Loop over all extensions and build an array of providable objects
                    if (empty(self::$_providers)) {
                        self::$_providers = array();
            Severity: Minor
            Found in symphony/lib/toolkit/class.extensionmanager.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 notifyMembers has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function notifyMembers($delegate, $page, array $context = array())
                {
                    // Make sure $page is an array
                    if (!is_array($page)) {
                        $page = array($page);
            Severity: Minor
            Found in symphony/lib/toolkit/class.extensionmanager.php - About 1 hr to fix

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

                  public static function create($name)
                  {
                      if (!isset(self::$_pool[$name])) {
                          $classname = self::__getClassName($name);
                          $path = self::__getDriverPath($name);
              Severity: Minor
              Found in symphony/lib/toolkit/class.extensionmanager.php - About 1 hr to fix

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

                    public static function enable($name)
                    {
                        $obj = self::getInstance($name);
                
                        // If not installed, install it
                Severity: Minor
                Found in symphony/lib/toolkit/class.extensionmanager.php - About 1 hr to fix

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

                      public static function create($name)
                      {
                          if (!isset(self::$_pool[$name])) {
                              $classname = self::__getClassName($name);
                              $path = self::__getDriverPath($name);
                  Severity: Minor
                  Found in symphony/lib/toolkit/class.extensionmanager.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 registerDelegates has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function registerDelegates($name)
                      {
                          $obj = self::getInstance($name);
                          $id = self::fetchExtensionID($name);
                  
                  
                  Severity: Minor
                  Found in symphony/lib/toolkit/class.extensionmanager.php - About 1 hr to fix

                    Method cleanupDatabase has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function cleanupDatabase()
                        {
                            // Grab any extensions sitting in the database
                            $rows = Symphony::Database()
                                ->select(['name', 'status'])
                    Severity: Minor
                    Found in symphony/lib/toolkit/class.extensionmanager.php - About 1 hr to fix

                      Function fetchStatus has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static function fetchStatus($about)
                          {
                              $return = array();
                              static::buildExtensionList();
                      
                      
                      Severity: Minor
                      Found in symphony/lib/toolkit/class.extensionmanager.php - About 35 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 cleanupDatabase has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static function cleanupDatabase()
                          {
                              // Grab any extensions sitting in the database
                              $rows = Symphony::Database()
                                  ->select(['name', 'status'])
                      Severity: Minor
                      Found in symphony/lib/toolkit/class.extensionmanager.php - About 35 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 listAll has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static function listAll($filter = '/^((?![-^?%:*|"<>]).)*$/')
                          {
                              $result = array();
                              $extensions = General::listDirStructure(EXTENSIONS, $filter, false, EXTENSIONS);
                      
                      
                      Severity: Minor
                      Found in symphony/lib/toolkit/class.extensionmanager.php - About 35 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 enable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static function enable($name)
                          {
                              $obj = self::getInstance($name);
                      
                              // If not installed, install it
                      Severity: Minor
                      Found in symphony/lib/toolkit/class.extensionmanager.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 sortByAuthor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private static function sortByAuthor($a, $b, $i = 0)
                          {
                              $first = $a;
                              $second = $b;
                      
                      
                      Severity: Minor
                      Found in symphony/lib/toolkit/class.extensionmanager.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 4 locations. Consider refactoring.
                      Open

                              if (is_dir(EXTENSIONS . "/{$extension_handle}/data-sources")) {
                                  foreach (glob(EXTENSIONS . "/{$extension_handle}/data-sources/data.*.php") as $file) {
                                      $handle = preg_replace(array('/^data\./i', '/\.php$/i'), null, basename($file));
                      
                                      if (PageManager::isDataSourceUsed($handle)) {
                      Severity: Major
                      Found in symphony/lib/toolkit/class.extensionmanager.php and 3 other locations - About 3 hrs to fix
                      symphony/lib/toolkit/class.extensionmanager.php on lines 631..642
                      symphony/lib/toolkit/class.extensionmanager.php on lines 659..670
                      symphony/lib/toolkit/class.extensionmanager.php on lines 673..684

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

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

                              if (is_dir(EXTENSIONS . "/{$extension_handle}/fields")) {
                                  foreach (glob(EXTENSIONS . "/{$extension_handle}/fields/field.*.php") as $file) {
                                      $type = preg_replace(array('/^field\./i', '/\.php$/i'), null, basename($file));
                      
                                      if (FieldManager::isFieldUsed($type)) {
                      Severity: Major
                      Found in symphony/lib/toolkit/class.extensionmanager.php and 3 other locations - About 3 hrs to fix
                      symphony/lib/toolkit/class.extensionmanager.php on lines 645..656
                      symphony/lib/toolkit/class.extensionmanager.php on lines 659..670
                      symphony/lib/toolkit/class.extensionmanager.php on lines 673..684

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

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

                              if (is_dir(EXTENSIONS . "/{$extension_handle}/events")) {
                                  foreach (glob(EXTENSIONS . "/{$extension_handle}/events/event.*.php") as $file) {
                                      $handle = preg_replace(array('/^event\./i', '/\.php$/i'), null, basename($file));
                      
                                      if (PageManager::isEventUsed($handle)) {
                      Severity: Major
                      Found in symphony/lib/toolkit/class.extensionmanager.php and 3 other locations - About 3 hrs to fix
                      symphony/lib/toolkit/class.extensionmanager.php on lines 631..642
                      symphony/lib/toolkit/class.extensionmanager.php on lines 645..656
                      symphony/lib/toolkit/class.extensionmanager.php on lines 673..684

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

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

                              if (is_dir(EXTENSIONS . "/{$extension_handle}/text-formatters")) {
                                  foreach (glob(EXTENSIONS . "/{$extension_handle}/text-formatters/formatter.*.php") as $file) {
                                      $handle = preg_replace(array('/^formatter\./i', '/\.php$/i'), null, basename($file));
                      
                                      if (FieldManager::isTextFormatterUsed($handle)) {
                      Severity: Major
                      Found in symphony/lib/toolkit/class.extensionmanager.php and 3 other locations - About 3 hrs to fix
                      symphony/lib/toolkit/class.extensionmanager.php on lines 631..642
                      symphony/lib/toolkit/class.extensionmanager.php on lines 645..656
                      symphony/lib/toolkit/class.extensionmanager.php on lines 659..670

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

                      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