Kylob/Bootstrap

View on GitHub
src/Common.php

Summary

Maintainability
F
1 wk
Test Coverage

File Common.php has 667 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace BootPress\Bootstrap;

use BootPress\Page\Component as Page;
Severity: Major
Found in src/Common.php - About 1 day to fix

    Function links has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

        public function links($tag, array $links, array $options = array())
        {
            $html = '';
            $class = null;
            if ($space = strpos($tag, ' ')) {
    Severity: Minor
    Found in src/Common.php - About 7 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 toggle has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        public function toggle($type, array $links, array $options = array())
        {
            $count = 1;
            $toggle = array();
            $content = '';
    Severity: Minor
    Found in src/Common.php - About 5 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 media has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        public function media(array $list, $parent = 0)
        {
            if (is_numeric($parent) && isset($list[0]) && is_array($list[0])) {
                $media = array();
                foreach ($list[$parent] as $child => $display) {
    Severity: Minor
    Found in src/Common.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

    Common has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Common
    {
        use Base;
    
        /** @var object A BootPress\Page\Component instance. */
    Severity: Minor
    Found in src/Common.php - About 3 hrs to fix

      Method links has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function links($tag, array $links, array $options = array())
          {
              $html = '';
              $class = null;
              if ($space = strpos($tag, ' ')) {
      Severity: Major
      Found in src/Common.php - About 2 hrs to fix

        Method toggle has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function toggle($type, array $links, array $options = array())
            {
                $count = 1;
                $toggle = array();
                $content = '';
        Severity: Major
        Found in src/Common.php - About 2 hrs to fix

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

              public function carousel(array $images, array $options = array())
              {
                  $html = '';
                  $id = $this->page->id('carousel');
                  $options = array_merge(array(
          Severity: Major
          Found in src/Common.php - About 2 hrs to fix

            Method media has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function media(array $list, $parent = 0)
                {
                    if (is_numeric($parent) && isset($list[0]) && is_array($list[0])) {
                        $media = array();
                        foreach ($list[$parent] as $child => $display) {
            Severity: Minor
            Found in src/Common.php - About 1 hr to fix

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

                  public function carousel(array $images, array $options = array())
                  {
                      $html = '';
                      $id = $this->page->id('carousel');
                      $options = array_merge(array(
              Severity: Minor
              Found in src/Common.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 button has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function button($class, $name, array $options = array())
                  {
                      $attributes = array('type' => 'button');
                      foreach ($options as $key => $value) {
                          if (!in_array($key, array('dropdown', 'dropup', 'active', 'disabled', 'pull'))) {
              Severity: Minor
              Found in src/Common.php - About 1 hr to fix

                Method accordion has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function accordion($class, array $sections, $open = 1)
                    {
                        $html = '';
                        $count = 0;
                        $id = $this->page->id('accordion');
                Severity: Minor
                Found in src/Common.php - About 1 hr to fix

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

                      public function search($url, array $form = array())
                      {
                          $html = '';
                          $form = array_merge(array(
                              'name' => 'search',
                  Severity: Minor
                  Found in src/Common.php - About 1 hr to fix

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

                        public function button($class, $name, array $options = array())
                        {
                            $attributes = array('type' => 'button');
                            foreach ($options as $key => $value) {
                                if (!in_array($key, array('dropdown', 'dropup', 'active', 'disabled', 'pull'))) {
                    Severity: Minor
                    Found in src/Common.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 listGroup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function listGroup(array $links, $active = false)
                        {
                            $html = '';
                            $tag = 'a';
                            $count = 1;
                    Severity: Minor
                    Found in src/Common.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 panel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function panel($class, array $sections)
                        {
                            $html = '';
                            foreach ($sections as $panel => $content) {
                                if (!is_numeric($panel)) {
                    Severity: Minor
                    Found in src/Common.php - About 45 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 row has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function row($size, $columns)
                        {
                            $html = '';
                            $prefix = array();
                            for ($i = 1; $i <= 12; ++$i) {
                    Severity: Minor
                    Found in src/Common.php - About 45 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 listItem has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        protected function listItem($link, $options, $name, $href, $count)
                    Severity: Minor
                    Found in src/Common.php - About 35 mins to fix

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

                          public function breadcrumbs(array $links)
                          {
                              if (empty($links)) {
                                  return '';
                              }
                      Severity: Minor
                      Found in src/Common.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 search has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function search($url, array $form = array())
                          {
                              $html = '';
                              $form = array_merge(array(
                                  'name' => 'search',
                      Severity: Minor
                      Found in src/Common.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 dropdown has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function dropdown(array $links, array $options = array(), &$count = 1)
                          {
                              $html = '';
                              $toggle = (isset($options['toggle'])) ? ' data-toggle="'.$options['toggle'].'"' : '';
                              foreach ($links as $name => $href) {
                      Severity: Minor
                      Found in src/Common.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 ($active == $name || $active == $count) {
                                          $options['active'] = '#'.$id;
                                          $content .= '<div role="tabpanel" class="'.$class.' in active" id="'.$id.'">'.$html.'</div>';
                                      } else {
                                          if ($disabled == $name || $disabled == $count) {
                      Severity: Major
                      Found in src/Common.php and 1 other location - About 2 hrs to fix
                      src/Common.php on lines 1075..1083

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

                      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 ($active == $drop || $active == $count) {
                                              $options['active'] = '#'.$id;
                                              $content .= '<div role="tabpanel" class="'.$class.' in active" id="'.$id.'">'.$down.'</div>';
                                          } else {
                                              if ($disabled == $drop || $disabled == $count) {
                      Severity: Major
                      Found in src/Common.php and 1 other location - About 2 hrs to fix
                      src/Common.php on lines 1094..1102

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

                      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