Completed
Pull Request — master (#111)
by MusikAnimal
02:40
created
src/AppBundle/Controller/EditSummaryController.php 3 patches
Spacing   +4 added lines, -6 removed lines patch added patch discarded remove patch
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
     {
144 144
         $dbName = $project->getDatabaseName();
145 145
 
146
-        $cacheKey = 'editsummaryusage.' . $dbName . '.'
147
-            . $user->getCacheKey() . '.' . $namespace;
146
+        $cacheKey = 'editsummaryusage.'.$dbName.'.'
147
+            . $user->getCacheKey().'.'.$namespace;
148 148
 
149 149
         $cache = $this->container->get('cache.app');
150 150
         if ($cache->hasItem($cacheKey)) {
@@ -231,8 +231,7 @@  discard block
 block discarded – undo
231 231
             if ($row['rev_minor_edit'] == 0) {
232 232
                 if ($row['rev_comment'] !== '') {
233 233
                     isset($monthEditsummaryTotals[$monthkey]) ?
234
-                        $monthEditsummaryTotals[$monthkey]++ :
235
-                        $monthEditsummaryTotals[$monthkey] = 1;
234
+                        $monthEditsummaryTotals[$monthkey]++ : $monthEditsummaryTotals[$monthkey] = 1;
236 235
                     $totalSummariesMajor++;
237 236
                 }
238 237
 
@@ -249,8 +248,7 @@  discard block
 block discarded – undo
249 248
                 // If there is a comment, count it
250 249
                 if ($row['rev_comment'] !== '') {
251 250
                     isset($monthEditsummaryTotals[$monthkey]) ?
252
-                        $monthEditsummaryTotals[$monthkey]++ :
253
-                        $monthEditsummaryTotals[$monthkey] = 1;
251
+                        $monthEditsummaryTotals[$monthkey]++ : $monthEditsummaryTotals[$monthkey] = 1;
254 252
                     $totalSummariesMinor++;
255 253
                     $totalEditsMinor++;
256 254
                 } else {
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -11,9 +11,7 @@
 block discarded – undo
11 11
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
12 12
 use Symfony\Component\HttpFoundation\Request;
13 13
 use Symfony\Component\HttpFoundation\Response;
14
-use Psr\Cache\CacheItemPoolInterface;
15 14
 use Xtools\Project;
16
-use Xtools\ProjectRepository;
17 15
 use Xtools\User;
18 16
 use DateTime;
19 17
 use DateInterval;
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
      * Display the Edit Summary results
75 75
      *
76 76
      * @param Request $request The HTTP request.
77
-     * @param string $namespace Namespace ID or 'all' for all namespaces.
77
+     * @param integer $namespace Namespace ID or 'all' for all namespaces.
78 78
      *
79 79
      * @Route("/editsummary/{project}/{username}/{namespace}", name="EditSummaryResult")
80 80
      *
Please login to merge, or discard this patch.
src/AppBundle/Controller/AutomatedEditsController.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -151,8 +151,8 @@
 block discarded – undo
151 151
         // Get individual counts of how many times each tool was used.
152 152
         // This also includes a wikilink to the tool.
153 153
         $toolCounts = $user->getAutomatedCounts($projectData, $namespace, $start, $end);
154
-        $toolsTotal = array_reduce($toolCounts, function ($a, $b) {
155
-            return $a + $b['count'];
154
+        $toolsTotal = array_reduce($toolCounts, function($a, $b) {
155
+            return $a+$b['count'];
156 156
         });
157 157
 
158 158
         // Query to get combined (semi)automated using for all edits
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -11,9 +11,7 @@
 block discarded – undo
11 11
 use Symfony\Component\HttpFoundation\RedirectResponse;
12 12
 use Symfony\Component\HttpFoundation\Request;
13 13
 use Symfony\Component\HttpFoundation\Response;
14
-use Xtools\ProjectRepository;
15 14
 use Xtools\User;
16
-use Xtools\UserRepository;
17 15
 
18 16
 /**
19 17
  * This controller serves the AutomatedEdits tool.
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
      *     }
79 79
      * )
80 80
      * @param Request $request The HTTP request.
81
-     * @param int|string $namespace
81
+     * @param integer $namespace
82 82
      * @param null|string $start
83 83
      * @param null|string $end
84 84
      * @return RedirectResponse|Response
Please login to merge, or discard this patch.
src/AppBundle/Controller/TopEditsController.php 2 patches
Unused Use Statements   -4 removed lines patch added patch discarded remove patch
@@ -11,12 +11,8 @@
 block discarded – undo
11 11
 use Symfony\Component\HttpFoundation\RedirectResponse;
12 12
 use Symfony\Component\HttpFoundation\Request;
13 13
 use Symfony\Component\HttpFoundation\Response;
14
-use Xtools\Page;
15
-use Xtools\PagesRepository;
16 14
 use Xtools\Project;
17
-use Xtools\ProjectRepository;
18 15
 use Xtools\User;
19
-use Xtools\UserRepository;
20 16
 use Xtools\TopEdits;
21 17
 use Xtools\TopEditsRepository;
22 18
 use Xtools\Edit;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@
 block discarded – undo
191 191
         // Send all to the template.
192 192
         return $this->render('topedits/result_article.html.twig', [
193 193
             'xtPage' => 'topedits',
194
-            'xtTitle' => $user->getUsername() . ' - ' . $page->getTitle(),
194
+            'xtTitle' => $user->getUsername().' - '.$page->getTitle(),
195 195
             'project' => $project,
196 196
             'user' => $user,
197 197
             'page' => $page,
Please login to merge, or discard this patch.
src/AppBundle/Controller/AdminScoreController.php 2 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -10,10 +10,7 @@
 block discarded – undo
10 10
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
11 11
 use Symfony\Component\HttpFoundation\Request;
12 12
 use Symfony\Component\HttpFoundation\Response;
13
-use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
14 13
 use DateTime;
15
-use Xtools\ProjectRepository;
16
-use Xtools\UserRepository;
17 14
 
18 15
 /**
19 16
  * The AdminScoreController serves the search form and results page of the AdminScore tool
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -91,20 +91,20 @@  discard block
 block discarded – undo
91 91
 
92 92
         // MULTIPLIERS (to review)
93 93
         $multipliers = [
94
-            'account-age-mult' => 1.25,             # 0 if = 365 jours
95
-            'edit-count-mult' => 1.25,              # 0 if = 10 000
96
-            'user-page-mult' => 0.1,                # 0 if =
97
-            'patrols-mult' => 1,                    # 0 if =
98
-            'blocks-mult' => 1.4,                   # 0 if = 10
94
+            'account-age-mult' => 1.25, # 0 if = 365 jours
95
+            'edit-count-mult' => 1.25, # 0 if = 10 000
96
+            'user-page-mult' => 0.1, # 0 if =
97
+            'patrols-mult' => 1, # 0 if =
98
+            'blocks-mult' => 1.4, # 0 if = 10
99 99
             'afd-mult' => 1.15,
100
-            'recent-activity-mult' => 0.9,          # 0 if =
100
+            'recent-activity-mult' => 0.9, # 0 if =
101 101
             'aiv-mult' => 1.15,
102
-            'edit-summaries-mult' => 0.8,           # 0 if =
103
-            'namespaces-mult' => 1.0,               # 0 if =
104
-            'pages-created-live-mult' => 1.4,       # 0 if =
105
-            'pages-created-deleted-mult' => 1.4,    # 0 if =
106
-            'rpp-mult' => 1.15,                     # 0 if =
107
-            'user-rights-mult' => 0.75,             # 0 if =
102
+            'edit-summaries-mult' => 0.8, # 0 if =
103
+            'namespaces-mult' => 1.0, # 0 if =
104
+            'pages-created-live-mult' => 1.4, # 0 if =
105
+            'pages-created-deleted-mult' => 1.4, # 0 if =
106
+            'rpp-mult' => 1.15, # 0 if =
107
+            'user-rights-mult' => 0.75, # 0 if =
108 108
         ];
109 109
 
110 110
         // Grab the connection to the replica database (which is separate from the above)
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
                 $now = new DateTime();
183 183
                 $date = new DateTime($value);
184 184
                 $diff = $date->diff($now);
185
-                $formula = 365 * $diff->format('%y') + 30 * $diff->format('%m') + $diff->format('%d');
186
-                $value = $formula - 365;
185
+                $formula = 365 * $diff->format('%y')+30 * $diff->format('%m')+$diff->format('%d');
186
+                $value = $formula-365;
187 187
             }
188 188
 
189
-            $multiplierKey = $row['source'] . '-mult';
189
+            $multiplierKey = $row['source'].'-mult';
190 190
             $multiplier = isset($multipliers[$multiplierKey]) ? $multipliers[$multiplierKey] : 1;
191 191
             $score = max(min($value * $multiplier, 100), -100);
192 192
             $master[$key]['mult'] = $multiplier;
Please login to merge, or discard this patch.
src/AppBundle/Controller/ArticleInfoController.php 2 patches
Unused Use Statements   -4 removed lines patch added patch discarded remove patch
@@ -9,13 +9,9 @@
 block discarded – undo
9 9
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
10 10
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
11 11
 use Symfony\Component\HttpFoundation\Request;
12
-use Symfony\Component\DependencyInjection\ContainerInterface;
13 12
 use Symfony\Component\HttpFoundation\Response;
14 13
 use Symfony\Component\Process\Process;
15 14
 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
16
-use Xtools\ProjectRepository;
17
-use Xtools\Page;
18
-use Xtools\PagesRepository;
19 15
 use Xtools\ArticleInfo;
20 16
 
21 17
 /**
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
             $rendered = str_replace('"', '\"', trim($rendered));
85 85
 
86 86
             // Uglify temporary file.
87
-            $tmpFile = sys_get_temp_dir() . '/xtools_articleinfo_gadget.js';
87
+            $tmpFile = sys_get_temp_dir().'/xtools_articleinfo_gadget.js';
88 88
             $script = "echo \"$rendered\" | tee $tmpFile >/dev/null && ";
89
-            $script .= $this->get('kernel')->getRootDir() .
90
-                "/Resources/node_modules/uglify-es/bin/uglifyjs $tmpFile --mangle " .
89
+            $script .= $this->get('kernel')->getRootDir().
90
+                "/Resources/node_modules/uglify-es/bin/uglifyjs $tmpFile --mangle ".
91 91
                 "&& rm $tmpFile >/dev/null";
92 92
             $process = new Process($script);
93 93
             $process->run();
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
             $rendered = str_replace('\"', '"', trim($rendered));
107 107
 
108 108
             // Add comment after uglifying since it removes comments.
109
-            $rendered = "/**\n * This code was automatically generated and should not " .
110
-                "be manually edited.\n * For updates, please copy and paste from " .
111
-                $this->generateUrl('ArticleInfoGadget', ['uglify' => 1], UrlGeneratorInterface::ABSOLUTE_URL) .
112
-                "\n * Released under GPL v3 license.\n */\n" . $rendered;
109
+            $rendered = "/**\n * This code was automatically generated and should not ".
110
+                "be manually edited.\n * For updates, please copy and paste from ".
111
+                $this->generateUrl('ArticleInfoGadget', ['uglify' => 1], UrlGeneratorInterface::ABSOLUTE_URL).
112
+                "\n * Released under GPL v3 license.\n */\n".$rendered;
113 113
         }
114 114
 
115 115
         $response = new \Symfony\Component\HttpFoundation\Response($rendered);
Please login to merge, or discard this patch.
src/AppBundle/Controller/PagesController.php 1 patch
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,6 @@
 block discarded – undo
12 12
 use Symfony\Component\HttpFoundation\RedirectResponse;
13 13
 use Symfony\Component\HttpFoundation\Request;
14 14
 use Symfony\Component\HttpFoundation\Response;
15
-use Xtools\ProjectRepository;
16
-use Xtools\UserRepository;
17 15
 
18 16
 /**
19 17
  * This controller serves the Pages tool.
Please login to merge, or discard this patch.
src/AppBundle/Controller/SimpleEditCounterController.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,6 @@
 block discarded – undo
12 12
 use Symfony\Component\HttpFoundation\Request;
13 13
 use Symfony\Component\HttpFoundation\Response;
14 14
 use Xtools\Project;
15
-use Xtools\ProjectRepository;
16
-use Xtools\User;
17 15
 
18 16
 /**
19 17
  * This controller handles the Simple Edit Counter tool.
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -132,16 +132,16 @@  discard block
 block discarded – undo
132 132
                 $rev = $row['value'];
133 133
             }
134 134
             if ($row['source'] == 'groups') {
135
-                $groups .= $row['value']. ', ';
135
+                $groups .= $row['value'].', ';
136 136
             }
137 137
         }
138 138
 
139 139
         // Unknown user - If the user is created the $results variable will have 3 entries.
140 140
         // This is a workaround to detect non-existent IPs.
141 141
         if (count($results) < 3 && $arch == 0 && $rev == 0) {
142
-            $this->addFlash('notice', [ 'no-result', $username]);
142
+            $this->addFlash('notice', ['no-result', $username]);
143 143
 
144
-            return $this->redirectToRoute('SimpleEditCounterProject', [ 'project' => $project->getDomain() ]);
144
+            return $this->redirectToRoute('SimpleEditCounterProject', ['project' => $project->getDomain()]);
145 145
         }
146 146
 
147 147
         // Remove the last comma and space
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
             'project' => $project,
171 171
             'id' => $id,
172 172
             'arch' => $arch,
173
-            'rev' => $rev + $arch,
173
+            'rev' => $rev+$arch,
174 174
             'live' => $rev,
175 175
             'groups' => $groups,
176 176
             'globalGroups' => $globalGroups,
Please login to merge, or discard this patch.
src/AppBundle/Controller/AdminStatsController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         }
104 104
 
105 105
         // Generate a diff for the dates - this is the number of days we're spanning.
106
-        $days = ($end - $start) / 60 / 60 / 24;
106
+        $days = ($end-$start) / 60 / 60 / 24;
107 107
 
108 108
         // Get admin ID's, used to account for inactive admins
109 109
         $userGroupsTable = $projectData->getTableName('user_groups');
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
         // Iterate over query results, loading each user id into the array
125 125
         while ($row = $res->fetch()) {
126
-            $adminIdArr[] = $row['user_id'] ;
126
+            $adminIdArr[] = $row['user_id'];
127 127
         }
128 128
 
129 129
         // Set the query results to be useful in a sql statement.
Please login to merge, or discard this patch.
src/AppBundle/Controller/MetaController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         $timeline = [];
75 75
         $startObj = new DateTime($start);
76 76
         $endObj = new DateTime($end);
77
-        $numDays = (int) $endObj->diff($startObj)->format("%a");
77
+        $numDays = (int)$endObj->diff($startObj)->format("%a");
78 78
         $grandSum = 0;
79 79
 
80 80
         // Generate array of date labels
@@ -84,17 +84,17 @@  discard block
 block discarded – undo
84 84
 
85 85
         foreach ($data as $entry) {
86 86
             if (!isset($totals[$entry['tool']])) {
87
-                $totals[$entry['tool']] = (int) $entry['count'];
87
+                $totals[$entry['tool']] = (int)$entry['count'];
88 88
 
89 89
                 // Create arrays for each tool, filled with zeros for each date in the timeline
90 90
                 $timeline[$entry['tool']] = array_fill(0, $numDays, 0);
91 91
             } else {
92
-                $totals[$entry['tool']] += (int) $entry['count'];
92
+                $totals[$entry['tool']] += (int)$entry['count'];
93 93
             }
94 94
 
95 95
             $date = new DateTime($entry['date']);
96
-            $dateIndex = (int) $date->diff($startObj)->format("%a");
97
-            $timeline[$entry['tool']][$dateIndex] = (int) $entry['count'];
96
+            $dateIndex = (int)$date->diff($startObj)->format("%a");
97
+            $timeline[$entry['tool']][$dateIndex] = (int)$entry['count'];
98 98
 
99 99
             $grandSum += $entry['count'];
100 100
         }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         }
146 146
 
147 147
         $conn = $this->container->get('doctrine')->getManager('default')->getConnection();
148
-        $date =  date('Y-m-d');
148
+        $date = date('Y-m-d');
149 149
 
150 150
         // Increment count in timeline
151 151
         $existsSql = "SELECT 1 FROM usage_timeline
Please login to merge, or discard this patch.