Completed
Pull Request — master (#111)
by MusikAnimal
02:23
created
src/AppBundle/Controller/AutomatedEditsController.php 2 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.
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 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -65,8 +65,6 @@
 block discarded – undo
65 65
     /**
66 66
      * Display the AdminScore results.
67 67
      * @Route("/adminscore/{project}/{username}", name="AdminScoreResult")
68
-     * @param string $project The project name.
69
-     * @param string $username The username.
70 68
      * @return Response
71 69
      * @todo Move SQL to a model.
72 70
      * @codeCoverageIgnore
Please login to merge, or discard this patch.
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
@@ -92,20 +92,20 @@  discard block
 block discarded – undo
92 92
 
93 93
         // MULTIPLIERS (to review)
94 94
         $multipliers = [
95
-            'account-age-mult' => 1.25,             # 0 if = 365 jours
96
-            'edit-count-mult' => 1.25,              # 0 if = 10 000
97
-            'user-page-mult' => 0.1,                # 0 if =
98
-            'patrols-mult' => 1,                    # 0 if =
99
-            'blocks-mult' => 1.4,                   # 0 if = 10
95
+            'account-age-mult' => 1.25, # 0 if = 365 jours
96
+            'edit-count-mult' => 1.25, # 0 if = 10 000
97
+            'user-page-mult' => 0.1, # 0 if =
98
+            'patrols-mult' => 1, # 0 if =
99
+            'blocks-mult' => 1.4, # 0 if = 10
100 100
             'afd-mult' => 1.15,
101
-            'recent-activity-mult' => 0.9,          # 0 if =
101
+            'recent-activity-mult' => 0.9, # 0 if =
102 102
             'aiv-mult' => 1.15,
103
-            'edit-summaries-mult' => 0.8,           # 0 if =
104
-            'namespaces-mult' => 1.0,               # 0 if =
105
-            'pages-created-live-mult' => 1.4,       # 0 if =
106
-            'pages-created-deleted-mult' => 1.4,    # 0 if =
107
-            'rpp-mult' => 1.15,                     # 0 if =
108
-            'user-rights-mult' => 0.75,             # 0 if =
103
+            'edit-summaries-mult' => 0.8, # 0 if =
104
+            'namespaces-mult' => 1.0, # 0 if =
105
+            'pages-created-live-mult' => 1.4, # 0 if =
106
+            'pages-created-deleted-mult' => 1.4, # 0 if =
107
+            'rpp-mult' => 1.15, # 0 if =
108
+            'user-rights-mult' => 0.75, # 0 if =
109 109
         ];
110 110
 
111 111
         // Grab the connection to the replica database (which is separate from the above)
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
                 $now = new DateTime();
189 189
                 $date = new DateTime($value);
190 190
                 $diff = $date->diff($now);
191
-                $formula = 365 * $diff->format('%y') + 30 * $diff->format('%m') + $diff->format('%d');
192
-                $value = $formula - 365;
191
+                $formula = 365 * $diff->format('%y')+30 * $diff->format('%m')+$diff->format('%d');
192
+                $value = $formula-365;
193 193
             }
194 194
 
195 195
             if ($key === 'id') {
196 196
                 $id = $value;
197 197
             } else {
198
-                $multiplierKey = $row['source'] . '-mult';
198
+                $multiplierKey = $row['source'].'-mult';
199 199
                 $multiplier = isset($multipliers[$multiplierKey]) ? $multipliers[$multiplierKey] : 1;
200 200
                 $score = max(min($value * $multiplier, 100), -100);
201 201
                 $master[$key]['mult'] = $multiplier;
Please login to merge, or discard this patch.
src/AppBundle/Controller/XtoolsController.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         $params = $this->parseLegacyParams($request, $params);
37 37
 
38 38
         // Remove blank values.
39
-        return array_filter($params, function ($param) {
39
+        return array_filter($params, function($param) {
40 40
             // 'namespace' or 'username' could be '0'.
41 41
             return $param !== null && $param !== '';
42 42
         });
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         ];
183 183
 
184 184
         // Remove blank values.
185
-        return array_filter($params, function ($param) {
185
+        return array_filter($params, function($param) {
186 186
             // 'namespace' or 'username' could be '0'.
187 187
             return $param !== null && $param !== '';
188 188
         });
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * Get a Project instance from the project string, using defaults if the
47 47
      * given project string is invalid.
48 48
      * @param  string[] $params Query params.
49
-     * @return Project
49
+     * @return \Xtools\Project
50 50
      */
51 51
     public function getProjectFromQuery($params)
52 52
     {
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      * @param  bool   $optionalStartDate If set, no start date will be provided
170 170
      *   if only an end date is given. If false, start date will be set to one
171 171
      *   month before the end date.
172
-     * @return int[] Start and end date as UTC timestamps.
172
+     * @return integer[] Start and end date as UTC timestamps.
173 173
      */
174 174
     public function getUTCFromDateParams($start, $end, $optionalStartDate = false)
175 175
     {
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/AdminStatsController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         $dbName = $projectData->getDatabaseName();
108 108
 
109 109
         // Generate a diff for the dates - this is the number of days we're spanning.
110
-        $days = ($end - $start) / 60 / 60 / 24;
110
+        $days = ($end-$start) / 60 / 60 / 24;
111 111
 
112 112
         // Get admin ID's, used to account for inactive admins
113 113
         $userGroupsTable = $projectRepo->getTableName($dbName, 'user_groups');
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
         // Iterate over query results, loading each user id into the array
129 129
         while ($row = $res->fetch()) {
130
-            $adminIdArr[] = $row["user_id"] ;
130
+            $adminIdArr[] = $row["user_id"];
131 131
         }
132 132
 
133 133
         // Set the query results to be useful in a sql statement.
Please login to merge, or discard this patch.