fucongcong/framework

View on GitHub
core/Group/Queue/Bear.php

Summary

Maintainability
A
1 hr
Test Coverage

Showing 72 of 72 total issues

Function stop has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

public function stop()
{
$pid = $this->getPid();
if (!empty($pid) && $pid) {
if (swoole_process::kill($pid, 0)) {
Severity: Minor
Found in core/Group/Queue/Bear.php - About 1 hr to fix

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

private function setWorkNum($jobs)
{
$workerNum = 0;
foreach ($jobs as $job) {
$taskWorkerNum = 0;
Severity: Minor
Found in core/Group/Queue/Bear.php - About 25 mins to fix

Missing class import via use statement (line '343', column '20').
Open

$app = new \Group\App\App();
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

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

} else {
foreach ($server as $one) {
$this->handleJob($one, $recv, $listener, $timer);
}
}
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

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

} else {
$this->pheanstalk[] = $pheanstalk;
}
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

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

} else {
foreach ($server as $one) {
$this->initPheanstalk($one['host'], $one['port']);
}
}
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

The method checkStatus() contains an exit expression.
Open

exit('队列服务已启动!');
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

Avoid unused parameters such as '$pipe'.
Open

swoole_event_add($worker->pipe, function($pipe) use ($worker, $server, $listener, $timer) {
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

Avoid unused parameters such as '$timerId'.
Open

swoole_timer_tick(intval($timer), function($timerId) use ($recv, $listener, $pheanstalk){
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

Avoid unused parameters such as '$signo'.
Open

swoole_process::signal(SIGTERM, function ($signo) use ($worker) {
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

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

foreach ($recv['handle'] as $handerClass => $job) {
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

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

foreach ($job as $key => $value) {
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

Avoid unused parameters such as '$signo'.
Open

swoole_process::signal(SIGCHLD, function ($signo) {
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

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

foreach ($job as $handerClass => $value) {
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

Expected 1 space before opening brace; found 0
Open

swoole_timer_tick(intval($timer), function($timerId) use ($recv, $listener, $pheanstalk){
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

swoole_event_add($worker->pipe, function($pipe) use ($worker, $server, $listener, $timer) {
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

swoole_timer_tick(intval($timer), function($timerId) use ($recv, $listener, $pheanstalk){
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

//主进程重启时收到的信号,该信号用于用户自定义
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

// swoole_process::signal(SIGUSR1, function ($signo) {
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

// });
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

$pid = $this->getPid();
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Blank line found at end of control structure
Open

Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

{
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

if (file_exists($this->logDir."/pid"))
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

{
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Spaces must be used for alignment; tabs are not allowed
Open

$this->logDir = \Config::get("queue::log_dir");
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Line exceeds 120 characters; contains 210 characters
Open

\Log::error("jobId:".$recv['job']->getId()."任务出错了!", ['jobId' => $recv['job']->getId(), 'jobData' => $recv['job']->getData(), 'message' => $e->getMessage()], 'queue.worker');
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Inline control structures are not allowed
Open

if (file_exists($this->logDir."/pid"))
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Line exceeds 120 characters; contains 132 characters
Open

//删除任务 是否应该放到用户队列任务 让用户自行删除?包括可以操作release和bury
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Line exceeds 120 characters; contains 128 characters
Open

//\Log::info("jobId:".$recv['job']->getId()."任务完成".$recv['job']->getData(), [], 'queue.worker');
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Inline control structures are not allowed
Open

if(function_exists("opcache_reset")) opcache_reset();
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

$this->bootstrapClass($loader, $this->listener->getJobs());
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Expected 1 space after TRY keyword; 0 found
Open

try{
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

}
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

{
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

$recv = unserialize($recv);
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Line indented incorrectly; expected at least 28 spaces, found 27
Open

$handler = new $handerClass($recv['job']->getId(), $recv['job']->getData());
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

}
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

{
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Expected 1 space after IF keyword; 0 found
Open

if(!$pheanstalk->getConnection()->isServiceListening()) {
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Line indented incorrectly; expected 16 spaces, found 15
Open

if ($taskWorkerNum < $value['task_worker_num']) {
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Closing brace indented incorrectly; expected 15 spaces, found 16
Open

}
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

{
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Expected 1 space after WHILE keyword; 0 found
Open

while($ret = swoole_process::wait(false)) {
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

{
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

* @param loader
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Expected 1 space after closing brace; 0 found
Open

}catch(\Exception $e){
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

$this->logDir = \Config::get("queue::log_dir");
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

public function workerCallBack(swoole_process $worker)
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

}
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

{
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

$this->timer = \Config::get("queue::timer");
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

* @param jobs
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Expected 1 space after closing parenthesis; found 0
Open

if ($worker_count >= $this->workerNum){
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Line indented incorrectly; expected at least 28 spaces, found 27
Open

$handler->handle();
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

$this->initParam($loader);
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

$this->setPid();
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

}
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Expected 1 space after CATCH keyword; 0 found
Open

}catch(\Exception $e){
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

* @param loader
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

$this->classCache = \Config::get("queue::class_cache");
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Expected 1 space after IF keyword; 0 found
Open

if(function_exists("opcache_reset")) opcache_reset();
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

{
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

* @param jobs
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Whitespace found at end of line
Open

swoole_process::kill($this->getPid(), SIGKILL);
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

Expected 1 space after closing parenthesis; found 0
Open

}catch(\Exception $e){
Severity: Minor
Found in core/Group/Queue/Bear.php by phpcodesniffer

The variable $work_id is not named in camelCase.
Open

public function stop()
{
$pid = $this->getPid();
if (!empty($pid) && $pid) {
if (swoole_process::kill($pid, 0)) {
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

The variable $work_id is not named in camelCase.
Open

public function stop()
{
$pid = $this->getPid();
if (!empty($pid) && $pid) {
if (swoole_process::kill($pid, 0)) {
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

The variable $worker_count is not named in camelCase.
Open

private function setSignal()
{
//子进程结束时主进程收到的信号
swoole_process::signal(SIGCHLD, function ($signo) {
 
 
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

The variable $worker_count is not named in camelCase.
Open

private function setSignal()
{
//子进程结束时主进程收到的信号
swoole_process::signal(SIGCHLD, function ($signo) {
 
 
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd

The variable $work_id is not named in camelCase.
Open

public function stop()
{
$pid = $this->getPid();
if (!empty($pid) && $pid) {
if (swoole_process::kill($pid, 0)) {
Severity: Minor
Found in core/Group/Queue/Bear.php by phpmd
Category
Status