Method getDocumentEvents
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getDocumentEvents($browserReloadPort)
{
if (!$browserReloadPort) {
return [];
}
Function getDocumentEvents
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getDocumentEvents($browserReloadPort)
{
if (!$browserReloadPort) {
return [];
}
- 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 'Phug\Phug' in method 'getOption'. Open
: (Phug::hasOption($name) ? Phug::getOption($name) : null)
- 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 'Phug\Phug' in method 'getOption'. Open
: (Phug::hasOption($name) ? Phug::getOption($name) : null)
- 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 'Phug\Phug' in method 'watch'. Open
return Phug::cacheFile($path);
- 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 'Phug\Phug' in method 'getOption'. Open
$options = Phug::getOptions();
- 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 unused parameters such as '$resource'. Open
$watcher->setChangeEventCallback(function ($event, $resource, $path) {
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$event'. Open
$watcher->setChangeEventCallback(function ($event, $resource, $path) {
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Possibly zero references to use statement for classlike/namespace DocumentNode
(\Phug\Parser\Node\DocumentNode)
Open
use Phug\Parser\Node\DocumentNode;
- Exclude checks
Call to method __construct
from undeclared class \Phug\Parser\Node\ElementNode
Open
$reloadScript = new ElementNode($document->getToken());
- Exclude checks
Checking instanceof against undeclared class \Phug\Parser\Node\ElementNode
Open
if ($child instanceof ElementNode && strtolower($child->getName()) === 'body') {
- Exclude checks
Class extends undeclared class \Phug\AbstractExtension
Open
class WatcherExtension extends AbstractExtension
- Exclude checks
Call to method appendChild
from undeclared class \Phug\Parser\Node\ElementNode
Open
$reloadScript->appendChild($code);
- Exclude checks
Call to method getRenderer
from undeclared class \Phug\Phug
Open
$sandbox = Phug::getRenderer()->getNewSandBox(function () use ($path) {
- Exclude checks
Checking instanceof against undeclared class \Phug\Parser\Node\ElementNode
Open
if ($child instanceof ElementNode && strtolower($child->getName()) === 'html') {
- Exclude checks
Call to method setName
from undeclared class \Phug\Parser\Node\ElementNode
Open
$reloadScript->setName('script');
- Exclude checks
Call to method getName
from undeclared class \Phug\Parser\Node\ElementNode
Open
if ($child instanceof ElementNode && strtolower($child->getName()) === 'html') {
- Exclude checks
Call to method setValue
from undeclared class \Phug\Parser\Node\TextNode
Open
$code->setValue("window.onload = function () { $addScript };");
- Exclude checks
Parameter $event
has undeclared type \Phug\Parser\Event\NodeEvent
Open
return [function (NodeEvent $event) use ($browserReloadPort) {
- Exclude checks
Call to method getName
from undeclared class \Phug\Parser\Node\ElementNode
Open
if ($child instanceof ElementNode && strtolower($child->getName()) === 'body') {
- Exclude checks
Call to method cacheFile
from undeclared class \Phug\Phug
Open
return Phug::cacheFile($path);
- Exclude checks
Call to method getNode
from undeclared class \Phug\Parser\Event\NodeEvent
Open
$document = $event->getNode();
- Exclude checks
Call to method getOptions
from undeclared class \Phug\Phug
Open
$options = Phug::getOptions();
- Exclude checks
Call to method getOption
from undeclared class \Phug\Phug
Open
: (Phug::hasOption($name) ? Phug::getOption($name) : null)
- Exclude checks
Call to method hasOption
from undeclared class \Phug\Phug
Open
: (Phug::hasOption($name) ? Phug::getOption($name) : null)
- Exclude checks
Call to method __construct
from undeclared class \Phug\Parser\Node\TextNode
Open
$code = new TextNode();
- Exclude checks