[MediaWiki-commits] [Gerrit] mediawiki...CheckUser[master]: build: Configure phpcs and fix some small errors

2016-12-01 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: build: Configure phpcs and fix some small errors
..


build: Configure phpcs and fix some small errors

Some errors were ignored for now and will be fixed in follow-ups.

Change-Id: I3f13d23dafa0b13d6af04bf94a931c745087df2b
---
M CheckUser.hooks.php
M api/ApiQueryCheckUser.php
M composer.json
M maintenance/importCheckUserLogs.php
M maintenance/populateCheckUserTable.php
M maintenance/purgeOldData.php
A phpcs.xml
7 files changed, 34 insertions(+), 12 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CheckUser.hooks.php b/CheckUser.hooks.php
index 4797c99..00730b4 100755
--- a/CheckUser.hooks.php
+++ b/CheckUser.hooks.php
@@ -461,7 +461,7 @@
$res = $dbr->select( 'cu_changes',
array( 'cuc_ip' ),
array( 'cuc_user' => $user->getId() ),
-   __METHOD__ ,
+   __METHOD__,
$options
);
 
@@ -469,7 +469,9 @@
foreach ( $res as $row ) {
if ( $row->cuc_ip ) {
$id = $block->doAutoblock( $row->cuc_ip );
-   if ( $id ) $blockIds[] = $id;
+   if ( $id ) {
+   $blockIds[] = $id;
+   }
}
}
 
diff --git a/api/ApiQueryCheckUser.php b/api/ApiQueryCheckUser.php
index e315adb..66a4311 100644
--- a/api/ApiQueryCheckUser.php
+++ b/api/ApiQueryCheckUser.php
@@ -89,7 +89,7 @@
} else {
$log_type[] = 'ipedits';
}
-   $log_type[] = 'ip' ;
+   $log_type[] = 'ip';
} else {
$user_id = User::idFromName( $target );
if ( !$user_id ) {
@@ -140,7 +140,7 @@
break;
 
case 'ipusers':
-   if ( IP::isIPAddress( $target )  ) {
+   if ( IP::isIPAddress( $target ) ) {
$cond = CheckUser::getIpConds( $db, 
$target, isset( $xff ) );
$this->addWhere( $cond );
$log_type = 'ipusers';
diff --git a/composer.json b/composer.json
index 1c63f9e..9e0d685 100644
--- a/composer.json
+++ b/composer.json
@@ -1,10 +1,13 @@
 {
"require-dev": {
-   "jakub-onderka/php-parallel-lint": "0.9.2"
+   "jakub-onderka/php-parallel-lint": "0.9.2",
+   "mediawiki/mediawiki-codesniffer": "0.7.2"
},
"scripts": {
"test": [
-   "parallel-lint . --exclude vendor"
-   ]
+   "parallel-lint . --exclude vendor",
+   "phpcs -p -s"
+   ],
+   "fix": "phpcbf"
}
 }
diff --git a/maintenance/importCheckUserLogs.php 
b/maintenance/importCheckUserLogs.php
index f1006ee..14eed61 100644
--- a/maintenance/importCheckUserLogs.php
+++ b/maintenance/importCheckUserLogs.php
@@ -4,7 +4,7 @@
 if ( $IP === false ) {
$IP = __DIR__ . '/../../..';
 }
-require_once( "$IP/maintenance/Maintenance.php" );
+require_once ( "$IP/maintenance/Maintenance.php" );
 
 /**
  * CheckUser old log file importer.
diff --git a/maintenance/populateCheckUserTable.php 
b/maintenance/populateCheckUserTable.php
index af87476..edca88b 100644
--- a/maintenance/populateCheckUserTable.php
+++ b/maintenance/populateCheckUserTable.php
@@ -4,7 +4,7 @@
 if ( $IP === false ) {
$IP = __DIR__ . '/../../..';
 }
-require_once( "$IP/maintenance/Maintenance.php" );
+require_once ( "$IP/maintenance/Maintenance.php" );
 
 /**
  * Populate the cu_changes table needed for CheckUser queries with
diff --git a/maintenance/purgeOldData.php b/maintenance/purgeOldData.php
index d751305..e164c18 100644
--- a/maintenance/purgeOldData.php
+++ b/maintenance/purgeOldData.php
@@ -2,9 +2,9 @@
 if ( getenv( 'MW_INSTALL_PATH' ) ) {
$IP = getenv( 'MW_INSTALL_PATH' );
 } else {
-   $IP = dirname( __FILE__ ) . '/../../..';
+   $IP = __DIR__ . '/../../..';
 }
-require_once( "$IP/maintenance/Maintenance.php" );
+require_once ( "$IP/maintenance/Maintenance.php" );
 
 class PurgeOldIPAddressData extends Maintenance {
public function __construct() {
@@ -66,4 +66,4 @@
 }
 
 $maintClass = "PurgeOldIPAddressData";
-require_once( RUN_MAINTENANCE_IF_MAIN );
+require_once ( RUN_MAINTENANCE_IF_MAIN );
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 

[MediaWiki-commits] [Gerrit] mediawiki...CheckUser[master]: build: Configure phpcs and fix some small errors

2016-12-01 Thread Legoktm (Code Review)
Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/324853

Change subject: build: Configure phpcs and fix some small errors
..

build: Configure phpcs and fix some small errors

Some errors were ignored for now and will be fixed in follow-ups.

Change-Id: I3f13d23dafa0b13d6af04bf94a931c745087df2b
---
M CheckUser.hooks.php
M api/ApiQueryCheckUser.php
M composer.json
M maintenance/importCheckUserLogs.php
M maintenance/populateCheckUserTable.php
M maintenance/purgeOldData.php
A phpcs.xml
7 files changed, 34 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CheckUser 
refs/changes/53/324853/1

diff --git a/CheckUser.hooks.php b/CheckUser.hooks.php
index 4797c99..00730b4 100755
--- a/CheckUser.hooks.php
+++ b/CheckUser.hooks.php
@@ -461,7 +461,7 @@
$res = $dbr->select( 'cu_changes',
array( 'cuc_ip' ),
array( 'cuc_user' => $user->getId() ),
-   __METHOD__ ,
+   __METHOD__,
$options
);
 
@@ -469,7 +469,9 @@
foreach ( $res as $row ) {
if ( $row->cuc_ip ) {
$id = $block->doAutoblock( $row->cuc_ip );
-   if ( $id ) $blockIds[] = $id;
+   if ( $id ) {
+   $blockIds[] = $id;
+   }
}
}
 
diff --git a/api/ApiQueryCheckUser.php b/api/ApiQueryCheckUser.php
index e315adb..66a4311 100644
--- a/api/ApiQueryCheckUser.php
+++ b/api/ApiQueryCheckUser.php
@@ -89,7 +89,7 @@
} else {
$log_type[] = 'ipedits';
}
-   $log_type[] = 'ip' ;
+   $log_type[] = 'ip';
} else {
$user_id = User::idFromName( $target );
if ( !$user_id ) {
@@ -140,7 +140,7 @@
break;
 
case 'ipusers':
-   if ( IP::isIPAddress( $target )  ) {
+   if ( IP::isIPAddress( $target ) ) {
$cond = CheckUser::getIpConds( $db, 
$target, isset( $xff ) );
$this->addWhere( $cond );
$log_type = 'ipusers';
diff --git a/composer.json b/composer.json
index 1c63f9e..9e0d685 100644
--- a/composer.json
+++ b/composer.json
@@ -1,10 +1,13 @@
 {
"require-dev": {
-   "jakub-onderka/php-parallel-lint": "0.9.2"
+   "jakub-onderka/php-parallel-lint": "0.9.2",
+   "mediawiki/mediawiki-codesniffer": "0.7.2"
},
"scripts": {
"test": [
-   "parallel-lint . --exclude vendor"
-   ]
+   "parallel-lint . --exclude vendor",
+   "phpcs -p -s"
+   ],
+   "fix": "phpcbf"
}
 }
diff --git a/maintenance/importCheckUserLogs.php 
b/maintenance/importCheckUserLogs.php
index f1006ee..14eed61 100644
--- a/maintenance/importCheckUserLogs.php
+++ b/maintenance/importCheckUserLogs.php
@@ -4,7 +4,7 @@
 if ( $IP === false ) {
$IP = __DIR__ . '/../../..';
 }
-require_once( "$IP/maintenance/Maintenance.php" );
+require_once ( "$IP/maintenance/Maintenance.php" );
 
 /**
  * CheckUser old log file importer.
diff --git a/maintenance/populateCheckUserTable.php 
b/maintenance/populateCheckUserTable.php
index af87476..edca88b 100644
--- a/maintenance/populateCheckUserTable.php
+++ b/maintenance/populateCheckUserTable.php
@@ -4,7 +4,7 @@
 if ( $IP === false ) {
$IP = __DIR__ . '/../../..';
 }
-require_once( "$IP/maintenance/Maintenance.php" );
+require_once ( "$IP/maintenance/Maintenance.php" );
 
 /**
  * Populate the cu_changes table needed for CheckUser queries with
diff --git a/maintenance/purgeOldData.php b/maintenance/purgeOldData.php
index d751305..e164c18 100644
--- a/maintenance/purgeOldData.php
+++ b/maintenance/purgeOldData.php
@@ -2,9 +2,9 @@
 if ( getenv( 'MW_INSTALL_PATH' ) ) {
$IP = getenv( 'MW_INSTALL_PATH' );
 } else {
-   $IP = dirname( __FILE__ ) . '/../../..';
+   $IP = __DIR__ . '/../../..';
 }
-require_once( "$IP/maintenance/Maintenance.php" );
+require_once ( "$IP/maintenance/Maintenance.php" );
 
 class PurgeOldIPAddressData extends Maintenance {
public function __construct() {
@@ -66,4 +66,4 @@
 }
 
 $maintClass = "PurgeOldIPAddressData";
-require_once( RUN_MAINTENANCE_IF_MAIN );
+require_once ( RUN_MAINTENANCE_IF_MAIN );
diff --git