Thiemo Mättig (WMDE) has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/353506 )
Change subject: Reduce line length limit and fix more PHPCS violations
......................................................................
Reduce line length limit and fix more PHPCS violations
Change-Id: Icfa15b39a7f3000706cd77cdceee6ec68c8c7343
---
M composer.json
M includes/ConstraintCheck/Checker/CommonsLinkChecker.php
M includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php
M includes/ConstraintCheck/Helper/RangeCheckerHelper.php
M includes/ConstraintParameterRenderer.php
M includes/ConstraintRepository.php
M phpcs.xml
M tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php
M tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php
M tests/phpunit/ConstraintRepositoryTest.php
10 files changed, 35 insertions(+), 25 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
refs/changes/06/353506/1
diff --git a/composer.json b/composer.json
index f540ae6..d9922bb 100644
--- a/composer.json
+++ b/composer.json
@@ -20,11 +20,11 @@
"wikibase/data-model-services": "~2.0|~3.0"
},
"require-dev": {
+ "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",
- "jakub-onderka/php-parallel-lint": "0.9.2",
- "wikibase/wikibase-codesniffer": "^0.1.0",
- "jakub-onderka/php-console-highlighter": "0.3.2"
+ "wikibase/wikibase-codesniffer": "^0.1.0"
},
"autoload": {
"psr-4": {
diff --git a/includes/ConstraintCheck/Checker/CommonsLinkChecker.php
b/includes/ConstraintCheck/Checker/CommonsLinkChecker.php
index b4205a7..156eaaa 100644
--- a/includes/ConstraintCheck/Checker/CommonsLinkChecker.php
+++ b/includes/ConstraintCheck/Checker/CommonsLinkChecker.php
@@ -107,7 +107,7 @@
$commonsLink = str_replace( ' ', '_', $commonsLink );
$commonsWikiId = 'commonswiki';
- if ( defined( 'MW_PHPUNIT_TEST' )) {
+ if ( defined( 'MW_PHPUNIT_TEST' ) ) {
$commonsWikiId = false;
}
$dbLoadBalancer = wfGetLB( $commonsWikiId );
diff --git a/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php
b/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php
index 67bd6d2..a7be376 100644
--- a/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php
+++ b/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php
@@ -85,7 +85,9 @@
$parameters['minimum_quantity'] =
$this->constraintParameterParser->parseSingleParameter(
$constraintParameters['minimum_quantity'], true );
$parameters['maximum_quantity'] =
$this->constraintParameterParser->parseSingleParameter(
$constraintParameters['maximum_quantity'], true );
} else {
- $message = wfMessage(
"wbqc-violation-message-parameters-needed-3" )->params(
$constraint->getConstraintTypeName(), 'property', 'minimum_quantity',
'maximum_quantity' )->escaped();
+ $message = wfMessage(
'wbqc-violation-message-parameters-needed-3' )
+ ->params(
$constraint->getConstraintTypeName(), 'property', 'minimum_quantity',
'maximum_quantity' )
+ ->escaped();
}
} else {
$message = wfMessage(
"wbqc-violation-message-value-needed-of-types-2" )->params(
$constraint->getConstraintTypeName(), 'quantity', 'time' )->escaped();
@@ -106,7 +108,15 @@
*/
if ( !$mainSnak instanceof PropertyValueSnak ) {
$message = wfMessage(
"wbqc-violation-message-diff-within-range-property-needs value" )->escaped();
- return new CheckResult(
$entity->getId(), $statement, $constraint->getConstraintTypeQid(),
$constraint->getConstraintId(), $parameters, CheckResult::STATUS_VIOLATION,
$message );
+ return new CheckResult(
+ $entity->getId(),
+ $statement,
+
$constraint->getConstraintTypeQid(),
+ $constraint->getConstraintId(),
+ $parameters,
+ CheckResult::STATUS_VIOLATION,
+ $message
+ );
}
if ( $mainSnak->getDataValue()->getType() ===
$dataValue->getType() && $mainSnak->getType() === 'value' ) {
diff --git a/includes/ConstraintCheck/Helper/RangeCheckerHelper.php
b/includes/ConstraintCheck/Helper/RangeCheckerHelper.php
index f4bbfea..1a8ccd5 100644
--- a/includes/ConstraintCheck/Helper/RangeCheckerHelper.php
+++ b/includes/ConstraintCheck/Helper/RangeCheckerHelper.php
@@ -31,7 +31,7 @@
private $timeCalculator;
public function __construct() {
- $this->timeParser = (new TimeParserFactory())->getTimeParser();
+ $this->timeParser = ( new TimeParserFactory()
)->getTimeParser();
$this->timeCalculator = new TimeValueCalculator();
}
@@ -96,7 +96,7 @@
$diff = $minuendYear - $subtrahendYear;
if ( $minuendYear > 0.0 && $subtrahendYear < 0.0 ) {
$diff -= 1.0; // there is no year 0, remove it
from difference
- } elseif ( $minuendYear < 0.0 && $subtrahendYear > 0.0)
{
+ } elseif ( $minuendYear < 0.0 && $subtrahendYear > 0.0
) {
$diff += 1.0; // there is no year 0, remove it
from negative difference
}
return $diff;
diff --git a/includes/ConstraintParameterRenderer.php
b/includes/ConstraintParameterRenderer.php
index d2fa983..b876042 100644
--- a/includes/ConstraintParameterRenderer.php
+++ b/includes/ConstraintParameterRenderer.php
@@ -18,7 +18,7 @@
* @license GNU GPL v2+
*/
-class ConstraintParameterRenderer{
+class ConstraintParameterRenderer {
/**
* Maximum number of displayed values for parameters with multiple ones.
@@ -42,12 +42,12 @@
* @param EntityIdFormatter $entityIdFormatter
* @param ValueFormatter $dataValueFormatter
*/
- public function __construct( EntityIdFormatter $entityIdFormatter,
- ValueFormatter
$dataValueFormatter ) {
-
+ public function __construct(
+ EntityIdFormatter $entityIdFormatter,
+ ValueFormatter $dataValueFormatter
+ ) {
$this->entityIdLabelFormatter = $entityIdFormatter;
$this->dataValueFormatter = $dataValueFormatter;
-
}
/**
@@ -61,7 +61,7 @@
if ( is_string( $value ) ) {
// Cases like 'Format' 'pattern' or 'minimum'/'maximum'
values, which we have stored as
// strings
- return (htmlspecialchars( $value ));
+ return htmlspecialchars( $value );
} elseif ( $value instanceof EntityId ) {
// Cases like 'Conflicts with' 'property', to which we
can link
return $this->entityIdLabelFormatter->formatEntityId(
$value );
diff --git a/includes/ConstraintRepository.php
b/includes/ConstraintRepository.php
index 147cd42..d468f87 100644
--- a/includes/ConstraintRepository.php
+++ b/includes/ConstraintRepository.php
@@ -103,7 +103,7 @@
$db->commit( __METHOD__, 'flush' );
wfGetLBFactory()->waitForReplication();
$table = $db->tableName( CONSTRAINT_TABLE );
- $db->query( sprintf('DELETE FROM %s LIMIT %s',
$table, $batchSize ) );
+ $db->query( sprintf( 'DELETE FROM %s LIMIT %d',
$table, $batchSize ) );
} while ( $db->affectedRows() > 0 );
}
}
diff --git a/phpcs.xml b/phpcs.xml
index f5cbe42..46c4f50 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -2,7 +2,6 @@
<ruleset name="Wikibase">
<rule ref="vendor/wikibase/wikibase-codesniffer/Wikibase">
<!-- FIXME: The following should all be fixed. -->
- <exclude name="MediaWiki.WhiteSpace.SpaceyParenthesis" />
<exclude name="PSR1.Classes.ClassDeclaration" />
</rule>
@@ -11,8 +10,8 @@
<rule ref="Generic.Files.LineLength">
<properties>
<!-- FIXME: Should be lowered to at least 140. -->
- <property name="lineLimit" value="184" />
- <property name="absoluteLineLimit" value="184" />
+ <property name="lineLimit" value="182" />
+ <property name="absoluteLineLimit" value="182" />
</properties>
</rule>
diff --git
a/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php
b/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php
index 940ad02..a6fbeb6 100644
--- a/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php
+++ b/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php
@@ -54,9 +54,10 @@
}
public function addDBData() {
- $this->db->delete('image', '*');
-
- $this->db->insert('image', [
+ $this->db->delete( 'image', '*' );
+ $this->db->insert(
+ 'image',
+ [
'img_name' => 'test_image.jpg',
'img_size' => '42',
'img_width' => '7',
diff --git
a/tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php
b/tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php
index 7bfce10..3a2a7ff 100644
--- a/tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php
+++ b/tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php
@@ -128,7 +128,7 @@
$this->checker = new ConflictsWithChecker( $this->lookup,
$this->helper, $this->connectionCheckerHelper );
$value = new EntityIdValue( new ItemId( 'Q100' ) );
- $statement = new Statement(new PropertyValueSnak( new
PropertyId( 'P188' ), $value ) );
+ $statement = new Statement( new PropertyValueSnak( new
PropertyId( 'P188' ), $value ) );
$constraintParameters = [];
diff --git a/tests/phpunit/ConstraintRepositoryTest.php
b/tests/phpunit/ConstraintRepositoryTest.php
index 1b84400..065211e 100644
--- a/tests/phpunit/ConstraintRepositoryTest.php
+++ b/tests/phpunit/ConstraintRepositoryTest.php
@@ -24,7 +24,7 @@
$repo = new ConstraintRepository();
$constraints = $repo->queryConstraintsForProperty( new
PropertyId( 'P1' ) );
- $this->assertEquals( true, is_array( $constraints) );
+ $this->assertInternalType( 'array', $constraints );
$this->assertEquals( 2, count( $constraints ) );
$this->assertInstanceOf( Constraint::class, $constraints[0] );
}
@@ -35,8 +35,8 @@
$repo = new ConstraintRepository();
$constraints = $repo->queryConstraintsForProperty( new
PropertyId( 'P2' ) );
- $this->assertEquals( true, is_array( $constraints ) );
- $this->assertEquals( 0, count( $constraints ) );
+ $this->assertInternalType( 'array', $constraints );
+ $this->assertEmpty( $constraints );
}
public function testInsertBatch() {
--
To view, visit https://gerrit.wikimedia.org/r/353506
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icfa15b39a7f3000706cd77cdceee6ec68c8c7343
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
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