Showing 73 of 73 total issues
Function generateClassType
has a Cognitive Complexity of 251 (exceeds 5 allowed). Consider refactoring. Open
public function generateClassType(array $properties, $typesReference, $typesDescription, ClassConfig $config)
{
$phpNamespace = $this->currentClass->getNamespace();
if ($config->isInterface) {
$this->info('Passo a interfaccia', [$this->currentClass->getName()]);
- 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 generate
has a Cognitive Complexity of 146 (exceeds 5 allowed). Consider refactoring. Open
public function generate(Local $directoryOutput)
{
//$is_constructor_enable = true;
//$ddd_is_root_aggregate = 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
Method generateClassType
has 317 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generateClassType(array $properties, $typesReference, $typesDescription, ClassConfig $config)
{
$phpNamespace = $this->currentClass->getNamespace();
if ($config->isInterface) {
$this->info('Passo a interfaccia', [$this->currentClass->getName()]);
Method generate
has 219 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generate(Local $directoryOutput)
{
//$is_constructor_enable = true;
//$ddd_is_root_aggregate = false;
File ClassGenerator.php
has 451 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Yoghi\Bundle\MaddaBundle\Generator;
/*
Method generateRest
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generateRest($ramlFile, Local $directoryOutput)
{
$parser = new Parser();
try {
The class ClassGenerator has an overall complexity of 83 which is very high. The configured complexity threshold is 50. Open
class ClassGenerator extends AbstractFileGenerator
{
/**
* [$currentClass description].
*
- Exclude checks
File DDDGenerator.php
has 266 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Yoghi\Bundle\MaddaBundle\Generator;
/*
Function generateRest
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function generateRest($ramlFile, Local $directoryOutput)
{
$parser = new Parser();
try {
- 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
Avoid excessively long variable names like $namespaceImplementClass. Keep variable name length under 20. Open
$namespaceImplementClass = $this->modelClass[$eventsImplement];
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid variables with short names like $g. Configured minimum length is 3. Open
$g = new ClassGenerator($namespace, $className, $classComments);
- 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
Avoid variables with short names like $mc. Configured minimum length is 3. Open
$mc = $this->currentClass->addMethod('__construct');
- 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
Avoid deeply nested control flow statements. Open
if ($defaultValue != null) {
/* @var $parameter \Nette\PhpGenerator\Parameter */
$parameter->setDefaultValue(''.$defaultValue);
}
Blank line found at start of control structure Open
try {
- Exclude checks
Missing class import via use statement (line '34', column '20'). Open
$rdi = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
- 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 '35', column '20'). Open
$rit = new \RecursiveIteratorIterator($rdi);
- 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
Function search
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function search($dir, $extension)
{
if (isset($this->logger)) {
$this->logger->info('Finder invocato su directory : '.$dir);
}
- 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
The method generate() has 288 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function generate(Local $directoryOutput)
{
//$is_constructor_enable = true;
//$ddd_is_root_aggregate = false;
- Exclude checks
Avoid unused local variables such as '$infoSecuritySchema'. Open
$infoSecuritySchema = $this->apiDef->getSecuredBy(); // descrive i vari security schema usati nelle varie risorse
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused private methods such as 'removeGraph'. Open
private function removeGraph(&$str)
{
$str = str_replace('{', '', $str);
$str = str_replace('}', '', $str);
$str = ucfirst($str);
- Read upRead up
- Exclude checks
UnusedPrivateMethod
Since: 0.2
Unused Private Method detects when a private method is declared but is unused.
Example
class Something
{
private function foo() {} // unused
}