Showing 191 of 191 total issues
Method _functionNode
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _functionNode()
{
$node = new FunctionDef();
$token = $this->_stream->current(true);
$parent = $this->_states['current'];
Method _classNode
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _classNode()
{
if (substr($this->_states['body'], -2) === '::') { // Bails out on `::class`
$this->_states['body'] .= 'class';
return;
Method _renderMetricsReport
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _renderMetricsReport($metricsReport, $labelWidth, $lineWidth, $depth)
{
$nbChilden = count($metricsReport);
$index = 0;
foreach ($metricsReport as $name => $data) {
Method debug
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function debug($content)
{
$root = is_object($content) ? $content : static::parse($content, ['lines' => true]);
$result = '';
Method _reportSpecMessage
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _reportSpecMessage($log)
{
$messages = $log->messages();
$message = end($messages);
Method export
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function export($options)
{
$defaults = [
'collector' => null,
'head' => null,
Method errorType
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function errorType($value)
{
switch ($value) {
case E_ERROR:
return 'E_ERROR';
Method specEnd
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function specEnd($log = null)
{
$isOk = $log->passed() ? "ok" : "not ok";
switch ($log->type()) {
Function box
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function box($name = '', $box = null)
{
static $boxes = [];
if (func_num_args() === 1) {
- 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 _renderCoverage
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function _renderCoverage($metrics)
{
$stats = $metrics->data();
foreach ($stats['files'] as $file) {
$this->write("File: {$file}" . "\n\n");
- 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 _generateMethodStubs
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected static function _generateMethodStubs($methods, $defaults = true)
{
$result = [];
$methods = $methods !== null ? (array) $methods : [];
- 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 where($requirements = [])
{
foreach ($requirements as $name => $args) {
if (!isset($this->_chain[$name])) {
throw new InvalidArgumentException("Unexisting `{$name}` as method as part of the chain definition.");
- 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 105.
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 where($requirements = [])
{
foreach ($requirements as $name => $args) {
if (!isset($this->_messages[$name])) {
throw new InvalidArgumentException("Unexisting `{$name}` as method as part of the chain definition.");
- 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 105.
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 add
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->_fallbackDirsPsr0 = array_merge(
Method addPsr4
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
Method _coverage
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _coverage($file, $coverage)
{
$result = [];
$root = $this->parse($file);
foreach ($root->lines['content'] as $num => $content) {
Method _coverage
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _coverage()
{
return Filters::run($this, 'coverage', [], function ($chain) {
if (!$this->commandLine()->exists('coverage')) {
return;
Method patched
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function patched($namespace, $className, $methodName, &$substitute = null)
{
$name = $className ?: $methodName;
if ($namespace && ($className || function_exists("{$namespace}\\{$name}"))) {
Method _buildDescription
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _buildDescription($startIndex = 0)
{
$times = $this->times();
$report = $this->_report;
Method match
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function match($actual, $expected)
{
$args = func_get_args();
$expected = count($args) > 2 ? array_slice($args, 1) : $expected;
$expected = (array) $expected;