Conditions | 1 |
Paths | 1 |
Total Lines | 75 |
Code Lines | 15 |
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 |
||
104 | public function generalStatsAction($project, $username) |
||
105 | { |
||
106 | // Set up project and user. |
||
107 | $project = ProjectRepository::getProject($project, $this->container); |
||
1 ignored issue
–
show
|
|||
108 | $user = UserRepository::getUser($username, $this->container); |
||
1 ignored issue
–
show
|
|||
109 | |||
110 | // Get an edit-counter. |
||
111 | $editCounterRepo = new EditCounterRepository(); |
||
112 | $editCounterRepo->setContainer($this->container); |
||
1 ignored issue
–
show
|
|||
113 | $editCounter = new EditCounter($project, $user); |
||
114 | $editCounter->setRepository($editCounterRepo); |
||
115 | |||
116 | // $revisionCounts = $this->editCounterHelper->getRevisionCounts($user->getId($project)); |
||
1 ignored issue
–
show
|
|||
117 | // $pageCounts = $this->editCounterHelper->getPageCounts($username, $revisionCounts['total']); |
||
118 | // $logCounts = $this->editCounterHelper->getLogCounts($user->getId($project)); |
||
119 | // $automatedEditsSummary = $automatedEditsHelper->getEditsSummary($user->getId($project)); |
||
120 | // $topProjectsEditCounts = $this->editCounterHelper->getTopProjectsEditCounts($project->getUrl(), |
||
121 | // $user->getUsername()); |
||
122 | |||
123 | // Render view. |
||
124 | $isSubRequest = $this->get('request_stack')->getParentRequest() !== null; |
||
125 | return $this->render('editCounter/general_stats.html.twig', [ |
||
126 | 'xtPage' => 'ec', |
||
127 | 'is_sub_request' => $isSubRequest, |
||
128 | 'is_labs' => $editCounterRepo->isLabs(), |
||
129 | 'project' => $project, |
||
130 | 'user' => $user, |
||
131 | 'ec' => $editCounter, |
||
132 | |||
133 | // Revision counts. |
||
1 ignored issue
–
show
|
|||
134 | // 'deleted_edits' => $revisionCounts['deleted'], |
||
135 | // 'total_edits' => $revisionCounts['total'], |
||
136 | // 'live_edits' => $revisionCounts['live'], |
||
137 | // 'first_rev' => $revisionCounts['first'], |
||
138 | // 'latest_rev' => $revisionCounts['last'], |
||
139 | // 'days' => $revisionCounts['days'], |
||
140 | // 'avg_per_day' => $revisionCounts['avg_per_day'], |
||
141 | // 'rev_24h' => $revisionCounts['24h'], |
||
142 | // 'rev_7d' => $revisionCounts['7d'], |
||
143 | // 'rev_30d' => $revisionCounts['30d'], |
||
144 | // 'rev_365d' => $revisionCounts['365d'], |
||
145 | // 'rev_small' => $revisionCounts['small'], |
||
146 | // 'rev_large' => $revisionCounts['large'], |
||
147 | // 'with_comments' => $revisionCounts['with_comments'], |
||
148 | // 'without_comments' => $revisionCounts['live'] - $revisionCounts['with_comments'], |
||
149 | // 'minor_edits' => $revisionCounts['minor_edits'], |
||
150 | // 'nonminor_edits' => $revisionCounts['live'] - $revisionCounts['minor_edits'], |
||
151 | // 'auto_edits_total' => array_sum($automatedEditsSummary), |
||
152 | // |
||
153 | // // Page counts. |
||
154 | // 'uniquePages' => $pageCounts['unique'], |
||
155 | // 'pagesCreated' => $pageCounts['created'], |
||
156 | // 'pagesMoved' => $pageCounts['moved'], |
||
157 | // 'editsPerPage' => $pageCounts['edits_per_page'], |
||
158 | // |
||
159 | // // Log counts (keys are 'log name'-'action'). |
||
160 | // 'pagesThanked' => $logCounts['thanks-thank'], |
||
161 | // 'pagesApproved' => $logCounts['review-approve'], // Merged -a, -i, and -ia approvals. |
||
162 | // 'pagesPatrolled' => $logCounts['patrol-patrol'], |
||
163 | // 'usersBlocked' => $logCounts['block-block'], |
||
164 | // 'usersUnblocked' => $logCounts['block-unblock'], |
||
165 | // 'pagesProtected' => $logCounts['protect-protect'], |
||
166 | // 'pagesUnprotected' => $logCounts['protect-unprotect'], |
||
167 | // 'pagesDeleted' => $logCounts['delete-delete'], |
||
168 | // 'pagesDeletedRevision' => $logCounts['delete-revision'], |
||
169 | // 'pagesRestored' => $logCounts['delete-restore'], |
||
170 | // 'pagesImported' => $logCounts['import-import'], |
||
171 | // 'files_uploaded' => $logCounts['upload-upload'], |
||
172 | // 'files_modified' => $logCounts['upload-overwrite'], |
||
173 | // 'files_uploaded_commons' => $logCounts['files_uploaded_commons'], |
||
174 | // |
||
175 | // // Other projects. |
||
176 | // 'top_projects_edit_counts' => $topProjectsEditCounts, |
||
177 | ]); |
||
178 | } |
||
179 | |||
285 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.