Kylob/Bootstrap

View on GitHub

Showing 35 of 35 total issues

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

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

        public function radio($field, array $attributes = array(), $inline = false)
        {
            $disabled = in_array('disabled', $attributes) ? 'disabled' : '';
            if ($inline !== false) {
                $wrap = $this->page->tag('label', array('class' => array('radio-inline', $this->input, $disabled)), '%s');
    Severity: Major
    Found in src/Form.php and 1 other location - About 4 hrs to fix
    src/Form.php on lines 215..225

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

    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

        public function checkbox($field, array $attributes = array(), $inline = false)
        {
            $disabled = in_array('disabled', $attributes) ? 'disabled' : '';
            if ($inline !== false) {
                $wrap = $this->page->tag('label', array('class' => array('checkbox-inline', $this->input, $disabled)), '%s');
    Severity: Major
    Found in src/Form.php and 1 other location - About 4 hrs to fix
    src/Form.php on lines 245..255

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

    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 addClass has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function addClass($html, array $tags)
        {
            $rnr = array();
            foreach ($tags as $tag => $class) {
                $prefix = (is_array($class) && isset($class[2]) && is_array($class[1])) ? $class : false;
    Severity: Minor
    Found in src/Base.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 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

    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 3 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 121.

    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 3 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 121.

    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

    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

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

                public function field($prompt, $input, $error = null)
                {
                    foreach (array('input', 'select', 'textarea', 'button', 'p') as $tag) {
                        if ($this->firstTagAttributes($input, $matches, '<'.$tag)) {
                            break;
            Severity: Minor
            Found in src/Form.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 label has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function label($prompt, $name, $id)
                {
                    if (empty($prompt)) {
                        return '';
                    }
            Severity: Minor
            Found in src/Form.php - About 1 hr 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

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

                    public function field($prompt, $input, $error = null)
                    {
                        foreach (array('input', 'select', 'textarea', 'button', 'p') as $tag) {
                            if ($this->firstTagAttributes($input, $matches, '<'.$tag)) {
                                break;
                Severity: Minor
                Found in src/Form.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

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

                      private function label($prompt, $name, $id)
                      {
                          if (empty($prompt)) {
                              return '';
                          }
                  Severity: Minor
                  Found in src/Form.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
                    Severity
                    Category
                    Status
                    Source
                    Language