[MediaWiki-commits] [Gerrit] Add php code sniffer - change (mediawiki...Translate)

2015-11-07 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Add php code sniffer
..


Add php code sniffer

Originally from Siebrand: https://gerrit.wikimedia.org/r/#/c/243160/

Bug: T90943
Change-Id: Ic7d101ca2b2be0592e0391f35ad9fe247eddfb12
---
M .jshintignore
M composer.json
M ffs/MediaWikiComplexMessages.php
M messagegroups/FileBasedMessageGroup.php
A phpcs.xml
M scripts/magic-export.php
M scripts/plural-comparison.php
M tests/phpunit/data/Example-result.i18n.php
M tests/phpunit/data/Example.i18n.php
9 files changed, 44 insertions(+), 32 deletions(-)

Approvals:
  Nikerabbit: Checked; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/.jshintignore b/.jshintignore
index e7bc219..6310582 100644
--- a/.jshintignore
+++ b/.jshintignore
@@ -1,4 +1,6 @@
+extensions/
 node_modules/
+vendor/
 
 # upstream libs
 resources/js/jquery.autosize.js
diff --git a/composer.json b/composer.json
index 2a1da67..e2ee904 100644
--- a/composer.json
+++ b/composer.json
@@ -23,7 +23,7 @@
},
{
"name": "Siebrand Mazeland",
-   "email": "s.mazel...@xs4all.nl",
+   "email": "siebr...@kitano.nl",
"role": "Developer"
}
],
@@ -38,11 +38,21 @@
"composer/installers": ">=1.0.1",
"mediawiki/universal-language-selector": "*"
},
+   "require-dev": {
+   "jakub-onderka/php-parallel-lint": "0.9",
+   "mediawiki/mediawiki-codesniffer": "0.4.0"
+   },
"suggest": {
"mediawiki/babel": "Users can easily indicate their language 
proficiency on their user page",
"mediawiki/translation-notifications": "Manage communication 
with translators",
"mustangostang/spyc": "More recent version of the bundled spyc 
library",
"romaricdrigon/metayaml": "If you want to validate message 
group configurations",
"ruflin/elastica": "Support for translation memory and search 
in ElasticSearch"
+   },
+   "scripts": {
+   "test": [
+   "parallel-lint . --exclude vendor --exclude extensions",
+   "phpcs -p -s"
+   ]
}
 }
diff --git a/ffs/MediaWikiComplexMessages.php b/ffs/MediaWikiComplexMessages.php
index 3034b8e..cd03e2f 100644
--- a/ffs/MediaWikiComplexMessages.php
+++ b/ffs/MediaWikiComplexMessages.php
@@ -51,9 +51,7 @@
return wfMessage( 'translate-magic-' . $this->id )->text();
}
 
-   #
-   # Data retrieval
-   #
+   // Data retrieval
protected $init = false;
 
public function getGroups() {
@@ -250,13 +248,9 @@
return $data;
}
 
-   #
-   # /Data retrieval
-   #
+   // /Data retrieval
 
-   #
-   # Output
-   #
+   // Output
public function header( $title ) {
$colspan = array( 'colspan' => 3 );
$header = Xml::element( 'th', $colspan, $this->getTitle() . ' - 
' . $title );
@@ -365,13 +359,10 @@
) );
}
 
-   #
-   # /Output
-   #
+   // /Output
 
-   #
-   # Save to database
-   #
+   // Save to database
+
 
function getKeyForSave() {
return $this->databaseMsg . '/' . $this->language;
@@ -436,13 +427,9 @@
$this->init = false;
}
 
-   #
-   # !Save to database
-   #
+   // /Save to database
 
-   #
-   # Export
-   #
+   // Export
public function validate( &$errors = array(), $filter = false ) {
$used = array();
foreach ( array_keys( $this->data ) as $group ) {
@@ -587,9 +574,7 @@
return "'$data'";
}
 
-   #
-   # /Export
-   #
+   // /Export
public function highlight( $key, $values ) {
return $values;
}
diff --git a/messagegroups/FileBasedMessageGroup.php 
b/messagegroups/FileBasedMessageGroup.php
index 0b5c383..a36dfd6 100644
--- a/messagegroups/FileBasedMessageGroup.php
+++ b/messagegroups/FileBasedMessageGroup.php
@@ -110,7 +110,9 @@
 * @since 2014.02 Made public
 */
public function replaceVariables( $pattern, $code ) {
+   // @codingStandardsIgnoreStart Ignore 
MediaWiki.NamingConventions.ValidGlobalName.wgPrefix
global $IP, $wgTranslateGroupRoot;
+   // @codingStandardsIgnoreEnd
 
$variables = array(
'%CODE%' => $this->mapCode( $code ),
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 000..d81a292
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,8 @@
+
+
+   
+   .
+   
+   
+   vendor
+
diff --git a/scripts/magic-export.php b/scripts/magic-export.php
index 

[MediaWiki-commits] [Gerrit] Add php code sniffer - change (mediawiki...Translate)

2015-10-05 Thread Paladox (Code Review)
Paladox has uploaded a new change for review.

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

Change subject: Add php code sniffer
..

Add php code sniffer

Originly from siebrand ( https://gerrit.wikimedia.org/r/#/c/243160/ )

Bug: T90943
Change-Id: Ic7d101ca2b2be0592e0391f35ad9fe247eddfb12
---
M .gitignore
M .jshintignore
M .jshintrc
M composer.json
M messagegroups/FileBasedMessageGroup.php
A phpcs.xml
M scripts/plural-comparison.php
7 files changed, 38 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate 
refs/changes/82/243682/1

diff --git a/.gitignore b/.gitignore
index 115b5cd..4d4a120 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,7 @@
-.svn
+composer.lock
+extensions/
+node_modules/
+vendor/
 *~
 .*.swp
 *.kate-swp
@@ -9,6 +12,3 @@
 .settings
 *.bak
 tests/pagetranslation/*.fail
-composer.lock
-extensions/
-vendor/
diff --git a/.jshintignore b/.jshintignore
index 6fe22a3..d4bff2b 100644
--- a/.jshintignore
+++ b/.jshintignore
@@ -1,3 +1,8 @@
+extensions
+node_modules
+vendor
+
 # upstream libs
+resources/js/jquery.ajaxdispatcher.js
 resources/js/jquery.autosize.js
-resources/js/jquery.ui.position.js
+resources/js/jquery.textchange.js
diff --git a/.jshintrc b/.jshintrc
index d7649a3..ce29904 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -16,7 +16,7 @@
"bitwise": true,
"forin": false,
"regexp": false,
-   "strict": true,
+   "strict": false,
"laxbreak": true,
"smarttabs": true,
"multistr": true,
diff --git a/composer.json b/composer.json
index 2a1da67..c1da9c1 100644
--- a/composer.json
+++ b/composer.json
@@ -23,7 +23,7 @@
},
{
"name": "Siebrand Mazeland",
-   "email": "s.mazel...@xs4all.nl",
+   "email": "siebr...@kitano.nl",
"role": "Developer"
}
],
@@ -38,11 +38,21 @@
"composer/installers": ">=1.0.1",
"mediawiki/universal-language-selector": "*"
},
+   "require-dev": {
+   "jakub-onderka/php-parallel-lint": "0.9",
+   "mediawiki/mediawiki-codesniffer": "0.4.0"
+   },
"suggest": {
"mediawiki/babel": "Users can easily indicate their language 
proficiency on their user page",
"mediawiki/translation-notifications": "Manage communication 
with translators",
"mustangostang/spyc": "More recent version of the bundled spyc 
library",
"romaricdrigon/metayaml": "If you want to validate message 
group configurations",
"ruflin/elastica": "Support for translation memory and search 
in ElasticSearch"
+   },
+   "scripts": {
+   "test": [
+   "parallel-lint . --exclude vendor",
+   "phpcs -p -s"
+   ]
}
 }
diff --git a/messagegroups/FileBasedMessageGroup.php 
b/messagegroups/FileBasedMessageGroup.php
index 0b5c383..a36dfd6 100644
--- a/messagegroups/FileBasedMessageGroup.php
+++ b/messagegroups/FileBasedMessageGroup.php
@@ -110,7 +110,9 @@
 * @since 2014.02 Made public
 */
public function replaceVariables( $pattern, $code ) {
+   // @codingStandardsIgnoreStart Ignore 
MediaWiki.NamingConventions.ValidGlobalName.wgPrefix
global $IP, $wgTranslateGroupRoot;
+   // @codingStandardsIgnoreEnd
 
$variables = array(
'%CODE%' => $this->mapCode( $code ),
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 000..d81a292
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,8 @@
+
+
+   
+   .
+   
+   
+   vendor
+
diff --git a/scripts/plural-comparison.php b/scripts/plural-comparison.php
index dc41b98..4b6bcd5 100644
--- a/scripts/plural-comparison.php
+++ b/scripts/plural-comparison.php
@@ -13,8 +13,7 @@
 if ( getenv( 'MW_INSTALL_PATH' ) !== false ) {
$IP = getenv( 'MW_INSTALL_PATH' );
 } else {
-   $dir = __DIR__;
-   $IP = "$dir/../../..";
+   $IP = __DIR__ . "/../../..";
 }
 require_once "$IP/maintenance/Maintenance.php";
 
@@ -129,13 +128,18 @@
}
 
public function loadCLDR() {
+   // @codingStandardsIgnoreStart Ignore 
MediaWiki.NamingConventions.ValidGlobalName.wgPrefix
global $IP;
+   // @codingStandardsIgnoreEnd
 
return $this->loadPluralFile( "$IP/languages/data/plurals.xml" 
);
}
 
public function loadMediaWiki() {
+   // @codingStandardsIgnoreStart Ignore 
MediaWiki.NamingConventions.ValidGlobalName.wgPrefix
global $IP;
+   // @codingStandardsIgnoreEnd
+
$rules = $this->loadPluralFile( 
"$IP/languages/data/plurals.xml" );
$rulesMW = $this->loadPluralFile(