Function process
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function process()
{
if (\App\Integrations\SMSProvider::isActiveProvider()) {
$queryGenerator = new \App\QueryGenerator($this->moduelName);
$dataReader = $queryGenerator->setFields(['id'])
- 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 '26', column '26'). Open
$queryGenerator = new \App\QueryGenerator($this->moduelName);
- 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
Avoid using static access to class '\App\Config' in method 'process'. Open
->setLimit(\App\Config::module($this->moduelName, 'maxCronSentSMS'))
- 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 '\SMSNotifier_Record_Model' in method 'process'. Open
$recordModel = \SMSNotifier_Record_Model::getInstanceById($recordId, $this->moduelName);
- 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 '\App\Integrations\SMSProvider' in method 'process'. Open
if (\App\Integrations\SMSProvider::isActiveProvider()) {
- 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
Remove this unused "STATUS_QUEUE" private field. Open
private const STATUS_QUEUE = 'PLL_QUEUE';
- Read upRead up
- Exclude checks
If a private
field is declared but not used in the program, it can be considered dead code and should therefore be removed. This will
improve maintainability because developers will not wonder what the variable is used for.
Noncompliant Code Example
class MyClass { private $foo = 4; //foo is unused public function compute($a) { return $a * 4; } }
Compliant Solution
class MyClass { public function compute($a) { return $a * 4; } }
See
- CERT, MSC12-CPP. - Detect and remove code that has no effect
Call to method setFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$dataReader = $queryGenerator->setFields(['id'])
- Exclude checks
Call to method __construct
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator = new \App\QueryGenerator($this->moduelName);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class SMSNotifier_SMSNotifier_Cron extends \App\CronHandler
- Exclude checks
The class SMSNotifier_SMSNotifier_Cron is not named in CamelCase. Open
class SMSNotifier_SMSNotifier_Cron extends \App\CronHandler
{
/** @var string Status */
private const STATUS_QUEUE = 'PLL_QUEUE';
/** @var string Module name */
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->send();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function process()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\Integrations\SMSProvider::isActiveProvider()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = $queryGenerator->setFields(['id'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($recordId = $dataReader->readColumn(0)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator = new \App\QueryGenerator($this->moduelName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = \SMSNotifier_Record_Model::getInstanceById($recordId, $this->moduelName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private const STATUS_QUEUE = 'PLL_QUEUE';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $moduelName = 'SMSNotifier';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->createQuery()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Module name */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->updateLastActionTime();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setLimit(\App\Config::module($this->moduelName, 'maxCronSentSMS'))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Status */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->addCondition('smsnotifier_status', static::STATUS_QUEUE, 'e')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->checkTimeout()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Class name "SMSNotifier_SMSNotifier_Cron" is not in camel caps format Open
class SMSNotifier_SMSNotifier_Cron extends \App\CronHandler
- Exclude checks