Showing 15 of 15 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
namespace Attogram\SharedMedia\Sandbox;
use PHPUnit\Framework\TestCase;
- 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 91.
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
<?php
namespace Attogram\SharedMedia\Sandbox;
use PHPUnit\Framework\TestCase;
- 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 91.
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
Missing class import via use statement (line '25', column '21'). Open
$base = new \Attogram\SharedMedia\Sandbox\Base();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '115', column '29'). Open
$refClass = new \ReflectionClass($class);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '25', column '24'). Open
$sandbox = new \Attogram\SharedMedia\Sandbox\Sandbox();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The 'getClass()' method which returns a boolean should be named 'is...()' or 'has...()' Open
protected function getClass()
{
$classNames = array_unique(array_column($this->methods, '0'));
if (!in_array($this->class, $classNames)) {
$this->logger->critical('getClass: Class Denied:', [$this->class]);
- Read upRead up
- Exclude checks
BooleanGetMethodName
Since: 0.2
Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.
Example
class Foo {
/**
* @return boolean
*/
public function getFoo() {} // bad
/**
* @return bool
*/
public function isFoo(); // ok
/**
* @return boolean
*/
public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}
Source https://phpmd.org/rules/naming.html#booleangetmethodname
Suspicious type null
of a variable or expression used to build a string. (Expected type to be able to cast to a string) Open
$form .= '<br />' . $this->action[2]
- Exclude checks
Returning type object
but getClass()
is declared to return bool
Open
return new $this->class($this->logger);
- Exclude checks
Invalid offset 2
of array type array{}
Open
$form .= '<br />' . $this->action[2]
- Exclude checks
Argument 1 (object)
is bool
but \get_class()
takes object
Open
$this->logger->debug('SANDBOX: class: '.get_class($class));
- Exclude checks
Invalid offset 2
of array type array{}
Open
if (isset($this->action[2]) && $this->action[2]) { // Requires argument
- Exclude checks
Call to method format
on non-class type string
Open
$response = $class->format($results);
- Exclude checks
Invalid offset 3
of array type array{}
Open
if (isset($this->action[3]) && $this->action[3]) { // Requires Identifier
- Exclude checks
Suspicious type void
of a variable or expression used to build a string. (Expected type to be able to cast to a string) Open
$response = '<pre>' . var_dump($results) . '</pre>';
- Exclude checks
Cannot assign void return value Open
$response = var_dump($results);
- Exclude checks