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;
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, ' ')) {
- Read upRead up
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 = '';
- Read upRead up
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');
- Read upRead up
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 156.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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');
- Read upRead up
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 156.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
- Read upRead up
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) {
- Read upRead up
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. */
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, ' ')) {
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) {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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) {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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 = '';
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(
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;
- Read upRead up
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 '';
}
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) {
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;
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(
- Read upRead up
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 '';
}
- Read upRead up
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'))) {