Method process
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process()
{
\App\Log::trace('Start cron CalDAV');
if(!\App\YetiForce\Shop::check('YetiForceDav')){
$this->logs = \App\YetiForce\Shop::checkAlert('YetiForceDav');
Function process
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function process()
{
\App\Log::trace('Start cron CalDAV');
if(!\App\YetiForce\Shop::check('YetiForceDav')){
$this->logs = \App\YetiForce\Shop::checkAlert('YetiForceDav');
- 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 '36', column '18'). Open
$cardDav = new API_CalDAV_Model();
- 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 '23', column '14'). Open
$dav = new API_DAV_Model();
- 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 'API_DAV_Model' in method 'process'. Open
$davUsers = API_DAV_Model::getAllUser(2);
- 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\Log' in method 'process'. Open
\App\Log::info(__METHOD__ . ' | User is inactive ' . $user->getName());
- 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\Log' in method 'process'. Open
\App\Log::trace('End cron CalDAV');
- 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\Log' in method 'process'. Open
\App\Log::trace('Start cron CalDAV');
- 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\YetiForce\Shop' in method 'process'. Open
if(!\App\YetiForce\Shop::check('YetiForceDav')){
- 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\YetiForce\Shop' in method 'process'. Open
$this->logs = \App\YetiForce\Shop::checkAlert('YetiForceDav');
- 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 'Users_Record_Model' in method 'process'. Open
foreach (Users_Record_Model::getAll() as $id => $user) {
- 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\Log' in method 'process'. Open
\App\Log::trace(__METHOD__ . ' | User is active ' . $user->getName());
- 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
The method process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else { // User is inactive
\App\Log::info(__METHOD__ . ' | User is inactive ' . $user->getName());
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Call to method check
from undeclared class \App\YetiForce\Shop
Open
if(!\App\YetiForce\Shop::check('YetiForceDav')){
- Exclude checks
Call to method checkAlert
from undeclared class \App\YetiForce\Shop
Open
$this->logs = \App\YetiForce\Shop::checkAlert('YetiForceDav');
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('Start cron CalDAV');
- Exclude checks
Call to method getUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$user->set('groups', \App\User::getUserModel($id)->getGroups());
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace(__METHOD__ . ' | User is active ' . $user->getName());
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('End cron CalDAV');
- Exclude checks
Call to method info
from undeclared class \App\Log
Open
\App\Log::info(__METHOD__ . ' | User is inactive ' . $user->getName());
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Calendar_CalDav_Cron extends \App\CronHandler
- Exclude checks
The class Calendar_CalDav_Cron is not named in CamelCase. Open
class Calendar_CalDav_Cron extends \App\CronHandler
{
/** {@inheritdoc} */
public function process()
{
- 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
} else { // User is inactive
- 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
$dav = new API_DAV_Model();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$user->set('calendarsid', $davUsers[$id]['calendarsid']);
- 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
$dav->davUsers[$id] = $user;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::info(__METHOD__ . ' | User is inactive ' . $user->getName());
- 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
\App\Log::trace(__METHOD__ . ' | User is active ' . $user->getName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (Users_Record_Model::getAll() as $id => $user) {
- 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 (isset($davUsers[$id])) {
- 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
\App\Log::trace('Start cron CalDAV');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$davUsers = API_DAV_Model::getAllUser(2);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cardDav = new API_CalDAV_Model();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cardDav->davUsers = $dav->davUsers;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$user->set('david', $davUsers[$id]['david']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$user->set('groups', \App\User::getUserModel($id)->getGroups());
- 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->logs .= ' | dav2Crm: ' . $cardDav->dav2Crm();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return;
- 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
if(!\App\YetiForce\Shop::check('YetiForceDav')){
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->logs = 'crm2Dav: ' . $cardDav->crm2Dav();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace('End cron CalDAV');
- 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->logs = \App\YetiForce\Shop::checkAlert('YetiForceDav');
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if(!\App\YetiForce\Shop::check('YetiForceDav')){
- Exclude checks
Class name "Calendar_CalDav_Cron" is not in camel caps format Open
class Calendar_CalDav_Cron extends \App\CronHandler
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
if(!\App\YetiForce\Shop::check('YetiForceDav')){
- Exclude checks