Updates for CodeSniffer and other tests

Change-Id: Ief70f6b82ed9c10d658eaeb980b0a4e780de9ac2
This commit is contained in:
Siebrand Mazeland 2016-02-17 15:57:15 +01:00
parent 627050be10
commit 66cf8c80f0
6 changed files with 32 additions and 28 deletions

View file

@ -3,9 +3,9 @@
* Magic words for extension. * Magic words for extension.
*/ */
$magicWords = array(); $magicWords = [];
/** English (English) */ /** English (English) */
$magicWords['en'] = array( $magicWords['en'] = [
'cscore' => array( 0, 'cscore' ), 'cscore' => [ 0, 'cscore' ],
); ];

View file

@ -9,14 +9,14 @@ if ( !defined( 'MEDIAWIKI' ) ) {
exit( 1 ); exit( 1 );
} }
$wgExtensionCredits['specialpage'][] = array( $wgExtensionCredits['specialpage'][] = [
'path' => __FILE__, 'path' => __FILE__,
'name' => 'Contribution Scores', 'name' => 'Contribution Scores',
'url' => 'https://www.mediawiki.org/wiki/Extension:Contribution_Scores', 'url' => 'https://www.mediawiki.org/wiki/Extension:Contribution_Scores',
'author' => 'Tim Laqua', 'author' => 'Tim Laqua',
'descriptionmsg' => 'contributionscores-desc', 'descriptionmsg' => 'contributionscores-desc',
'version' => '1.23.0' 'version' => '1.25.0'
); ];
define( 'CONTRIBUTIONSCORES_MAXINCLUDELIMIT', 50 ); define( 'CONTRIBUTIONSCORES_MAXINCLUDELIMIT', 50 );
$wgContribScoreReports = null; $wgContribScoreReports = null;
@ -67,19 +67,19 @@ function efContributionScores_Render( &$parser, $usertext, $metric = 'score' ) {
if ( $metric == 'score' ) { if ( $metric == 'score' ) {
$res = $dbr->select( 'revision', $res = $dbr->select( 'revision',
'COUNT(DISTINCT rev_page)+SQRT(COUNT(rev_id)-COUNT(DISTINCT rev_page))*2 AS wiki_rank', 'COUNT(DISTINCT rev_page)+SQRT(COUNT(rev_id)-COUNT(DISTINCT rev_page))*2 AS wiki_rank',
array( 'rev_user' => $user->getID() ) ); [ 'rev_user' => $user->getID() ] );
$row = $dbr->fetchObject( $res ); $row = $dbr->fetchObject( $res );
$output = $wgLang->formatNum( round( $row->wiki_rank, 0 ) ); $output = $wgLang->formatNum( round( $row->wiki_rank, 0 ) );
} elseif ( $metric == 'changes' ) { } elseif ( $metric == 'changes' ) {
$res = $dbr->select( 'revision', $res = $dbr->select( 'revision',
'COUNT(rev_id) AS rev_count', 'COUNT(rev_id) AS rev_count',
array( 'rev_user' => $user->getID() ) ); [ 'rev_user' => $user->getID() ] );
$row = $dbr->fetchObject( $res ); $row = $dbr->fetchObject( $res );
$output = $wgLang->formatNum( $row->rev_count ); $output = $wgLang->formatNum( $row->rev_count );
} elseif ( $metric == 'pages' ) { } elseif ( $metric == 'pages' ) {
$res = $dbr->select( 'revision', $res = $dbr->select( 'revision',
'COUNT(DISTINCT rev_page) AS page_count', 'COUNT(DISTINCT rev_page) AS page_count',
array( 'rev_user' => $user->getID() ) ); [ 'rev_user' => $user->getID() ] );
$row = $dbr->fetchObject( $res ); $row = $dbr->fetchObject( $res );
$output = $wgLang->formatNum( $row->page_count ); $output = $wgLang->formatNum( $row->page_count );
} else { } else {

View file

@ -94,11 +94,11 @@ class ContributionScores extends IncludableSpecialPage {
$output = "<table class=\"wikitable contributionscores plainlinks{$sortable}\" >\n" . $output = "<table class=\"wikitable contributionscores plainlinks{$sortable}\" >\n" .
"<tr class='header'>\n" . "<tr class='header'>\n" .
Html::element( 'th', array(), $this->msg( 'contributionscores-rank' )->text() ) . Html::element( 'th', [], $this->msg( 'contributionscores-rank' )->text() ) .
Html::element( 'th', array(), $this->msg( 'contributionscores-score' )->text() ) . Html::element( 'th', [], $this->msg( 'contributionscores-score' )->text() ) .
Html::element( 'th', array(), $this->msg( 'contributionscores-pages' )->text() ) . Html::element( 'th', [], $this->msg( 'contributionscores-pages' )->text() ) .
Html::element( 'th', array(), $this->msg( 'contributionscores-changes' )->text() ) . Html::element( 'th', [], $this->msg( 'contributionscores-changes' )->text() ) .
Html::element( 'th', array(), $this->msg( 'contributionscores-username' )->text() ); Html::element( 'th', [], $this->msg( 'contributionscores-username' )->text() );
$altrow = ''; $altrow = '';
$user_rank = 1; $user_rank = 1;
@ -154,12 +154,12 @@ class ContributionScores extends IncludableSpecialPage {
if ( !empty( $title ) ) { if ( !empty( $title ) ) {
$output = Html::rawElement( 'table', $output = Html::rawElement( 'table',
array( [
'style' => 'border-spacing: 0; padding: 0', 'style' => 'border-spacing: 0; padding: 0',
'class' => 'contributionscores-wrapper', 'class' => 'contributionscores-wrapper',
'lang' => htmlspecialchars( $lang->getCode() ), 'lang' => htmlspecialchars( $lang->getCode() ),
'dir' => $lang->getDir() 'dir' => $lang->getDir()
), ],
"\n" . "\n" .
"<tr>\n" . "<tr>\n" .
"<td style='padding: 0px;'>{$title}</td>\n" . "<td style='padding: 0px;'>{$title}</td>\n" .
@ -223,7 +223,7 @@ class ContributionScores extends IncludableSpecialPage {
} }
$reportTitle .= ' ' . $this->msg( 'contributionscores-top' )->numParams( $limit )->text(); $reportTitle .= ' ' . $this->msg( 'contributionscores-top' )->numParams( $limit )->text();
$title = Xml::element( 'h4', $title = Xml::element( 'h4',
array( 'class' => 'contributionscores-title' ), [ 'class' => 'contributionscores-title' ],
$reportTitle $reportTitle
) . "\n"; ) . "\n";
$this->getOutput()->addHTML( $this->genContributionScoreTable( $this->getOutput()->addHTML( $this->genContributionScoreTable(
@ -241,11 +241,11 @@ class ContributionScores extends IncludableSpecialPage {
global $wgContribScoreReports; global $wgContribScoreReports;
if ( !is_array( $wgContribScoreReports ) ) { if ( !is_array( $wgContribScoreReports ) ) {
$wgContribScoreReports = array( $wgContribScoreReports = [
array( 7, 50 ), [ 7, 50 ],
array( 30, 50 ), [ 30, 50 ],
array( 0, 50 ) [ 0, 50 ]
); ];
} }
$out = $this->getOutput(); $out = $this->getOutput();
@ -260,7 +260,7 @@ class ContributionScores extends IncludableSpecialPage {
} }
$reportTitle .= ' ' . $this->msg( 'contributionscores-top' )->numParams( $revs )->text(); $reportTitle .= ' ' . $this->msg( 'contributionscores-top' )->numParams( $revs )->text();
$title = Xml::element( 'h2', $title = Xml::element( 'h2',
array( 'class' => 'contributionscores-title' ), [ 'class' => 'contributionscores-title' ],
$reportTitle $reportTitle
) . "\n"; ) . "\n";
$out->addHTML( $title ); $out->addHTML( $title );

View file

@ -1,5 +1,7 @@
/*jshint node:true */ /*jshint node:true */
module.exports = function ( grunt ) { module.exports = function ( grunt ) {
'use strict';
grunt.loadNpmTasks( 'grunt-contrib-jshint' ); grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-banana-checker' ); grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-jsonlint' ); grunt.loadNpmTasks( 'grunt-jsonlint' );
@ -11,7 +13,7 @@ module.exports = function ( grunt ) {
] ]
}, },
banana: { banana: {
all: 'i18n/' all: 'i18n'
}, },
jsonlint: { jsonlint: {
all: [ all: [

View file

@ -1,9 +1,10 @@
{ {
"require-dev": { "require-dev": {
"jakub-onderka/php-parallel-lint": "0.9.2", "jakub-onderka/php-parallel-lint": "0.9.2",
"mediawiki/mediawiki-codesniffer": "0.5.1" "mediawiki/mediawiki-codesniffer": "0.6.0"
}, },
"scripts": { "scripts": {
"fix": "phpcbf",
"test": [ "test": [
"parallel-lint . --exclude vendor", "parallel-lint . --exclude vendor",
"phpcs -p -s" "phpcs -p -s"

View file

@ -7,7 +7,8 @@
"grunt": "0.4.5", "grunt": "0.4.5",
"grunt-cli": "0.1.13", "grunt-cli": "0.1.13",
"grunt-contrib-jshint": "0.11.3", "grunt-contrib-jshint": "0.11.3",
"grunt-banana-checker": "0.4.0", "grunt-jscs": "2.5.0",
"grunt-jsonlint": "1.0.7" "grunt-jsonlint": "1.0.7",
"grunt-banana-checker": "0.4.0"
} }
} }