jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/361494 )
Change subject: build: Updating mediawiki/mediawiki-codesniffer to 0.10.0 ...................................................................... build: Updating mediawiki/mediawiki-codesniffer to 0.10.0 Change-Id: I75f07ccc2131a2b01f53ff6c7adba386cb6d84bf --- M Translate.i18n.magic.php M api/ApiTranslationStash.php M composer.json M ffs/AmdFFS.php M ffs/FlatPhpFFS.php M ffs/GettextFFS.php M ffs/JsonFFS.php M ffs/MediaWikiComplexMessages.php M insertables/MediaWikiInsertablesSuggester.php M insertables/NumericalParameterInsertablesSuggester.php M phpcs.xml M scripts/create-language-models.php M scripts/createCheckIndex.php M scripts/fallbacks-graph.php M specials/SpecialExportTranslations.php M specials/SpecialLanguageStats.php M specials/SpecialTranslationStats.php M tag/SpecialPageTranslation.php M tag/TranslatablePage.php M tests/generateRandomSandboxData.php M tests/phpunit/PageTranslationParserTest.php M translationaids/GettextDocumentationAid.php M translationaids/InsertablesAid.php M ttmserver/DatabaseTTMServer.php M ttmserver/ElasticSearchTTMServer.php M ttmserver/FuzzyLikeThis.php M ttmserver/TTMServerMessageUpdateJob.php M utils/ArrayFlattener.php M utils/ExternalMessageSourceStateComparator.php M utils/MessageWebImporter.php M utils/StatsTable.php M webservices/QueryAggregator.php M webservices/TranslationQueryResponse.php 33 files changed, 51 insertions(+), 53 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/Translate.i18n.magic.php b/Translate.i18n.magic.php index de78330..a8f69ce 100644 --- a/Translate.i18n.magic.php +++ b/Translate.i18n.magic.php @@ -12,4 +12,3 @@ $magicWords['en'] = [ 'translation' => [ 0, 'translation' ], ]; - diff --git a/api/ApiTranslationStash.php b/api/ApiTranslationStash.php index 71a22cd..9a486c0 100644 --- a/api/ApiTranslationStash.php +++ b/api/ApiTranslationStash.php @@ -19,7 +19,7 @@ // The user we are operating on, not necessarly the user making the request $user = $this->getUser(); - if ( isset( $params['username'] ) ){ + if ( isset( $params['username'] ) ) { if ( $this->getUser()->isAllowed( 'translate-sandboxmanage' ) ) { $user = User::newFromName( $params['username'] ); if ( !$user ) { diff --git a/composer.json b/composer.json index c8a1392..4791fb9 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ }, "require-dev": { "jakub-onderka/php-parallel-lint": "0.9.2", - "mediawiki/mediawiki-codesniffer": "~0.7.2", + "mediawiki/mediawiki-codesniffer": "0.10.0", "jakub-onderka/php-console-highlighter": "0.3.2" }, "suggest": { @@ -52,7 +52,7 @@ "scripts": { "fix": "phpcbf", "test": [ - "parallel-lint . --exclude vendor --exclude extensions", + "parallel-lint . --exclude vendor --exclude node_modules --exclude extensions", "phpcs -p -s" ] } diff --git a/ffs/AmdFFS.php b/ffs/AmdFFS.php index aff9ab9..41f739c 100644 --- a/ffs/AmdFFS.php +++ b/ffs/AmdFFS.php @@ -66,7 +66,7 @@ public function readFromVariable( $data ) { $authors = AmdFFS::extractAuthors( $data ); $data = AmdFFS::extractMessagePart( $data ); - $messages = (array) FormatJson::decode( $data, /*as array*/true ); + $messages = (array)FormatJson::decode( $data, /*as array*/true ); $metadata = []; // Take care of regular language bundles, as well as the root bundle. diff --git a/ffs/FlatPhpFFS.php b/ffs/FlatPhpFFS.php index 0c71c0d..fc3ec6e 100644 --- a/ffs/FlatPhpFFS.php +++ b/ffs/FlatPhpFFS.php @@ -39,7 +39,7 @@ foreach ( $matches as $_ ) { $legal = Title::legalChars(); $key = preg_replace_callback( "/([^$legal]|\\\\)/u", - function( $m ) { + function ( $m ) { return '\x' . dechex( ord( $m[0] ) ); }, $_[1] diff --git a/ffs/GettextFFS.php b/ffs/GettextFFS.php index 616501a..68d9fe7 100644 --- a/ffs/GettextFFS.php +++ b/ffs/GettextFFS.php @@ -135,7 +135,6 @@ // Then parse the messages foreach ( $sections as $section ) { - $item = self::parseGettextSection( $section, $pluralCount, $metadata ); if ( $item === false ) { continue; @@ -165,7 +164,6 @@ } public static function parseGettextSection( $section, $pluralCount, &$metadata ) { - if ( trim( $section ) === '' ) { return false; } diff --git a/ffs/JsonFFS.php b/ffs/JsonFFS.php index 24d3f71..0c176e9 100644 --- a/ffs/JsonFFS.php +++ b/ffs/JsonFFS.php @@ -41,7 +41,7 @@ * @return array Parsed data. */ public function readFromVariable( $data ) { - $messages = (array) FormatJson::decode( $data, /*as array*/true ); + $messages = (array)FormatJson::decode( $data, /*as array*/true ); $authors = []; $metadata = []; diff --git a/ffs/MediaWikiComplexMessages.php b/ffs/MediaWikiComplexMessages.php index e9b65ba..f968095 100644 --- a/ffs/MediaWikiComplexMessages.php +++ b/ffs/MediaWikiComplexMessages.php @@ -230,7 +230,7 @@ if ( $group['code'] ) { MediaWiki\suppressWarnings(); - $data = (array) ${$group['var']} [$code]; + $data = (array)${$group['var']} [$code]; MediaWiki\restoreWarnings(); } else { $data = ${$group['var']}; diff --git a/insertables/MediaWikiInsertablesSuggester.php b/insertables/MediaWikiInsertablesSuggester.php index 7055dd6..750f422 100644 --- a/insertables/MediaWikiInsertablesSuggester.php +++ b/insertables/MediaWikiInsertablesSuggester.php @@ -16,7 +16,7 @@ $matches = []; preg_match_all( '/\$(1[a-z]+|[0-9]+)/', $text, $matches, PREG_SET_ORDER ); - $new = array_map( function( $match ) { + $new = array_map( function ( $match ) { return new Insertable( $match[0], $match[0] ); }, $matches ); $insertables = array_merge( $insertables, $new ); @@ -28,14 +28,14 @@ $matches, PREG_SET_ORDER ); - $new = array_map( function( $match ) { + $new = array_map( function ( $match ) { return new Insertable( $match[2], $match[1], $match[3] ); }, $matches ); $insertables = array_merge( $insertables, $new ); $matches = []; preg_match_all( '/<\/?[a-z]+>/', $text, $matches, PREG_SET_ORDER ); - $new = array_map( function( $match ) { + $new = array_map( function ( $match ) { return new Insertable( $match[0], $match[0] ); }, $matches ); $insertables = array_merge( $insertables, $new ); diff --git a/insertables/NumericalParameterInsertablesSuggester.php b/insertables/NumericalParameterInsertablesSuggester.php index 2c6fa70..67e060e 100644 --- a/insertables/NumericalParameterInsertablesSuggester.php +++ b/insertables/NumericalParameterInsertablesSuggester.php @@ -19,7 +19,7 @@ $matches, PREG_SET_ORDER ); - $new = array_map( function( $match ) { + $new = array_map( function ( $match ) { return new Insertable( $match[0], $match[0] ); }, $matches ); $insertables = array_merge( $insertables, $new ); diff --git a/phpcs.xml b/phpcs.xml index a1157f9..a308716 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,12 +1,26 @@ <?xml version="1.0"?> <ruleset> - <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/> + <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"> + <exclude name="MediaWiki.Commenting.IllegalSingleLineComment.IllegalSingleLineCommentStart"/><!--T168963--> + <exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected"/> + <exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic"/> + <exclude name="MediaWiki.Commenting.FunctionComment.MissingParamComment"/> + <exclude name="MediaWiki.Commenting.FunctionComment.MissingParamName"/> + <exclude name="MediaWiki.Commenting.FunctionComment.MissingParamTag"/> + <exclude name="MediaWiki.Commenting.FunctionComment.MissingReturn"/> + <exclude name="MediaWiki.Commenting.FunctionComment.ParamNameNoMatch"/> + <exclude name="MediaWiki.Commenting.FunctionComment.WrongStyle"/> + <exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName"/> + <exclude name="MediaWiki.Usage.DbrQueryUsage"/> + <exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment"/> + </rule> <rule ref="Generic.Files.LineLength"> <exclude-pattern>Translate.alias.php</exclude-pattern> </rule> <file>.</file> <arg name="extensions" value="php,php5,inc"/> - <arg name="encoding" value="utf8"/> - <exclude-pattern type="relative">extensions</exclude-pattern> - <exclude-pattern>vendor</exclude-pattern> + <arg name="encoding" value="UTF-8"/> + <exclude-pattern type="relative">^extensions</exclude-pattern> + <exclude-pattern type="relative">^vendor</exclude-pattern> + <exclude-pattern type="relative">^node_modules</exclude-pattern> </ruleset> diff --git a/scripts/create-language-models.php b/scripts/create-language-models.php index 8895474..3cb9ef0 100644 --- a/scripts/create-language-models.php +++ b/scripts/create-language-models.php @@ -164,7 +164,7 @@ $config->useMb( true ); $c = new LanguageDetector\Learn( $config ); $c->addSample( $code, $text ); - $c->addStepCallback( function( $lang, $status ) { + $c->addStepCallback( function ( $lang, $status ) { echo "Learning {$lang}: $status\n"; } ); @@ -177,7 +177,6 @@ $key = wfMemcKey( __CLASS__, 'cc', $code ); $text = $cache->get( $key ); if ( !is_string( $text ) ) { - $snippets = []; $ids = explode( '|', $ids ); diff --git a/scripts/createCheckIndex.php b/scripts/createCheckIndex.php index d180f54..7b7e7ea 100644 --- a/scripts/createCheckIndex.php +++ b/scripts/createCheckIndex.php @@ -97,7 +97,6 @@ foreach ( $collection as $key => $message ) { $prob = $checker->checkMessageFast( $message, $code ); if ( $prob ) { - if ( $verbose ) { // Print it $nsText = $wgContLang->getNsText( $g->namespaces[0] ); diff --git a/scripts/fallbacks-graph.php b/scripts/fallbacks-graph.php index 153005b..5b3c01b 100644 --- a/scripts/fallbacks-graph.php +++ b/scripts/fallbacks-graph.php @@ -46,7 +46,6 @@ $langs = Language::fetchLanguageNames( null, 'mw' ); $nodes = $edges = []; foreach ( $langs as $code => $name ) { - $fallbacks = Language::getFallbacksFor( $code ); if ( $fallbacks === [ 'en' ] ) { continue; diff --git a/specials/SpecialExportTranslations.php b/specials/SpecialExportTranslations.php index 4b0ccbd..f16afe2 100644 --- a/specials/SpecialExportTranslations.php +++ b/specials/SpecialExportTranslations.php @@ -46,7 +46,6 @@ $this->doExport(); } - } protected function outputForm() { diff --git a/specials/SpecialLanguageStats.php b/specials/SpecialLanguageStats.php index f8473a0..f10aab9 100644 --- a/specials/SpecialLanguageStats.php +++ b/specials/SpecialLanguageStats.php @@ -308,7 +308,7 @@ /** * If workflow states are configured, adds a cell with the workflow state to the row, * @param String $target Whose workflow state do we want, such as language code or group id. - * @param String $state The workflow state id + * @param String $state The workflow state id * @return string Html */ protected function getWorkflowStateCell( $target, $state ) { diff --git a/specials/SpecialTranslationStats.php b/specials/SpecialTranslationStats.php index 1e9bc49..c9cef02 100644 --- a/specials/SpecialTranslationStats.php +++ b/specials/SpecialTranslationStats.php @@ -122,7 +122,6 @@ if ( $this->including() ) { $this->getOutput()->addHTML( $this->image( $opts ) ); } elseif ( $opts['graphit'] ) { - if ( !class_exists( 'PHPlot' ) ) { header( 'HTTP/1.0 500 Multi fail' ); echo 'PHPlot not found'; diff --git a/tag/SpecialPageTranslation.php b/tag/SpecialPageTranslation.php index 0b07aca..7875ec0 100644 --- a/tag/SpecialPageTranslation.php +++ b/tag/SpecialPageTranslation.php @@ -221,7 +221,7 @@ // Check if user wants to translate title // If not, remove it from the list of sections if ( !$request->getCheck( 'translatetitle' ) ) { - $sections = array_filter( $sections, function( $s ) { + $sections = array_filter( $sections, function ( $s ) { return $s->id !== 'Page display title'; } ); } diff --git a/tag/TranslatablePage.php b/tag/TranslatablePage.php index 0ca0049..c90f3c4 100644 --- a/tag/TranslatablePage.php +++ b/tag/TranslatablePage.php @@ -216,7 +216,7 @@ /** * Check whether title is marked for translation * @return bool - * @return 2014.06 + * @since 2014.06 */ public function hasPageDisplayTitle() { // Cached value diff --git a/tests/generateRandomSandboxData.php b/tests/generateRandomSandboxData.php index b2ce488..f615b20 100644 --- a/tests/generateRandomSandboxData.php +++ b/tests/generateRandomSandboxData.php @@ -97,7 +97,7 @@ function wfRandom01() { // Returns random number using mt_rand() with a flat distribution from 0 to 1 inclusive - return (float) mt_rand() / (float) mt_getrandmax(); + return (float)mt_rand() / (float)mt_getrandmax(); } function wfRandomPn() { diff --git a/tests/phpunit/PageTranslationParserTest.php b/tests/phpunit/PageTranslationParserTest.php index ab2f54a..bb7d592 100644 --- a/tests/phpunit/PageTranslationParserTest.php +++ b/tests/phpunit/PageTranslationParserTest.php @@ -28,7 +28,6 @@ * @dataProvider provideTestFiles */ public function testParsing( $file ) { - $filename = basename( $file ); list( $pagename, ) = explode( '.', $filename, 2 ); $title = Title::newFromText( $pagename ); diff --git a/translationaids/GettextDocumentationAid.php b/translationaids/GettextDocumentationAid.php index 9ed3057..4923387 100644 --- a/translationaids/GettextDocumentationAid.php +++ b/translationaids/GettextDocumentationAid.php @@ -16,7 +16,6 @@ */ class GettextDocumentationAid extends TranslationAid { public function getData() { - // We need to get the primary group to get the correct file // So $group can be different from $this->group $group = $this->handle->getGroup(); diff --git a/translationaids/InsertablesAid.php b/translationaids/InsertablesAid.php index 621c4cd..a9bdfe6 100644 --- a/translationaids/InsertablesAid.php +++ b/translationaids/InsertablesAid.php @@ -16,7 +16,6 @@ */ class InsertablesAid extends TranslationAid { public function getData() { - // We need to get the primary group to get the correct file // So $group can be different from $this->group $group = $this->handle->getGroup(); diff --git a/ttmserver/DatabaseTTMServer.php b/ttmserver/DatabaseTTMServer.php index 11c5aff..402bba2 100644 --- a/ttmserver/DatabaseTTMServer.php +++ b/ttmserver/DatabaseTTMServer.php @@ -123,7 +123,6 @@ $text = $lang->lc( $text ); $segments = preg_split( '/\s+/', $text, -1, PREG_SPLIT_NO_EMPTY ); if ( count( $segments ) < 4 ) { - return []; } diff --git a/ttmserver/ElasticSearchTTMServer.php b/ttmserver/ElasticSearchTTMServer.php index 75bca84..3d9df86 100644 --- a/ttmserver/ElasticSearchTTMServer.php +++ b/ttmserver/ElasticSearchTTMServer.php @@ -165,10 +165,11 @@ $query->setParam( 'min_score', $cutoff ); $query->setSort( [ '_score', '_uid' ] ); - // This query is doing two unrelated things: - // 1) Collect the message contents and scores so that they can - // be accessed later for the translations we found. - // 2) Build the query string for the query that fetches the translations. + /* This query is doing two unrelated things: + * 1) Collect the message contents and scores so that they can + * be accessed later for the translations we found. + * 2) Build the query string for the query that fetches the translations. + */ $contents = $scores = $terms = []; do { $resultset = $this->getType()->search( $query ); @@ -296,10 +297,10 @@ $doc = $this->createDocument( $handle, $targetText, $revId ); MWElasticUtils::withRetry( self::BULK_INDEX_RETRY_ATTEMPTS, - function() use ( $doc ) { + function () use ( $doc ) { $this->getType()->addDocument( $doc ); }, - function( $e, $errors ) { + function ( $e, $errors ) { $c = get_class( $e ); $msg = $e->getMessage(); error_log( __METHOD__ . ": update failed ($c: $msg); retrying." ); @@ -453,10 +454,10 @@ } MWElasticUtils::withRetry( self::BULK_INDEX_RETRY_ATTEMPTS, - function() use ( $docs ) { + function () use ( $docs ) { $this->getType()->addDocuments( $docs ); }, - function( $e, $errors ) { + function ( $e, $errors ) { $c = get_class( $e ); $msg = $e->getMessage(); $this->logOutput( "Batch failed ($c: $msg), trying again in 10 seconds" ); @@ -784,7 +785,7 @@ $ids[] = $result->getId(); } MWElasticUtils::withRetry( $retryAttempts, - function() use ( $ids, $type ) { + function () use ( $ids, $type ) { $type->deleteIds( $ids ); } ); diff --git a/ttmserver/FuzzyLikeThis.php b/ttmserver/FuzzyLikeThis.php index bf13b7c..dd0bb90 100644 --- a/ttmserver/FuzzyLikeThis.php +++ b/ttmserver/FuzzyLikeThis.php @@ -132,7 +132,7 @@ * @return $this */ public function setIgnoreTF( $ignoreTF ) { - $this->_ignoreTF = (bool) $ignoreTF; + $this->_ignoreTF = (bool)$ignoreTF; return $this; } @@ -145,7 +145,7 @@ * @return $this */ public function setFuzziness( $value ) { - $value = (int) $value; + $value = (int)$value; $this->_fuzziness = $value; return $this; @@ -159,7 +159,7 @@ * @return $this */ public function setPrefixLength( $value ) { - $this->_prefixLength = (int) $value; + $this->_prefixLength = (int)$value; return $this; } @@ -172,7 +172,7 @@ * @return $this */ public function setMaxQueryTerms( $value ) { - $this->_maxQueryTerms = (int) $value; + $this->_maxQueryTerms = (int)$value; return $this; } diff --git a/ttmserver/TTMServerMessageUpdateJob.php b/ttmserver/TTMServerMessageUpdateJob.php index 4877364..4e407f1 100644 --- a/ttmserver/TTMServerMessageUpdateJob.php +++ b/ttmserver/TTMServerMessageUpdateJob.php @@ -62,7 +62,6 @@ /** * @param Title $title * @param array $params - * @param int $id */ public function __construct( $title, $params = [] ) { parent::__construct( diff --git a/utils/ArrayFlattener.php b/utils/ArrayFlattener.php index bcdb06b..c1511e5 100644 --- a/utils/ArrayFlattener.php +++ b/utils/ArrayFlattener.php @@ -147,7 +147,6 @@ } foreach ( $flat as $key => $value ) { - $path = explode( $this->sep, $key ); if ( count( $path ) === 1 ) { $unflat[$key] = $value; diff --git a/utils/ExternalMessageSourceStateComparator.php b/utils/ExternalMessageSourceStateComparator.php index 2133810..874c3e4 100644 --- a/utils/ExternalMessageSourceStateComparator.php +++ b/utils/ExternalMessageSourceStateComparator.php @@ -123,7 +123,6 @@ // Does not exist if ( $file === false ) { - return; } @@ -208,7 +207,6 @@ $this->addChange( 'deletion', $code, $key, null ); } } - } protected function addChange( $type, $language, $key, $content ) { diff --git a/utils/MessageWebImporter.php b/utils/MessageWebImporter.php index a909a23..a74a86f 100644 --- a/utils/MessageWebImporter.php +++ b/utils/MessageWebImporter.php @@ -140,7 +140,6 @@ $request->getBool( 'process', false ) && $this->getUser()->matchEditToken( $request->getVal( 'token' ) ) ) { - return true; } diff --git a/utils/StatsTable.php b/utils/StatsTable.php index 4d78d2d..ecd9c2a 100644 --- a/utils/StatsTable.php +++ b/utils/StatsTable.php @@ -227,7 +227,7 @@ /** * Makes a nice print from plain float. * @param number $num - * @param string $to floor or ceil + * @param string $to floor or ceil * @return string Plain text */ public function formatPercentage( $num, $to = 'floor' ) { diff --git a/webservices/QueryAggregator.php b/webservices/QueryAggregator.php index d1ba5cf..040092a 100644 --- a/webservices/QueryAggregator.php +++ b/webservices/QueryAggregator.php @@ -74,7 +74,7 @@ * @return array[] */ protected function getMultiHttpQueries( $queries ) { - $converter = function( TranslationQuery $q ) { + $converter = function ( TranslationQuery $q ) { return [ 'url' => $q->getUrl(), 'method' => $q->getMethod(), diff --git a/webservices/TranslationQueryResponse.php b/webservices/TranslationQueryResponse.php index 9a5cbb9..7b1a052 100644 --- a/webservices/TranslationQueryResponse.php +++ b/webservices/TranslationQueryResponse.php @@ -29,7 +29,7 @@ public static function newFromMultiHttp( array $data, TranslationQuery $query ) { $response = $data['response']; $obj = new TranslationQueryResponse(); - $obj->code = (int) $response['code']; + $obj->code = (int)$response['code']; $obj->reason = $response['reason']; $obj->headers = $response['headers']; $obj->body = $response['body']; -- To view, visit https://gerrit.wikimedia.org/r/361494 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I75f07ccc2131a2b01f53ff6c7adba386cb6d84bf Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> Gerrit-Reviewer: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: Umherirrender <umherirrender_de...@web.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits