strata-mvc/strata

View on GitHub

Showing 158 of 158 total issues

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

    public static function sort(array $data, $path, $dir = 'asc', $type = 'regular')
    {
        if (empty($data)) {
            return 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

Method tokenize has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function tokenize($data, $separator = ',', $leftBound = '(', $rightBound = ')')
    {
        if (empty($data)) {
            return array();
        }
Severity: Major
Found in src/Utility/StringUtility.php - About 2 hrs to fix

    FormHelper has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class FormHelper extends Helper
    {
        /**
         * @var Strata\Controller\Request The active request
         */
    Severity: Minor
    Found in src/View/Helper/FormHelper.php - About 2 hrs to fix

      Method cleanInsert has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function cleanInsert($str, $options)
          {
              $clean = $options['clean'];
              if (!$clean) {
                  return $str;
      Severity: Major
      Found in src/Utility/StringUtility.php - About 2 hrs to fix

        Method saveWPGettextFunctions has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function saveWPGettextFunctions(array $functions, Translations $translations, $file = '')
            {
                foreach ($this->getFunctions() as $function) {
                    list($name, $line, $args) = $function;
        
        
        Severity: Major
        Found in src/I18n/WpPhpFunctionsScanner.php - About 2 hrs to fix

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

                  if (!isset(self::$_plural['cacheUninflected']) || !isset(self::$_plural['cacheIrregular'])) {
                      self::$_plural['cacheUninflected'] = '(?:' . implode('|', self::$_plural['merged']['uninflected']) . ')';
                      self::$_plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_plural['merged']['irregular'])) . ')';
                  }
          Severity: Major
          Found in src/Utility/Inflector.php and 1 other location - About 2 hrs to fix
          src/Utility/Inflector.php on lines 444..447

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

          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 (!isset(self::$_singular['cacheUninflected']) || !isset(self::$_singular['cacheIrregular'])) {
                      self::$_singular['cacheUninflected'] = '(?:' . implode('|', self::$_singular['merged']['uninflected']) . ')';
                      self::$_singular['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_singular['merged']['irregular'])) . ')';
                  }
          Severity: Major
          Found in src/Utility/Inflector.php and 1 other location - About 2 hrs to fix
          src/Utility/Inflector.php on lines 392..395

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

          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

          Function wordWrap has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function wordWrap($text, $width = 72, $break = "\n", $cut = false)
              {
                  if ($cut) {
                      $parts = array();
                      while (mb_strlen($text) > 0) {
          Severity: Minor
          Found in src/Utility/StringUtility.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

          Function nest has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function nest(array $data, $options = array())
              {
                  if (!$data) {
                      return $data;
                  }
          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

          Method nest has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function nest(array $data, $options = array())
              {
                  if (!$data) {
                      return $data;
                  }
          Severity: Major
          Found in src/Utility/Hash.php - About 2 hrs to fix

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

                public static function sort(array $data, $path, $dir = 'asc', $type = 'regular')
                {
                    if (empty($data)) {
                        return array();
                    }
            Severity: Major
            Found in src/Utility/Hash.php - About 2 hrs to fix

              Method setCurrentLocaleByContext has 49 lines of code (exceeds 25 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 1 hr to fix

                Method input has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function input($name, $options = array())
                    {
                        $options += array(
                            "type"  => "text",
                            "id"    => $this->id($name),
                Severity: Minor
                Found in src/View/Helper/FormHelper.php - About 1 hr to fix

                  Method combine has 49 lines of code (exceeds 25 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 1 hr to fix

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

                        public static function normalize(array $data, $assoc = true)
                        {
                            $keys = array_keys($data);
                            $count = count($keys);
                            $numeric = true;
                    Severity: Minor
                    Found in src/Utility/Hash.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

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

                        public static function remove(array $data, $path)
                        {
                            if (strpos($path, '[') === false) {
                                $tokens = explode('.', $path);
                            } else {
                    Severity: Minor
                    Found in src/Utility/Hash.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 registerTaxonomy has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function registerTaxonomy(Taxonomy $taxonomy)
                        {
                            $labelParser = new LabelParser($taxonomy);
                            $labelParser->parse();
                            $singular   = $labelParser->singular();
                    Severity: Minor
                    Found in src/Model/CustomPostType/Registrar/TaxonomyRegistrar.php - About 1 hr to fix

                      Method insert has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function insert($str, $data, $options = array())
                          {
                              $defaults = array(
                                  'before' => ':', 'after' => null, 'escape' => '\\', 'format' => null, 'clean' => false
                              );
                      Severity: Minor
                      Found in src/Utility/StringUtility.php - About 1 hr to fix

                        Function test has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function test($value, $context)
                            {
                                if ($this->hasConfig("if") && !is_null($this->getConfig("if"))) {
                                    $request =  Strata::router()->getCurrentController()->request;
                                    foreach ($this->getConfig("if") as $key => $expectedValue) {
                        Severity: Minor
                        Found in src/Model/Validator/RequiredValidator.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

                        Function contains has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public static function contains(array $data, array $needle)
                            {
                                if (empty($data) || empty($needle)) {
                                    return false;
                                }
                        Severity: Minor
                        Found in src/Utility/Hash.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

                        Severity
                        Category
                        Status
                        Source
                        Language