MissingDocBlockVisitor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 30
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A enterNode() 0 20 3
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer\Visitors;
6
7
use PhpParser\Node;
8
use PhpParser\NodeVisitorAbstract;
9
use SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer\DTO\Output\CommentDTO;
0 ignored issues
show
Bug introduced by
The type SavinMikhail\CommentsDen...r\DTO\Output\CommentDTO was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer\Visitors\Checkers\NodeNeedsDocblockChecker;
0 ignored issues
show
Bug introduced by
The type SavinMikhail\CommentsDen...odeNeedsDocblockChecker was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use SavinMikhail\CommentsDensity\AnalyzeComments\Comments\MissingDocBlock;
12
13
final class MissingDocBlockVisitor extends NodeVisitorAbstract
14
{
15
    /** @var CommentDTO[] */
16
    public array $missingDocBlocks = [];
17
18 31
    public function __construct(
19
        private readonly string $filename,
20
        private readonly NodeNeedsDocblockChecker $nodeChecker,
21 31
    ) {}
22
23 31
    public function enterNode(Node $node): null
24
    {
25 31
        if (! $this->nodeChecker->requiresDocBlock($node)) {
26 31
            return null;
27
        }
28 21
        $docComment = $node->getDocComment();
29 21
        if ($docComment !== null) {
30 12
            return null;
31
        }
32
33 19
        $this->missingDocBlocks[] =
34 19
            new CommentDTO(
35 19
                MissingDocBlock::NAME,
36 19
                MissingDocBlock::COLOR,
37 19
                $this->filename,
38 19
                $node->getLine(),
0 ignored issues
show
Deprecated Code introduced by
The function PhpParser\Node::getLine() has been deprecated: Use getStartLine() instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

38
                /** @scrutinizer ignore-deprecated */ $node->getLine(),

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
39 19
                '',
40 19
            );
41
42 19
        return null;
43
    }
44
}
45