Thiemo Mättig (WMDE) has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/352354 )
Change subject: Add PHPCS rule set and checks to CI tests
......................................................................
Add PHPCS rule set and checks to CI tests
Change-Id: Ib874d943efb49c77ce10b2bc8a1d0712ac1b2a1d
---
M composer.json
M includes/Html/HtmlTableBuilder.php
M includes/Html/HtmlTableCellBuilder.php
M includes/Html/HtmlTableHeaderBuilder.php
A phpcs.xml
M tests/phpunit/Helper/JsonFileEntityLookup.php
M tests/phpunit/Html/HtmlTableBuilderTest.php
7 files changed, 47 insertions(+), 15 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQuality
refs/changes/54/352354/1
diff --git a/composer.json b/composer.json
index bcbd11c..60fff42 100644
--- a/composer.json
+++ b/composer.json
@@ -14,7 +14,7 @@
"issues":
"https://phabricator.wikimedia.org/project/profile/989/"
},
"require": {
- "php": ">=5.5.0",
+ "php": ">=5.5.9",
"wikibase/data-model": "~4.0|~5.0|~6.0|~7.0",
"wikibase/data-model-services": "~2.0|~3.0",
"serialization/serialization": "^3.2.1"
@@ -24,11 +24,12 @@
"data-values/number": ">=0.1 <0.9",
"data-values/serialization": ">=0.1 <2.0",
"data-values/time": ">=0.1 <0.9",
+ "jakub-onderka/php-console-highlighter": "0.3.2",
+ "jakub-onderka/php-parallel-lint": "0.9.2",
"phpunit/phpunit": "^3.7.37|~4.5",
"satooshi/php-coveralls": "master-dev",
"wikibase/data-model-serialization": ">=0.1 <3.0",
- "jakub-onderka/php-parallel-lint": "0.9.2",
- "jakub-onderka/php-console-highlighter": "0.3.2"
+ "wikibase/wikibase-codesniffer": "^0.1.0"
},
"autoload": {
"psr-4": {
@@ -40,7 +41,9 @@
},
"scripts": {
"test": [
- "parallel-lint . --exclude vendor"
+ "@validate --no-interaction",
+ "parallel-lint . --exclude vendor",
+ "phpcs -p -s"
]
}
}
diff --git a/includes/Html/HtmlTableBuilder.php
b/includes/Html/HtmlTableBuilder.php
index 1c4bf5f..33e2f76 100644
--- a/includes/Html/HtmlTableBuilder.php
+++ b/includes/Html/HtmlTableBuilder.php
@@ -95,7 +95,7 @@
foreach ( $cells as $key => $cell ) {
if ( is_string( $cell ) ) {
$cells[$key] = new HtmlTableCellBuilder( $cell
);
- } else if ( !( $cell instanceof HtmlTableCellBuilder )
) {
+ } elseif ( !( $cell instanceof HtmlTableCellBuilder ) )
{
throw new InvalidArgumentException( '$cells
must be array of HtmlTableCell objects.' );
}
}
diff --git a/includes/Html/HtmlTableCellBuilder.php
b/includes/Html/HtmlTableCellBuilder.php
index ec94779..03143de 100644
--- a/includes/Html/HtmlTableCellBuilder.php
+++ b/includes/Html/HtmlTableCellBuilder.php
@@ -85,4 +85,5 @@
. $content
. Html::closeElement( 'td' );
}
+
}
diff --git a/includes/Html/HtmlTableHeaderBuilder.php
b/includes/Html/HtmlTableHeaderBuilder.php
index ecef60a..dfdf6fc 100644
--- a/includes/Html/HtmlTableHeaderBuilder.php
+++ b/includes/Html/HtmlTableHeaderBuilder.php
@@ -88,12 +88,7 @@
$content = htmlspecialchars( $this->content );
}
- return
- Html::openElement(
- 'th',
- $attributes
- )
- . $content
- . Html::closeElement('th');
+ return Html::rawElement( 'th', $attributes, $content );
}
+
}
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..1cb830e
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<ruleset name="Wikibase">
+ <rule ref="vendor/wikibase/wikibase-codesniffer/Wikibase">
+ <!-- FIXME: The following should all be fixed. -->
+ <exclude name="Generic.Arrays.DisallowLongArraySyntax" />
+ <exclude name="MediaWiki.WhiteSpace.SpaceyParenthesis" />
+ <exclude name="PSR1.Classes.ClassDeclaration" />
+ </rule>
+
+ <!-- Exceptions -->
+
+ <rule ref="Generic.Files.LineLength">
+ <properties>
+ <property name="lineLimit" value="109" />
+ </properties>
+ </rule>
+
+ <!-- Additions -->
+
+ <!-- Metrics are intentionally not part of the base Wikibase
CodeSniffer rule set. -->
+ <rule ref="Generic.Metrics.CyclomaticComplexity" />
+ <rule ref="Generic.Metrics.NestingLevel" />
+
+ <!-- TODO: Move to the Wikibase CodeSniffer library. -->
+ <rule ref="Squiz.WhiteSpace.CastSpacing" />
+
+ <file>.</file>
+</ruleset>
diff --git a/tests/phpunit/Helper/JsonFileEntityLookup.php
b/tests/phpunit/Helper/JsonFileEntityLookup.php
index d0542e3..3878850 100644
--- a/tests/phpunit/Helper/JsonFileEntityLookup.php
+++ b/tests/phpunit/Helper/JsonFileEntityLookup.php
@@ -80,7 +80,6 @@
return null;
}
-
return $this->entityDeserializer->deserialize(
$serializedEntity );
}
diff --git a/tests/phpunit/Html/HtmlTableBuilderTest.php
b/tests/phpunit/Html/HtmlTableBuilderTest.php
index 1f51e7b..51a1602 100644
--- a/tests/phpunit/Html/HtmlTableBuilderTest.php
+++ b/tests/phpunit/Html/HtmlTableBuilderTest.php
@@ -225,7 +225,10 @@
$this->getHtmlTableCellMock(
'beyond all recognition' )
)
),
- '<table
class="wikitable"><tr><th>fu</th><th>bar</th></tr><tr><td>fucked
up</td><td>beyond all recognition</td></tr></table>'
+ '<table class="wikitable">'
+ . '<tr><th>fu</th><th>bar</th></tr>'
+ . '<tr><td>fucked up</td><td>beyond all
recognition</td></tr>'
+ . '</table>'
),
array(
array(
@@ -238,7 +241,10 @@
$this->getHtmlTableCellMock(
'beyond all recognition' )
)
),
- '<table class="wikitable sortable
jquery-tablesort"><tr><th>fu</th><th>bar</th></tr><tr><td>fucked
up</td><td>beyond all recognition</td></tr></table>'
+ '<table class="wikitable sortable
jquery-tablesort">'
+ . '<tr><th>fu</th><th>bar</th></tr>'
+ . '<tr><td>fucked up</td><td>beyond all
recognition</td></tr>'
+ . '</table>'
)
);
}
--
To view, visit https://gerrit.wikimedia.org/r/352354
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib874d943efb49c77ce10b2bc8a1d0712ac1b2a1d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQuality
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits