Skip to content

Commit 0f42b86

Browse files
lucaswerkmeisterWMDE bot
authored andcommitted
Enable MediaWiki.Arrays.TrailingComma sniff
Enforce trailing commas in multi-line arrays, and no trailing commas in single-line arrays. In one line in FullStatementRdfBuilderTest, the extra comma pushes the line length over the hard limit (140 → 141 characters), so split the array across multiple lines to keep it below the limit. The same thing happens in one line in RdfBuilderTest, so split the DatabaseEntitySource constructor call across multiple lines. Bug: T325532 Change-Id: I184b019ba7ab8b435cd0774cac04011dac4585bd
1 parent 924a00d commit 0f42b86

11 files changed

+45
-45
lines changed

tests/integration/Deserializers/StatementDeserializerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private function newTestStatement() {
5151

5252
$statement->setQualifiers( new SnakList( [
5353
new PropertyNoValueSnak( 1337 ),
54-
new PropertyValueSnak( 23, new NumberValue( 42 ) )
54+
new PropertyValueSnak( 23, new NumberValue( 42 ) ),
5555
] ) );
5656

5757
$statement->setGuid( 'some guid be here' );

tests/integration/RealEntitiesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private function getEntitySerializationsFromDir( $dir ) {
5353
if ( $fileInfo->getExtension() === 'json' ) {
5454
$argumentLists[] = [
5555
$fileInfo->getFilename(),
56-
json_decode( file_get_contents( $fileInfo->getPathname() ), true )
56+
json_decode( file_get_contents( $fileInfo->getPathname() ), true ),
5757
];
5858
}
5959
}

tests/unit/Deserializers/EntityDeserializerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function testLegacySerializationWithoutId_exceptionIsThrown() {
100100

101101
private function getLegacyItemSerializationWithoutId() {
102102
return [ 'aliases' => [
103-
'en' => [ 'foo', 'bar' ]
103+
'en' => [ 'foo', 'bar' ],
104104
] ];
105105
}
106106

@@ -125,7 +125,7 @@ private function getCurrentItemSerializationWithoutId() {
125125
'language' => 'en',
126126
'value' => 'bar',
127127
],
128-
]
128+
],
129129
] ];
130130
}
131131

tests/unit/Deserializers/LegacyEntityIdDeserializerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ public function legacyIdProvider() {
6060
return [
6161
[
6262
new ItemId( 'Q42' ),
63-
[ 'item', 42 ]
63+
[ 'item', 42 ],
6464
],
6565

6666
[
6767
new NumericPropertyId( 'P1337' ),
68-
[ 'property', 1337 ]
68+
[ 'property', 1337 ],
6969
],
7070
];
7171
}

tests/unit/Deserializers/LegacyFingerprintDeserializerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function TermListProvider() {
4141
return [
4242
[
4343
[],
44-
new TermList( [] )
44+
new TermList( [] ),
4545
],
4646

4747
[
@@ -52,7 +52,7 @@ public function TermListProvider() {
5252
new TermList( [
5353
new Term( 'en', 'foo' ),
5454
new Term( 'de', 'bar' ),
55-
] )
55+
] ),
5656
],
5757
];
5858
}
@@ -94,7 +94,7 @@ public function descriptionListProvider() {
9494
return [
9595
[
9696
[],
97-
new TermList( [] )
97+
new TermList( [] ),
9898
],
9999

100100
[
@@ -105,7 +105,7 @@ public function descriptionListProvider() {
105105
new TermList( [
106106
new Term( 'en', 'foo' ),
107107
new Term( 'de', 'bar' ),
108-
] )
108+
] ),
109109
],
110110
];
111111
}
@@ -131,7 +131,7 @@ public function aliasesListProvider() {
131131
return [
132132
[
133133
[],
134-
new AliasGroupList( [] )
134+
new AliasGroupList( [] ),
135135
],
136136

137137
[
@@ -145,7 +145,7 @@ public function aliasesListProvider() {
145145
new AliasGroup( 'en', [ 'foo', 'bar' ] ),
146146
new AliasGroup( 'de', [ 'foo', 'bar', 'baz' ] ),
147147
new AliasGroup( 'nl', [ 'bah' ] ),
148-
] )
148+
] ),
149149
],
150150
];
151151
}

tests/unit/Deserializers/LegacyItemDeserializerTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ public function invalidSerializationProvider() {
5252
[ null ],
5353

5454
[ [
55-
'links' => [ null ]
55+
'links' => [ null ],
5656
] ],
5757

5858
[ [
59-
'claims' => null
59+
'claims' => null,
6060
] ],
6161

6262
[ [
63-
'claims' => [ null ]
63+
'claims' => [ null ],
6464
] ],
6565

6666
[ [
67-
'entity' => 42
67+
'entity' => 42,
6868
] ],
6969
];
7070
}
@@ -99,7 +99,7 @@ public function testGivenLinks_itemHasSiteLinks() {
9999
'links' => [
100100
'foo' => 'bar',
101101
'baz' => 'bah',
102-
]
102+
],
103103
],
104104
$item
105105
);
@@ -132,8 +132,8 @@ public function testGivenStatement_itemHasStatement() {
132132
$this->assertDeserialization(
133133
[
134134
'claims' => [
135-
$this->newStatementSerialization()
136-
]
135+
$this->newStatementSerialization(),
136+
],
137137
],
138138
$item
139139
);
@@ -151,7 +151,7 @@ private function newStatementSerialization() {
151151
'q' => [],
152152
'g' => 'foo',
153153
'rank' => Statement::RANK_NORMAL,
154-
'refs' => []
154+
'refs' => [],
155155
];
156156
}
157157

@@ -162,8 +162,8 @@ public function testGivenStatementWithLegacyKey_itemHasStatement() {
162162
$this->assertDeserialization(
163163
[
164164
'statements' => [
165-
$this->newStatementSerialization()
166-
]
165+
$this->newStatementSerialization(),
166+
],
167167
],
168168
$item
169169
);

tests/unit/Deserializers/LegacyPropertyDeserializerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ public function testGivenInvalidEntityId_exceptionIsThrown() {
5959
$this->expectDeserializationException();
6060
$this->deserializer->deserialize( [
6161
'datatype' => 'foo',
62-
'entity' => 'spam spam spam'
62+
'entity' => 'spam spam spam',
6363
] );
6464
}
6565

6666
public function testGivenNonPropertyEntityId_exceptionIsThrown() {
6767
$this->expectDeserializationException();
6868
$this->deserializer->deserialize( [
6969
'datatype' => 'foo',
70-
'entity' => 'q42'
70+
'entity' => 'q42',
7171
] );
7272
}
7373

@@ -79,7 +79,7 @@ public function testGivenNoPropertyIdId_noPropertyIdIsSet() {
7979
public function testGivenValidPropertyIdId_propertyIdIsSet() {
8080
$property = $this->deserializer->deserialize( [
8181
'datatype' => 'foo',
82-
'entity' => 'p42'
82+
'entity' => 'p42',
8383
] );
8484

8585
$this->assertEquals( new NumericPropertyId( 'p42' ), $property->getId() );
@@ -92,7 +92,7 @@ public function testGivenLabels_getLabelsReturnsThem( array $labels ) {
9292
/** @var Property $property */
9393
$property = $this->deserializer->deserialize( [
9494
'datatype' => 'foo',
95-
'label' => $labels
95+
'label' => $labels,
9696
] );
9797

9898
$this->assertEquals( $labels, $property->getFingerprint()->getLabels()->toTextArray() );
@@ -121,7 +121,7 @@ public function testGivenDescriptions_getDescriptionsReturnsThem( array $descrip
121121
/** @var Property $property */
122122
$property = $this->deserializer->deserialize( [
123123
'datatype' => 'foo',
124-
'description' => $descriptions
124+
'description' => $descriptions,
125125
] );
126126

127127
$this->assertEquals( $descriptions, $property->getFingerprint()->getDescriptions()->toTextArray() );
@@ -139,7 +139,7 @@ public function testGivenAliases_getAliasesReturnsThem( array $aliases ) {
139139
/** @var Property $property */
140140
$property = $this->deserializer->deserialize( [
141141
'datatype' => 'foo',
142-
'aliases' => $aliases
142+
'aliases' => $aliases,
143143
] );
144144

145145
$this->assertEquals( $aliases, $property->getFingerprint()->getAliasGroups()->toTextArray() );

tests/unit/Deserializers/LegacySiteLinkListDeserializerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ public function serializationProvider() {
7171
'baz' => [
7272
'name' => 'bah',
7373
'badges' => [],
74-
]
74+
],
7575
] ],
7676

7777
[ [
7878
'foo' => [
7979
'name' => 'bar',
8080
'badges' => [ 'Q42', 'Q1337' ],
81-
]
81+
],
8282
] ],
8383

8484
[ [
@@ -105,7 +105,7 @@ public function testDeserialization() {
105105
new SiteLinkList(
106106
[
107107
new SiteLink( 'foo', 'bar', [ new ItemId( 'Q42' ), new ItemId( 'Q1337' ) ] ),
108-
new SiteLink( 'bar', 'baz' )
108+
new SiteLink( 'bar', 'baz' ),
109109
]
110110
),
111111
$this->deserializer->deserialize(
@@ -114,7 +114,7 @@ public function testDeserialization() {
114114
'name' => 'bar',
115115
'badges' => [ 'Q42', 'Q1337' ],
116116
],
117-
'bar' => 'baz'
117+
'bar' => 'baz',
118118
]
119119
)
120120
);

tests/unit/Deserializers/LegacySnakDeserializerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ public function testValueSnakDeserialization() {
8989
'value',
9090
42,
9191
'string',
92-
'foo'
92+
'foo',
9393
] )
9494
);
9595
}
9696

9797
public function testGivenInvalidDataValue_unDerializableValueIsConstructed() {
9898
$dataValueDeserializer = new DataValueDeserializer( [
99-
'string' => StringValue::class
99+
'string' => StringValue::class,
100100
] );
101101

102102
$deserializer = new LegacySnakDeserializer( $dataValueDeserializer );
@@ -105,7 +105,7 @@ public function testGivenInvalidDataValue_unDerializableValueIsConstructed() {
105105
'value',
106106
42,
107107
'string',
108-
1337
108+
1337,
109109
] );
110110

111111
$this->assertInstanceOf( PropertyValueSnak::class, $snak );

tests/unit/Deserializers/LegacySnakListDeserializerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testGivenValidSerialization_deserializeReturnsCorrectSnakList()
6868
[
6969
'somevalue',
7070
1337,
71-
]
71+
],
7272
];
7373

7474
$this->assertEquals(

0 commit comments

Comments
 (0)