jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/358066 )
Change subject: Add phpcs and make pass ...................................................................... Add phpcs and make pass Change-Id: Iccc25342734d12928b98d49e7dae02d64136607c --- M auth-api.php M composer.json M includes/SecurePollHooks.php M includes/crypt/Crypt.php M includes/entities/Election.php M includes/main/Context.php M includes/main/SpecialSecurePoll.php M includes/main/Store.php M includes/user/Auth.php M includes/user/Voter.php A phpcs.xml 11 files changed, 66 insertions(+), 22 deletions(-) Approvals: Huji: Looks good to me, approved jenkins-bot: Verified diff --git a/auth-api.php b/auth-api.php index ef06d1e..8e4fe0a 100644 --- a/auth-api.php +++ b/auth-api.php @@ -9,7 +9,7 @@ } chdir( $IP ); -require( "$IP/includes/WebStart.php" ); +require "$IP/includes/WebStart.php"; if ( !class_exists( 'SecurePoll_RemoteMWAuth' ) ) { header( 'HTTP/1.1 500 Internal Server Error' ); @@ -40,4 +40,3 @@ $auth = $context->newAuth( 'local' ); $status = Status::newGood( $auth->getUserParams( $user ) ); echo serialize( $status ); - diff --git a/composer.json b/composer.json index 686b65b..b8f68fb 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,14 @@ { "require-dev": { "jakub-onderka/php-parallel-lint": "0.9.2", - "jakub-onderka/php-console-highlighter": "0.3.2" + "jakub-onderka/php-console-highlighter": "0.3.2", + "mediawiki/mediawiki-codesniffer": "0.7.2" }, "scripts": { + "fix": "phpcbf", "test": [ - "parallel-lint . --exclude vendor" + "parallel-lint . --exclude vendor", + "phpcs -p -s" ] } } diff --git a/includes/SecurePollHooks.php b/includes/SecurePollHooks.php index adb2275..204aad0 100644 --- a/includes/SecurePollHooks.php +++ b/includes/SecurePollHooks.php @@ -79,7 +79,7 @@ */ public static function onContentHandlerDefaultModelFor( $title, &$model ) { global $wgSecurePollUseNamespace; - if( $wgSecurePollUseNamespace && $title->getNamespace() == NS_SECUREPOLL ) { + if ( $wgSecurePollUseNamespace && $title->getNamespace() == NS_SECUREPOLL ) { $model = 'SecurePoll'; return false; } diff --git a/includes/crypt/Crypt.php b/includes/crypt/Crypt.php index 7d36b00..7734665 100644 --- a/includes/crypt/Crypt.php +++ b/includes/crypt/Crypt.php @@ -244,7 +244,9 @@ if ( !$dir ) { return; } + // @codingStandardsIgnoreStart while ( false !== ( $file = readdir( $dir ) ) ) { + // @codingStandardsIgnoreEnd if ( $file == '.' || $file == '..' ) { continue; } diff --git a/includes/entities/Election.php b/includes/entities/Election.php index 89a3b0c..08cb5a2 100644 --- a/includes/entities/Election.php +++ b/includes/entities/Election.php @@ -127,12 +127,16 @@ /** * Get the start date in MW internal form. */ - function getStartDate() { return $this->startDate; } + function getStartDate() { + return $this->startDate; + } /** * Get the end date in MW internal form. */ - function getEndDate() { return $this->endDate; } + function getEndDate() { + return $this->endDate; + } /** * Returns true if the election has started. @@ -194,7 +198,7 @@ $edits = isset( $props['edit-count'] ) ? $props['edit-count'] : 0; if ( $minEdits && $edits < $minEdits ) { $status->fatal( 'securepoll-too-few-edits', - $wgLang->formatNum( $minEdits), $wgLang->formatNum( $edits ) ); + $wgLang->formatNum( $minEdits ), $wgLang->formatNum( $edits ) ); } // Registration date diff --git a/includes/main/Context.php b/includes/main/Context.php index 1d7c3cf..6e50517 100644 --- a/includes/main/Context.php +++ b/includes/main/Context.php @@ -109,7 +109,7 @@ * @return SecurePoll_Election */ function getElection( $id ) { - if( !isset( $this->electionCache[$id] ) ) { + if ( !isset( $this->electionCache[$id] ) ) { $info = $this->getStore()->getElectionInfo( array( $id ) ); if ( $info ) { $this->electionCache[$id] = $this->newElection( reset( $info ) ); diff --git a/includes/main/SpecialSecurePoll.php b/includes/main/SpecialSecurePoll.php index e6c59f3..6a43704 100644 --- a/includes/main/SpecialSecurePoll.php +++ b/includes/main/SpecialSecurePoll.php @@ -61,7 +61,7 @@ return; } - if ( !($page instanceof SecurePoll_EntryPage ) ) { + if ( !( $page instanceof SecurePoll_EntryPage ) ) { $this->setSubtitle(); } diff --git a/includes/main/Store.php b/includes/main/Store.php index 9bac5fb..4896338 100644 --- a/includes/main/Store.php +++ b/includes/main/Store.php @@ -237,7 +237,7 @@ 'vote_current' => 1, 'vote_struck' => 0 ); - if( $voterId !== null ){ + if ( $voterId !== null ){ $where['vote_voter'] = $voterId; } $res = $dbr->select( @@ -249,14 +249,14 @@ foreach ( $res as $row ) { $status = call_user_func( $callback, $this, $row->vote_record ); - if( $status instanceof Status && !$status->isOK() ){ + if ( $status instanceof Status && !$status->isOK() ){ return $status; } } return Status::newGood(); } - function getEntityType( $id ){ + function getEntityType( $id ) { $db = $this->getDB(); $res = $db->selectRow( 'securepoll_entity', @@ -356,7 +356,7 @@ return Status::newGood(); } - function getEntityType( $id ){ + function getEntityType( $id ) { return isset( $this->entityInfo[$id] ) ? $this->entityInfo[$id]['type'] : false; @@ -429,7 +429,9 @@ $xr = $this->xmlReader; # Check document element + // @codingStandardsIgnoreStart while ( $xr->read() && $xr->nodeType !== XMLReader::ELEMENT ); + // @codingStandardsIgnoreEnd if ( $xr->name != 'SecurePoll' ) { wfDebug( __METHOD__.": invalid document element\n" ); return false; @@ -605,7 +607,7 @@ */ public function addParentIds( &$info, $key, $id ) { foreach ( self::$childTypes[$info['type']] as $childType ) { - if( isset( $info[$childType] ) ) { + if ( isset( $info[$childType] ) ) { foreach ( $info[$childType] as &$child ) { $child[$key] = $id; # Recurse diff --git a/includes/user/Auth.php b/includes/user/Auth.php index 7df0391..2042f8d 100644 --- a/includes/user/Auth.php +++ b/includes/user/Auth.php @@ -300,7 +300,7 @@ $attached = $centralUser->queryAttached(); $blockCount = 0; - foreach( $attached as $data ) { + foreach ( $attached as $data ) { if ( $data['blocked'] ) { $blockCount++; } diff --git a/includes/user/Voter.php b/includes/user/Voter.php index e143676..0aef482 100644 --- a/includes/user/Voter.php +++ b/includes/user/Voter.php @@ -77,34 +77,46 @@ } /** Get the voter ID */ - function getId() { return $this->id; } + function getId() { + return $this->id; + } /** * Get the voter name. This is a short, ambiguous name appropriate for * display. */ - function getName() { return $this->name; } + function getName() { + return $this->name; + } /** * Get the authorization type. */ - function getType() { return $this->type; } + function getType() { + return $this->type; + } /** * Get the voter domain. The name and domain, taken together, should usually be * unique, although this is not strictly necessary. */ - function getDomain() { return $this->domain; } + function getDomain() { + return $this->domain; + } /** * Get a URL uniquely identifying the underlying user. */ - function getUrl() { return $this->url; } + function getUrl() { + return $this->url; + } /** * Get the associated election ID */ - function getElectionId() { return $this->electionId; } + function getElectionId() { + return $this->electionId; + } /** * Get the voter's preferred language diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..1845afe --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ruleset> + <rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki"> + <exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/> + <exclude name="Generic.Arrays.DisallowLongArraySyntax.Found"/> + </rule> + <rule ref="MediaWiki.NamingConventions.ValidGlobalName"> + <properties> + <property name="ignoreList" type="array" value="$spDebianVoteDir,$spDebianVoteDir,$users,$spConf,$specialWikis" /> + </properties> + </rule> + <rule ref="MediaWiki.NamingConventions.PrefixedGlobalFunctions"> + <properties> + <property name="ignoreList" type="array" value="spGetRandom,spGenerateTest,getLanguage,runChecks,spFatal,spDeleteElection,spDumpVote,spImportDump,spInsertEntity,spImportConfiguration,spInsertMessages,spUpdateMessages,spGetQualifiedUsers,spGetEditCounts,spIsQualified,getDefaultLang,spReportProgress,spGetMetaTranslations,spFormatEntityMessages,spRunTest,spRunDebianVote" /> + </properties> + </rule> + <file>.</file> + <arg name="extensions" value="php,php5,inc"/> + <arg name="encoding" value="UTF-8"/> + <exclude-pattern>vendor</exclude-pattern> + <exclude-pattern>node_modules</exclude-pattern> +</ruleset> -- To view, visit https://gerrit.wikimedia.org/r/358066 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iccc25342734d12928b98d49e7dae02d64136607c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SecurePoll Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> Gerrit-Reviewer: Huji <huji.h...@gmail.com> Gerrit-Reviewer: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits