strata-mvc/strata

View on GitHub

Showing 158 of 158 total issues

File I18n.php has 329 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Strata\I18n;

use Strata\Strata;
Severity: Minor
Found in src/I18n/I18n.php - About 3 hrs to fix

    Function uuid has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function uuid()
        {
            $node = getenv('SERVER_ADDR');
            if (strpos($node, ':') !== false) {
                if (substr_count($node, '::')) {
    Severity: Minor
    Found in src/Utility/StringUtility.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

    Hash has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Hash
    {
    
        /**
     * Get a single value specified by $path out of $data.
    Severity: Minor
    Found in src/Utility/Hash.php - About 3 hrs to fix

      Query has 29 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Query
      {
          /**
           * A list of WP_Query filters. Defaults to a list of published posts
           * ordered by name alphabetically unpaged.
      Severity: Minor
      Found in src/Model/CustomPostType/Query.php - About 3 hrs to fix

        Function extract has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function extract(array $data, $path)
            {
                if (empty($path)) {
                    return $data;
                }
        Severity: Minor
        Found in src/Utility/Hash.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 combine has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function combine(array $data, $keyPath, $valuePath = null, $groupPath = null)
            {
                if (empty($data)) {
                    return array();
                }
        Severity: Minor
        Found in src/Utility/Hash.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 _simpleOp has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            protected static function _simpleOp($op, $data, $path, $values = null)
            {
                $_list =& $data;
        
                $count = count($path);
        Severity: Minor
        Found in src/Utility/Hash.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 scanThemeDirectories has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function scanThemeDirectories($base)
            {
                $tree = array("themes" => array());
        
                $di = new \RecursiveDirectoryIterator($base);
        Severity: Minor
        Found in src/Shell/Command/DocumentationCommand.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

        Strata has 28 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Strata extends StrataContext
        {
            use StrataConfigurableTrait;
        
            /**
        Severity: Minor
        Found in src/Strata.php - About 3 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                      if ($op === '=' && $val && $val[0] === '/') {
                          if (!preg_match($val, $prop)) {
                              return false;
                          }
                      } elseif (($op === '=' && $prop != $val)
          Severity: Critical
          Found in src/Utility/Hash.php - About 3 hrs to fix

            Function rules has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function rules($type, $rules, $reset = false)
                {
                    $var = '_' . $type;
            
                    switch ($type) {
            Severity: Minor
            Found in src/Utility/Inflector.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

            File FormHelper.php has 294 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            namespace Strata\View\Helper;
            
            use Strata\Model\ModelEntity;
            Severity: Minor
            Found in src/View/Helper/FormHelper.php - About 3 hrs to fix

              File ModelEntity.php has 291 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              namespace Strata\Model\CustomPostType;
              
              use Strata\Utility\Hash;
              Severity: Minor
              Found in src/Model/CustomPostType/ModelEntity.php - About 3 hrs to fix

                Function expand has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function expand($data, $separator = '.')
                    {
                        $result = array();
                
                        $stack = array();
                Severity: Minor
                Found in src/Utility/Hash.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

                Request has 24 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class Request
                {
                    /**
                     * A cache of the parsed GET values in the current request.
                     * @var array
                Severity: Minor
                Found in src/Controller/Request.php - About 2 hrs to fix

                  UrlRoute has 24 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class UrlRoute extends Route
                  {
                      /**
                       * @var string The hidden key for dynamically defined callback functions.
                       */
                  Severity: Minor
                  Found in src/Router/RouteParser/Url/UrlRoute.php - About 2 hrs to fix

                    Function debug has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                        function debug()
                        {
                            if (!WP_DEBUG) {
                                return;
                            }
                    Severity: Minor
                    Found in src/Utility/Toolset.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 uuid has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function uuid()
                        {
                            $node = getenv('SERVER_ADDR');
                            if (strpos($node, ':') !== false) {
                                if (substr_count($node, '::')) {
                    Severity: Major
                    Found in src/Utility/StringUtility.php - About 2 hrs to fix

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

                              if (preg_match('/(.*?(?:\\b|_))(' . self::$_singular['cacheIrregular'] . ')$/i', $word, $regs)) {
                                  self::$_cache['singularize'][$word] = $regs[1] .
                                      substr($regs[2], 0, 1) .
                                      substr(self::$_singular['merged']['irregular'][strtolower($regs[2])], 1);
                                  return self::$_cache['singularize'][$word];
                      Severity: Major
                      Found in src/Utility/Inflector.php and 1 other location - About 2 hrs to fix
                      src/Utility/Inflector.php on lines 397..402

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

                      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('/(.*?(?:\\b|_))(' . self::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) {
                                  self::$_cache['pluralize'][$word] = $regs[1] .
                                      substr($regs[2], 0, 1) .
                                      substr(self::$_plural['merged']['irregular'][strtolower($regs[2])], 1);
                                  return self::$_cache['pluralize'][$word];
                      Severity: Major
                      Found in src/Utility/Inflector.php and 1 other location - About 2 hrs to fix
                      src/Utility/Inflector.php on lines 449..454

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

                      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