| Conditions | 7 |
| Paths | 18 |
| Total Lines | 42 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | private function sumSkill($limitItems, $isBait = false) |
||
| 37 | { |
||
| 38 | $table = $isBait ? 'users_baits' : 'users_items'; |
||
| 39 | $skill = 0; |
||
| 40 | $countItem = 0; |
||
| 41 | $loop = 0; |
||
| 42 | $limit = 10; |
||
| 43 | do { |
||
| 44 | $doLoop = false; |
||
| 45 | $offset = $loop * $limit; |
||
| 46 | $res = Yii::app()->db->createCommand() |
||
| 47 | ->select('item_id, item_count, skill') |
||
| 48 | ->from($table) |
||
| 49 | ->where('uid=:uid', [':uid'=>Yii::app()->player->uid]) |
||
| 50 | ->order('skill DESC') |
||
| 51 | ->offset($offset) |
||
| 52 | ->limit($limit) |
||
| 53 | ->queryAll(); |
||
| 54 | foreach ($res as $item) { |
||
| 55 | |||
| 56 | $toAdd = $limitItems - $countItem; |
||
| 57 | if ($toAdd > $item['item_count']) { |
||
| 58 | $toAdd = $item['item_count']; |
||
| 59 | } |
||
| 60 | |||
| 61 | $countItem += $toAdd; |
||
| 62 | |||
| 63 | if ($toAdd) { |
||
| 64 | $skill += $toAdd * $item['skill']; |
||
| 65 | } |
||
| 66 | |||
| 67 | $doLoop = $countItem < $limitItems; |
||
| 68 | |||
| 69 | if (!$doLoop) { |
||
| 70 | break; |
||
| 71 | } |
||
| 72 | } |
||
| 73 | $loop++; |
||
| 74 | } while ($doLoop); |
||
| 75 | |||
| 76 | return $skill; |
||
| 77 | } |
||
| 78 | } |
||
| 79 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.