Showing 38 of 38 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
/**
* micrometa
*
- 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 145.
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
/**
* micrometa
*
- 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 145.
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 testAliasedItemProperty
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function testAliasedItemProperty()
{
$itemFactory = new ItemFactory(0);
$rawItem = (object)[
'type' => ['test'],
Method getItems
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getItems()
{
$items = ItemFactory::createFromApplicationItems(
[
// Stylesheet link item
Method getProfiledNames
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getProfiledNames()
{
$schemaOrgProfile = 'http://schema.org/';
$feedObject = (object)['name' => 'h-feed', 'profile' => MicroformatsFactory::MF2_PROFILE_URI];
$eventObject = (object)['name' => 'Event', 'profile' => $schemaOrgProfile];
Method creationArgumentProvider
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function creationArgumentProvider()
{
$item = new Item('test');
$testT = $this->typ('test');
$nvP = $this->prp('name1', 'value1');
Method renderItem
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function renderItem(ItemInterface $item)
{
$types = array_map(
function ($type) {
return '<abbr title="'.htmlspecialchars($type->profile.$type->name).'">'.
Method testItemCreation
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
$type,
array $properties,
$itemId,
$itemLanguage,
array $expectedTypes,
Method __construct
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
$format,
PropertyListFactoryInterface $propertyListFactory,
$type,
array $properties = [],
array $children = [],
Avoid variables with short names like $i. Configured minimum length is 3. Open
$i = $this->parseDocument($jsonLDDocSource);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The class Item has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13. Open
class Item extends Collection implements ItemInterface
{
/**
* Application item
*
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
The class JsonLD has a coupling between objects value of 16. Consider to reduce the number of dependencies under 13. Open
class JsonLD extends AbstractParser
{
/**
* Format
*
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
The class Parser has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13. Open
class Parser
{
/**
* Micro information formats
*
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$type,
array $properties = [],
$itemId = null,
$itemLanguage = null,
PropertyListFactoryInterface $propertyListFactory = null
Method setup
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
PropertyListFactoryInterface $propertyListFactory,
array $type,
array $properties,
$itemId,
$itemLanguage
Expected 1 space after FUNCTION keyword; 0 found Open
function($type) {
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
function($propertyValue) {
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
return $lang ? array_map(function($value) use ($lang) {
- Exclude checks
Missing class import via use statement (line '116', column '53'). Open
$this->logger->info('Running parser: '.(new \ReflectionClass(__CLASS__))->getShortName());
- 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 '69', column '22'). Open
$xpath = new \DOMXPath($dom);
- 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();
}