strata-mvc/strata

View on GitHub

Showing 158 of 158 total issues

Function truncate has a Cognitive Complexity of 84 (exceeds 5 allowed). Consider refactoring.
Open

    public static function truncate($text, $length = 100, $options = array())
    {
        $defaults = array(
            'ellipsis' => '...', 'exact' => true, 'html' => false
        );
Severity: Minor
Found in src/Utility/StringUtility.php - About 1 day 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

<?php

namespace Strata\Shell\Command\Generator;

use Strata\Model\Taxonomy\Taxonomy;
Severity: Major
Found in src/Shell/Command/Generator/TaxonomyGenerator.php and 1 other location - About 1 day to fix
src/Shell/Command/Generator/ValidatorGenerator.php on lines 1..68

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

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

<?php

namespace Strata\Shell\Command\Generator;

use Strata\Model\Validator\Validator;
Severity: Major
Found in src/Shell/Command/Generator/ValidatorGenerator.php and 1 other location - About 1 day to fix
src/Shell/Command/Generator/TaxonomyGenerator.php on lines 1..68

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

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

File Hash.php has 679 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
Severity: Major
Found in src/Utility/Hash.php - About 1 day to fix

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

            $customizedOptions['labels'] += array(
                'name'                => _x($plural, 'Post Type General Name', 'strata'),
                'singular_name'       => _x($singular, 'Post Type Singular Name', 'strata'),
                'menu_name'           => __($plural, 'strata'),
                'parent_item_colon'   => __($singular. ' Item:', 'strata'),
    Severity: Major
    Found in src/Model/CustomPostType/Registrar/TaxonomyRegistrar.php and 1 other location - About 7 hrs to fix
    src/Model/CustomPostType/Registrar/CustomPostTypeRegistrar.php on lines 51..65

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

    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

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

            $customizedOptions['labels'] += array(
                'name'                => _x($plural, 'Post Type General Name', 'strata'),
                'singular_name'       => _x($singular, 'Post Type Singular Name', 'strata'),
                'menu_name'           => __($plural, 'strata'),
                'parent_item_colon'   => __($singular. ' Item:', 'strata'),
    src/Model/CustomPostType/Registrar/TaxonomyRegistrar.php on lines 94..108

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

    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

    File StringUtility.php has 485 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * String handling methods.
     *
     * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
    Severity: Minor
    Found in src/Utility/StringUtility.php - About 7 hrs to fix

      Function tokenize has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function tokenize($data, $separator = ',', $leftBound = '(', $rightBound = ')')
          {
              if (empty($data)) {
                  return array();
              }
      Severity: Minor
      Found in src/Utility/StringUtility.php - About 6 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 Inflector.php has 407 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
       * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
       *
      Severity: Minor
      Found in src/Utility/Inflector.php - About 5 hrs to fix

        ModelEntity has 39 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ModelEntity
        {
            use StrataObjectTrait;
        
            /**
        Severity: Minor
        Found in src/Model/CustomPostType/ModelEntity.php - About 5 hrs to fix

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

                      if (preg_match("/themes\/$theme\/lib\/(.+?)\.php/", $filename, $matches)) {
                          $lib = $matches[1];
          
                          if (!array_key_exists($lib, $tree["themes"][$theme]["libs"])) {
                              $tree["themes"][$theme]["libs"][$lib] = array();
          Severity: Major
          Found in src/Shell/Command/DocumentationCommand.php and 1 other location - About 5 hrs to fix
          src/Shell/Command/DocumentationCommand.php on lines 243..256

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

          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("/themes\/$theme\/template\-(.+?)\.php/", $filename, $matches)) {
                          $template = $matches[1];
                          if (!array_key_exists($template, $tree["themes"][$theme]["templates"])) {
                              $tree["themes"][$theme]["templates"][$template] = array();
          
          
          Severity: Major
          Found in src/Shell/Command/DocumentationCommand.php and 1 other location - About 5 hrs to fix
          src/Shell/Command/DocumentationCommand.php on lines 259..273

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

          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

          StrataContext has 38 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class StrataContext
          {
              static $reference;
          
              /**
          Severity: Minor
          Found in src/Core/StrataContext.php - About 5 hrs to fix

            Function saveWPGettextFunctions has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
            Open

                public function saveWPGettextFunctions(array $functions, Translations $translations, $file = '')
                {
                    foreach ($this->getFunctions() as $function) {
                        list($name, $line, $args) = $function;
            
            
            Severity: Minor
            Found in src/I18n/WpPhpFunctionsScanner.php - About 4 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 setCurrentLocaleByContext has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
            Open

                public function setCurrentLocaleByContext()
                {
                    if (function_exists('apply_filters')) {
                        // Give a chance for plugins to override this decision
                        $locale = null;
            Severity: Minor
            Found in src/I18n/I18n.php - About 4 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

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

                        while (!empty($stack)) {
                            foreach ($stack as $curKey => &$curMerge) {
                                foreach ($curMerge[0] as $key => &$val) {
                                    if (!empty($curMerge[1][$key]) && (array)$curMerge[1][$key] === $curMerge[1][$key] && (array)$val === $val) {
                                        $stack[] = array(&$val, &$curMerge[1][$key]);
            Severity: Major
            Found in src/Utility/Hash.php and 1 other location - About 4 hrs to fix
            src/Utility/Hash.php on lines 717..731

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

            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

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

                    while (!empty($stack)) {
                        foreach ($stack as $curKey => &$curMerge) {
                            foreach ($curMerge[0] as $key => &$val) {
                                if (!empty($curMerge[1][$key]) && (array)$curMerge[1][$key] === $curMerge[1][$key] && (array)$val === $val) {
                                    $stack[] = array(&$val, &$curMerge[1][$key]);
            Severity: Major
            Found in src/Utility/Hash.php and 1 other location - About 4 hrs to fix
            src/Utility/Hash.php on lines 674..688

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

            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

            i18n has 34 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class i18n
            {
                /**
                 * @var string The default text domain used buy the class
                 */
            Severity: Minor
            Found in src/I18n/I18n.php - About 4 hrs to fix

              Function _matches has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected static function _matches(array $data, $selector)
                  {
                      preg_match_all(
                          '/(\[ (?P<attr>[^=><!]+?) (\s* (?P<op>[><!]?[=]|[><]) \s* (?P<val>(?:\/.*?\/ | [^\]]+)) )? \])/x',
                          $selector,
              Severity: Minor
              Found in src/Utility/Hash.php - About 4 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 truncate has 99 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function truncate($text, $length = 100, $options = array())
                  {
                      $defaults = array(
                          'ellipsis' => '...', 'exact' => true, 'html' => false
                      );
              Severity: Major
              Found in src/Utility/StringUtility.php - About 3 hrs to fix
                Severity
                Category
                Status
                Source
                Language