Function stop
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
public function stop()
{
$pid = $this->getPid();
if (!empty($pid) && $pid) {
if (swoole_process::kill($pid, 0)) {
Function setWorkNum
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
private function setWorkNum($jobs)
{
$workerNum = 0;
foreach ($jobs as $job) {
$taskWorkerNum = 0;
Missing class import via use statement (line '343', column '20').
$app = new \Group\App\App();
The method workerCallBack uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
foreach ($server as $one) {
$this->handleJob($one, $recv, $listener, $timer);
}
}
The method initPheanstalk uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
$this->pheanstalk[] = $pheanstalk;
}
The method initParam uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
foreach ($server as $one) {
$this->initPheanstalk($one['host'], $one['port']);
}
}
The method checkStatus() contains an exit expression.
exit('队列服务已启动!');
Avoid unused parameters such as '$pipe'.
swoole_event_add($worker->pipe, function($pipe) use ($worker, $server, $listener, $timer) {
Avoid unused parameters such as '$timerId'.
swoole_timer_tick(intval($timer), function($timerId) use ($recv, $listener, $pheanstalk){
Avoid unused parameters such as '$signo'.
swoole_process::signal(SIGTERM, function ($signo) use ($worker) {
Avoid unused local variables such as '$job'.
foreach ($recv['handle'] as $handerClass => $job) {
Avoid unused local variables such as '$key'.
foreach ($job as $key => $value) {
Avoid unused parameters such as '$signo'.
swoole_process::signal(SIGCHLD, function ($signo) {
Avoid unused local variables such as '$value'.
foreach ($job as $handerClass => $value) {
Expected 1 space before opening brace; found 0
swoole_timer_tick(intval($timer), function($timerId) use ($recv, $listener, $pheanstalk){
Spaces must be used for alignment; tabs are not allowed
Expected 1 space after FUNCTION keyword; 0 found
swoole_event_add($worker->pipe, function($pipe) use ($worker, $server, $listener, $timer) {
Expected 1 space after FUNCTION keyword; 0 found
swoole_timer_tick(intval($timer), function($timerId) use ($recv, $listener, $pheanstalk){
Spaces must be used for alignment; tabs are not allowed
Spaces must be used for alignment; tabs are not allowed
Spaces must be used for alignment; tabs are not allowed
Spaces must be used for alignment; tabs are not allowed
$pid = $this->getPid();
Blank line found at end of control structure
Spaces must be used for alignment; tabs are not allowed
{
Spaces must be used for alignment; tabs are not allowed
if (file_exists($this->logDir."/pid"))
Spaces must be used for alignment; tabs are not allowed
{
Spaces must be used for alignment; tabs are not allowed
$this->logDir = \Config::get("queue::log_dir");
Line exceeds 120 characters; contains 210 characters
\Log::error("jobId:".$recv['job']->getId()."任务出错了!", ['jobId' => $recv['job']->getId(), 'jobData' => $recv['job']->getData(), 'message' => $e->getMessage()], 'queue.worker');
Inline control structures are not allowed
if (file_exists($this->logDir."/pid"))
Line exceeds 120 characters; contains 132 characters
Line exceeds 120 characters; contains 128 characters
Inline control structures are not allowed
if(function_exists("opcache_reset")) opcache_reset();
Whitespace found at end of line
$this->bootstrapClass($loader, $this->listener->getJobs());
Expected 1 space after TRY keyword; 0 found
try{
Whitespace found at end of line
}
Whitespace found at end of line
{
Whitespace found at end of line
$recv = unserialize($recv);
Line indented incorrectly; expected at least 28 spaces, found 27
$handler = new $handerClass($recv['job']->getId(), $recv['job']->getData());
Whitespace found at end of line
}
Whitespace found at end of line
{
Expected 1 space after IF keyword; 0 found
if(!$pheanstalk->getConnection()->isServiceListening()) {
Line indented incorrectly; expected 16 spaces, found 15
if ($taskWorkerNum < $value['task_worker_num']) {
Closing brace indented incorrectly; expected 15 spaces, found 16
}
Whitespace found at end of line
{
Expected 1 space after WHILE keyword; 0 found
while($ret = swoole_process::wait(false)) {
Whitespace found at end of line
{
Whitespace found at end of line
* @param loader
Expected 1 space after closing brace; 0 found
}catch(\Exception $e){
Whitespace found at end of line
$this->logDir = \Config::get("queue::log_dir");
Whitespace found at end of line
public function workerCallBack(swoole_process $worker)
Whitespace found at end of line
}
Whitespace found at end of line
{
Whitespace found at end of line
$this->timer = \Config::get("queue::timer");
Whitespace found at end of line
* @param jobs
Expected 1 space after closing parenthesis; found 0
if ($worker_count >= $this->workerNum){
Line indented incorrectly; expected at least 28 spaces, found 27
$handler->handle();
Whitespace found at end of line
$this->initParam($loader);
Whitespace found at end of line
$this->setPid();
Whitespace found at end of line
}
Expected 1 space after CATCH keyword; 0 found
}catch(\Exception $e){
Whitespace found at end of line
* @param loader
Whitespace found at end of line
$this->classCache = \Config::get("queue::class_cache");
Expected 1 space after IF keyword; 0 found
if(function_exists("opcache_reset")) opcache_reset();
Whitespace found at end of line
{
Whitespace found at end of line
* @param jobs
Whitespace found at end of line
swoole_process::kill($this->getPid(), SIGKILL);
Expected 1 space after closing parenthesis; found 0
}catch(\Exception $e){
The variable $work_id is not named in camelCase.
public function stop()
{
$pid = $this->getPid();
if (!empty($pid) && $pid) {
if (swoole_process::kill($pid, 0)) {
The variable $work_id is not named in camelCase.
public function stop()
{
$pid = $this->getPid();
if (!empty($pid) && $pid) {
if (swoole_process::kill($pid, 0)) {
The variable $worker_count is not named in camelCase.
private function setSignal()
{
swoole_process::signal(SIGCHLD, function ($signo) {
The variable $worker_count is not named in camelCase.
private function setSignal()
{
swoole_process::signal(SIGCHLD, function ($signo) {
The variable $work_id is not named in camelCase.
public function stop()
{
$pid = $this->getPid();
if (!empty($pid) && $pid) {
if (swoole_process::kill($pid, 0)) {
There are no issues that match your filters.