File HasPHPDocPlugin.php
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace HasPHPDocPlugin;
Method checkMethodDescription
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function checkMethodDescription(Clazz $class, Node $node): ?ClassElementEntry
{
$method_name = (string)$node->children['name'];
$method = $class->getMethodByName($this->code_base, $method_name);
if ($method->isMagic()) {
Method visitClass
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitClass(Node $node): array
{
[$property_descriptions, $method_descriptions] = parent::visitClass($node);
foreach (self::findGroups($property_descriptions) as $entries) {
$first_entry = array_shift($entries);
Method analyzeFunction
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function analyzeFunction(
CodeBase $code_base,
Func $function
): void {
if ($function->isPHPInternal()) {
Method checkPropGroupDescription
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function checkPropGroupDescription(Clazz $class, Node $node): ?ClassElementEntry
{
$property_name = $node->children['props']->children[0]->children['name'] ?? null;
if (!is_string($property_name)) {
return null;
Method analyzeClass
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function analyzeClass(
CodeBase $code_base,
Clazz $class
): void {
if ($class->isAnonymous()) {
Function visitClass
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function visitClass(Node $node): array
{
[$property_descriptions, $method_descriptions] = parent::visitClass($node);
foreach (self::findGroups($property_descriptions) as $entries) {
$first_entry = array_shift($entries);
- 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 visitClass
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function visitClass(Node $node): array
{
$class = $this->context->getClassInScope($this->code_base);
$property_descriptions = [];
$method_descriptions = [];
- 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 checkMethodDescription
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function checkMethodDescription(Clazz $class, Node $node): ?ClassElementEntry
{
$method_name = (string)$node->children['name'];
$method = $class->getMethodByName($this->code_base, $method_name);
if ($method->isMagic()) {
- 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 findGroups
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function findGroups(array $values): array
{
$result = [];
foreach ($values as $v) {
if ($v->element->isDeprecated()) {
- 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 too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return new ClassElementEntry($method, \trim(\preg_replace('/\s+/', ' ', $description)));