Showing 37 of 37 total issues
The class RoutesTest has 15 public methods. Consider refactoring RoutesTest to keep number of public methods under 10. Open
class RoutesTest extends TestCase
{
/** @test */
public function userCantAccessJsonFileIfItIsNotGenerated(): void
{
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
Method configDataProvider
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function configDataProvider(): array
{
return [
[
[
Method docs
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function docs(Request $request)
{
$fileSystem = new Filesystem();
$documentation = $request->offsetGet('documentation');
$config = $request->offsetGet('config');
Avoid excessively long variable names like $securitySchemesConfig. Keep variable name length under 20. Open
public function __construct(array $securitySchemesConfig = [], array $securityConfig = [])
- 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 excessively long class names like L5SwaggerAnnotationsExampleSecurityScheme. Keep class name length under 40. Open
class L5SwaggerAnnotationsExampleSecurityScheme
{
}
- Read upRead up
- Exclude checks
LongClassName
Since: 2.9
Detects when classes or interfaces are declared with excessively long names.
Example
class ATooLongClassNameThatHintsAtADesignProblem {
}
interface ATooLongInterfaceNameThatHintsAtADesignProblem {
}
Source https://phpmd.org/rules/naming.html#longclassname
Avoid excessively long variable names like $securitySchemesConfig. Keep variable name length under 20. Open
protected $securitySchemesConfig;
- 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
Method canGenerateWithScanOptions
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function canGenerateWithScanOptions(): void
{
$cfg = config('l5-swagger.documentations.default');
$cfg['scanOptions']['exclude'] = [
Method api
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function api(Request $request)
{
$documentation = $request->offsetGet('documentation');
$config = $request->offsetGet('config');
Function docs
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function docs(Request $request)
{
$fileSystem = new Filesystem();
$documentation = $request->offsetGet('documentation');
$config = $request->offsetGet('config');
- 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 __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
array $paths,
array $constants,
bool $yamlCopyRequired,
SecurityDefinitions $security,
array $scanOptions,
The class Generator has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13. Open
class Generator
{
public const OPEN_API_DEFAULT_SPEC_VERSION = '3.0.0';
protected const SCAN_OPTION_PROCESSORS = 'processors';
- 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
Function setProcessors
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function setProcessors(OpenApiGenerator $generator): void
{
$processorClasses = Arr::get($this->scanOptions, self::SCAN_OPTION_PROCESSORS, []);
$processors = [];
- 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
Missing class import via use statement (line '233', column '104'). Open
$mockGenerator->expects($this->once())->method('generateDocs')->will($this->throwException(new \Exception));
- 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 '32', column '34'). Open
->setExpires(new \DateTime('+1 year'));
- 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 copyAssets
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function copyAssets(): void
{
$fileSystem = new Filesystem();
$src = __DIR__.'/../vendor/swagger-api/swagger-ui/dist/';
$destination = __DIR__.'/../vendor/orchestra/testbench-core/laravel/vendor/swagger-api/swagger-ui/dist/';
- 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 using static access to class '\Illuminate\Support\Facades\Log' in method 'docs'. Open
Log::error($e);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Illuminate\Support\Arr' in method 'createScanFinder'. Open
$exclude = Arr::get($this->scanOptions, self::SCAN_OPTION_EXCLUDE);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Illuminate\Support\Facades\Response' in method 'docs'. Open
return ResponseFacade::make($content, 200, [
'Content-Type' => 'application/yaml',
'Content-Disposition' => 'inline',
]);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Illuminate\Support\Arr' in method 'setProcessors'. Open
$processorClasses = Arr::get($this->scanOptions, self::SCAN_OPTION_PROCESSORS, []);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Illuminate\Support\Facades\Response' in method 'docs'. Open
return ResponseFacade::make($content, 200, [
'Content-Type' => 'application/json',
]);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}