YetiForceCompany/YetiForceCRM

View on GitHub
app/Cron.php

Summary

Maintainability
A
50 mins
Test Coverage
D
61%

Function __destruct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __destruct()
    {
        if (!static::$keepLogFile) {
            if (!static::$logActive) {
                return;
Severity: Minor
Found in app/Cron.php - About 25 mins to fix

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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct()
    {
        static::$scriptTimeStart = microtime(true);
        static::generateStatusFile();
        if (self::$watchdogIsActive) {
Severity: Minor
Found in app/Cron.php - About 25 mins to fix

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

The method log has a boolean flag argument $indent, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function log(string $message, string $level = 'info', bool $indent = true)
Severity: Minor
Found in app/Cron.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Avoid using static access to class 'App\Config' in method '__construct'.
Open

        if (!(static::$logActive = Config::debug('DEBUG_CRON'))) {
Severity: Minor
Found in app/Cron.php by phpmd

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\Config' in method 'getMaxExecutionTime'.
Open

        $maxExecutionTime = (int) Config::main('maxExecutionCronTime');
Severity: Minor
Found in app/Cron.php by phpmd

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\Watchdog' in method '__construct'.
Open

            YetiForce\Watchdog::send();
Severity: Minor
Found in app/Cron.php by phpmd

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 '__construct'.
Open

            Log::error("The mechanism of cron logs has been disabled !!!. No access to the log directory '{$this->logPath}'");
Severity: Minor
Found in app/Cron.php by phpmd

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\Utils\ConfReport' in method 'generateStatusFile'.
Open

            $all = Utils\ConfReport::getAll();
Severity: Minor
Found in app/Cron.php by phpmd

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 assigning values to variables in if clauses and the like (line '99', column '9').
Open

    public function __construct()
    {
        static::$scriptTimeStart = microtime(true);
        static::generateStatusFile();
        if (self::$watchdogIsActive) {
Severity: Minor
Found in app/Cron.php by phpmd

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

Avoid using static access to class 'App\Utils' in method 'generateStatusFile'.
Open

        return file_put_contents(ROOT_DIRECTORY . '/app_data/cron.php', '<?php return ' . Utils::varExport($all) . ';', LOCK_EX);
Severity: Minor
Found in app/Cron.php by phpmd

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 __destruct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $this->log('------------------------------------' . PHP_EOL . Log::getlastLogs(), 'info', false);
        }
Severity: Minor
Found in app/Cron.php by phpmd

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

Avoid using static access to class 'App\Log' in method '__destruct'.
Open

            $this->log('------------------------------------' . PHP_EOL . Log::getlastLogs(), 'info', false);
Severity: Minor
Found in app/Cron.php by phpmd

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

Assigning float to property but \App\Cron::$scriptTimeStart is int|null
Open

        static::$scriptTimeStart = microtime(true);
Severity: Minor
Found in app/Cron.php by phan

Call to method getAll from undeclared class \App\Utils\ConfReport (Did you mean class \Tests\Settings\ConfReport)
Open

            $all = Utils\ConfReport::getAll();
Severity: Critical
Found in app/Cron.php by phan

Call to undeclared method \App\Db\Query::from
Open

        return (new Db\Query())
Severity: Critical
Found in app/Cron.php by phan

Call to undeclared method \App\Db::createCommand
Open

        Db::getInstance()->createCommand()->update('vtiger_cron_task', ['status' => $status], ['name' => $name])->execute();
Severity: Critical
Found in app/Cron.php by phan

Call to method __construct from undeclared class \App\YetiForce\Register
Open

            (new YetiForce\Register())->send();
Severity: Critical
Found in app/Cron.php by phan

Call to method error from undeclared class \App\Log
Open

            Log::error("The mechanism of cron logs has been disabled !!!. No access to the log directory '{$this->logPath}'");
Severity: Critical
Found in app/Cron.php by phan

Call to method getlastLogs from undeclared class \App\Log
Open

            $this->log('------------------------------------' . PHP_EOL . Log::getlastLogs(), 'info', false);
Severity: Critical
Found in app/Cron.php by phan

Call to method send from undeclared class \App\YetiForce\Register
Open

            (new YetiForce\Register())->send();
Severity: Critical
Found in app/Cron.php by phan

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var bool Logging enabled flag
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    const STATUS_ENABLED = 1;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var bool Flag to keep log file after run finish */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var int status enabled
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static $scriptTimeStart;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var bool|string Current log file name
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    const STATUS_RUNNING = 2;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var int|null Script run start time in microtime
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static $cronTimeStart;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public $logPath = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'cache' . \DIRECTORY_SEPARATOR . 'logs' . \DIRECTORY_SEPARATOR . 'cron' . \DIRECTORY_SEPARATOR;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var bool Register enabled flag */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    private static $maxExecutionCronTime;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $all = [];
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return file_put_contents(ROOT_DIRECTORY . '/app_data/cron.php', '<?php return ' . Utils::varExport($all) . ';', LOCK_EX);
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Line exceeds 120 characters; contains 157 characters
Open

    public $logPath = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'cache' . \DIRECTORY_SEPARATOR . 'logs' . \DIRECTORY_SEPARATOR . 'cron' . \DIRECTORY_SEPARATOR;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static $shopIsActive = true;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @throws \App\Exceptions\CacheException
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (self::$watchdogIsActive) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $message = '   ' . $message;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $all['last_start'] = time();
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Line exceeds 120 characters; contains 129 characters
Open

        return file_put_contents(ROOT_DIRECTORY . '/app_data/cron.php', '<?php return ' . Utils::varExport($all) . ';', LOCK_EX);
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getCronExecutionTime()
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $maxExecutionTime = $iniMaxExecutionTime;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var bool Watchdog enabled flag */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Init and configure object.
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function __construct()
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        static::generateStatusFile();
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            YetiForce\Watchdog::send();
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            static::$logActive = false;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var int status disabled
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var int Max execution cron time. */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            (new YetiForce\Register())->send();
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!(static::$logActive = Config::debug('DEBUG_CRON'))) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $level   information type [info, warning, error]
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            return;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        switch ((int) $status) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            default:
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return self::$maxExecutionCronTime = $maxExecutionTime;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return time() >= (self::getMaxExecutionTime() + self::$cronTimeStart);
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Check if it is active function.
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $this->logFile = date('Ymd_Hi') . '.log';
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Remove log file if no value information was stored.
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param bool   $indent  add three spaces at message begin
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $all = Utils\ConfReport::getAll();
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function updateStatus(int $status, string $name): void
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get max execution cron time.
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var int status running
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var int status completed
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var string Log files directory path
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var bool Shop enabled flag */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Line exceeds 120 characters; contains 126 characters
Open

            Log::error("The mechanism of cron logs has been disabled !!!. No access to the log directory '{$this->logPath}'");
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function __destruct()
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        Db::getInstance()->createCommand()->update('vtiger_cron_task', ['status' => $status], ['name' => $name])->execute();
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!static::$keepLogFile) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Line exceeds 120 characters; contains 132 characters
Open

        file_put_contents($this->logPath . $this->logFile, date('Y-m-d H:i:s') . " [{$level}] - {$message}" . PHP_EOL, FILE_APPEND);
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!is_dir($this->logPath) && !mkdir($this->logPath, 0777, true) && !is_dir($this->logPath)) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            Log::error("The mechanism of cron logs has been disabled !!!. No access to the log directory '{$this->logPath}'");
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            static::$keepLogFile = true;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Update cron task status by name.
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int    $status
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return void
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $iniMaxExecutionTime = (int) \ini_get('max_execution_time');
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static $confReportIsActive = true;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($indent) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Gather and save information for YetiForce Status module.
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

                throw new Exceptions\AppException('Invalid status');
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            return self::$maxExecutionCronTime;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (0 !== $iniMaxExecutionTime && $iniMaxExecutionTime < $maxExecutionTime) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            if (!static::$logActive) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

                unlink($this->logPath . $this->logFile);
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $this->log('------------------------------------' . PHP_EOL . Log::getlastLogs(), 'info', false);
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Add log message.
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $message log information
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return float|null
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Line exceeds 120 characters; contains 124 characters
Open

        Db::getInstance()->createCommand()->update('vtiger_cron_task', ['status' => $status], ['name' => $name])->execute();
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return int
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var int|null Cron run start time in microtime
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public $logFile = false;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Calculate current object run time.
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Check max execution cron time.
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Script run start time in microtime.
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static $logActive = false;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (self::$registerIsActive) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!$this->logFile) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        } else {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        file_put_contents($this->logPath . $this->logFile, date('Y-m-d H:i:s') . " [{$level}] - {$message}" . PHP_EOL, FILE_APPEND);
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $name
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            case self::STATUS_DISABLED:
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    const STATUS_DISABLED = 0;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Cron run start time in microtime.
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static $watchdogIsActive = true;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        static::$scriptTimeStart = microtime(true);
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

                return;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            case self::STATUS_RUNNING:
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

                break;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    const STATUS_COMPLETED = 3;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            case self::STATUS_ENABLED:
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $maxExecutionTime = (int) Config::main('maxExecutionCronTime');
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            ->where(['status' => [self::STATUS_ENABLED, self::STATUS_RUNNING], 'handler_class' => $className])
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static $keepLogFile = false;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static $registerIsActive = true;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var bool ConfReport enabled flag */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            return;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!static::$logActive) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if ('error' === $level) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (self::$confReportIsActive) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function getMaxExecutionTime(): int
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function checkCronTimeout(): bool
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->log('File start', 'info', false);
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            if (file_exists($this->logPath . $this->logFile)) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function log(string $message, string $level = 'info', bool $indent = true)
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool|int
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function generateStatusFile()
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return static::$cronTimeStart ? round(microtime(true) - static::$cronTimeStart, 2) : null;
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (isset(self::$maxExecutionCronTime)) {
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $className
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            ->from('vtiger_cron_task')
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function checkActive(string $className): bool
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return (new Db\Query())
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            ->exists();
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Cron.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Cron.php by phpcodesniffer

There are no issues that match your filters.

Category
Status