Conditions | 9 |
Paths | 5 |
Total Lines | 60 |
Code Lines | 48 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
65 | public function rankRefresh() |
||
66 | { |
||
67 | $ret=[]; |
||
68 | $participants=$this->participants(); |
||
69 | $contest_problems=$this->problems; |
||
70 | $contest_problems->load('problem'); |
||
71 | if ($this->rule==1) { |
||
72 | // ACM/ICPC Mode |
||
73 | foreach ($participants as $participant) { |
||
74 | $prob_detail=[]; |
||
75 | $totPen=0; |
||
76 | $totScore=0; |
||
77 | foreach ($contest_problems as $contest_problem) { |
||
78 | $prob_stat=$contest_problem->userStatus($participant); |
||
79 | $prob_detail[]=[ |
||
80 | 'ncode'=>$contest_problem->ncode, |
||
81 | 'pid'=>$contest_problem->pid, |
||
82 | 'color'=>$prob_stat['color'], |
||
83 | 'wrong_doings'=>$prob_stat['wrong_doings'], |
||
84 | 'solved_time_parsed'=>$prob_stat['solved_time_parsed'] |
||
85 | ]; |
||
86 | if ($prob_stat['solved']) { |
||
87 | $totPen+=$prob_stat['wrong_doings'] * 20; |
||
88 | $totPen+=$prob_stat['solved_time'] / 60; |
||
89 | $totScore+=$prob_stat['solved']; |
||
90 | } |
||
91 | } |
||
92 | $ret[]=[ |
||
93 | "uid" => $participant->id, |
||
94 | "name" => $participant->name, |
||
95 | "nick_name" => DB::table("group_member")->where([ |
||
96 | "uid" => $participant->id, |
||
97 | "gid" => $this->group->gid |
||
98 | ])->where("role", ">", 0)->first()["nick_name"] ?? '', |
||
99 | "score" => $totScore, |
||
100 | "penalty" => $totPen, |
||
101 | "problem_detail" => $prob_detail |
||
102 | ]; |
||
103 | } |
||
104 | usort($ret, function($a, $b) { |
||
105 | if ($a["score"]==$b["score"]) { |
||
106 | if ($a["penalty"]==$b["penalty"]) { |
||
107 | return 0; |
||
108 | } elseif (($a["penalty"]>$b["penalty"])) { |
||
109 | return 1; |
||
110 | } else { |
||
111 | return -1; |
||
112 | } |
||
113 | } elseif ($a["score"]>$b["score"]) { |
||
114 | return -1; |
||
115 | } else { |
||
116 | return 1; |
||
117 | } |
||
118 | }); |
||
119 | Cache::tags(['contest', 'rank'])->put($this->cid, $ret, 60); |
||
120 | return $ret; |
||
121 | } else { |
||
122 | // IO Mode |
||
123 | $c=new OutdatedContestModel(); |
||
124 | return $c->contestRankCache($this->cid); |
||
125 | } |
||
184 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths