fucongcong/framework

View on GitHub
core/Group/Cron/CronAdmin.php

Summary

Maintainability
A
2 hrs
Test Coverage

Showing 28 of 28 total issues

The class CronAdmin has 11 public methods. Consider refactoring CronAdmin to keep number of public methods under 10.
Open

class CronAdmin
{
protected $http;
 
protected $jobs;
Severity: Minor
Found in core/Group/Cron/CronAdmin.php by phpmd

Method __construct has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public function __construct()
{
$this->mkDir(__FILEROOT__.'runtime/cron-server');
$http = new swoole_http_server('0.0.0.0', '10008');
$http->set(array(
Severity: Major
Found in core/Group/Cron/CronAdmin.php - About 2 hrs to fix

    The method __construct() has an NPath complexity of 2048. The configured NPath complexity threshold is 200.
    Open

    public function __construct()
    {
    $this->mkDir(__FILEROOT__.'runtime/cron-server');
    $http = new swoole_http_server('0.0.0.0', '10008');
    $http->set(array(
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    The method __construct() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
    Open

    public function __construct()
    {
    $this->mkDir(__FILEROOT__.'runtime/cron-server');
    $http = new swoole_http_server('0.0.0.0', '10008');
    $http->set(array(
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    Avoid using undefined variables such as '$env' which will lead to PHP notices.
    Open

    $twig = new \Twig_Environment($loader, isset($env) ? $env : array());
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    Avoid using undefined variables such as '$env' which will lead to PHP notices.
    Open

    $twig = new \Twig_Environment($loader, isset($env) ? $env : array());
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    Remove error control operator '@' on line 166.
    Open

    public function onShutdown($serv)
    {
    @unlink($this->pidPath);
    echo "HTTP Server Shutdown...".PHP_EOL;
    }
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    Missing class import via use statement (line '207', column '23').
    Open

    $loader = new \Twig_Loader_Filesystem(dirname(__FILE__)."/View");
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    Missing class import via use statement (line '208', column '21').
    Open

    $twig = new \Twig_Environment($loader, isset($env) ? $env : array());
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

    } else {
    $works[] = ['job' => $job, 'pid' => $work_id[0]];
    }
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    Avoid unused parameters such as '$post'.
    Open

    public function stopMaster($post)
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    Avoid unused local variables such as '$file'.
    Open

    $file = array_pop($parts);
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    Avoid unused parameters such as '$workerId'.
    Open

    public function onWorkerStart($serv, $workerId)
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    Avoid unused parameters such as '$post'.
    Open

    public function startMaster($post)
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    Avoid unused parameters such as '$serv'.
    Open

    public function onShutdown($serv)
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    Avoid unused parameters such as '$post'.
    Open

    public function reloadServer($post)
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    Avoid unused parameters such as '$serv'.
    Open

    public function onWorkerStart($serv, $workerId)
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    Opening class brace must be on a line by itself
    Open

    {

    Expected 1 space before opening brace; found 0
    Open

    $http->on('request', function ($request, $response){

    Whitespace found at end of line
    Open

    {

    Whitespace found at end of line
    Open

    {

    Whitespace found at end of line
    Open

    {

    Whitespace found at end of line
    Open

    'dispatch_mode' => 3,

    Whitespace found at end of line
    Open

    {

    The variable $work_id is not named in camelCase.
    Open

    public function __construct()
    {
    $this->mkDir(__FILEROOT__.'runtime/cron-server');
    $http = new swoole_http_server('0.0.0.0', '10008');
    $http->set(array(
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    The variable $work_id is not named in camelCase.
    Open

    public function __construct()
    {
    $this->mkDir(__FILEROOT__.'runtime/cron-server');
    $http = new swoole_http_server('0.0.0.0', '10008');
    $http->set(array(
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    The variable $work_id is not named in camelCase.
    Open

    public function __construct()
    {
    $this->mkDir(__FILEROOT__.'runtime/cron-server');
    $http = new swoole_http_server('0.0.0.0', '10008');
    $http->set(array(
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd

    The variable $work_id is not named in camelCase.
    Open

    public function __construct()
    {
    $this->mkDir(__FILEROOT__.'runtime/cron-server');
    $http = new swoole_http_server('0.0.0.0', '10008');
    $http->set(array(
    Severity: Minor
    Found in core/Group/Cron/CronAdmin.php by phpmd
    Category
    Status