Page MenuHomePhabricator

phpcbf: MediaWiki_Sniffs_WhiteSpace_SpaceyParenthesisSniff removes array elements
Closed, ResolvedPublic



'props' => ['sitelinks', 'claims'],

After running phpcbf with the mediawiki/mediawiki-codesniffer 0.7.1 rule set:

'props' => [ 'sitelinks', ],

This happened in, line 267.

Originally posted as Quoting

We can see that the sniff that removed "claims" was MediaWiki_Sniffs_WhiteSpace_SpaceyParenthesisSniff as it was trying to fix the warning "Single space expected before closing parenthesis". It replaced this content with a single space character.

Event Timeline

thiemowmde triaged this task as Unbreak Now! priority.May 10 2016, 10:12 AM
thiemowmde renamed this task from phpcbf removes array elements to phpcbf: MediaWiki_Sniffs_WhiteSpace_SpaceyParenthesisSniff removes array elements.May 10 2016, 10:28 AM
thiemowmde updated the task description. (Show Details)
Nikerabbit added a subscriber: Nikerabbit.

This is especially worrisome given that many extensions were just mass-changed by this method. We might need to double check all of those.

Change 288043 had a related patch set uploaded (by PleaseStand):
SpaceyParenthesisSniff: Don't remove last argument or array element

As there has been a patch for two weeks and as this is "Unbreak now", anyone having plans to merge?

Change 288043 merged by jenkins-bot:
SpaceyParenthesisSniff: Don't remove last argument or array element

I wrote a script to identify extensions that would have been affected by the SpaceyParenthesisSniff bug. The only extension that triggered it was ArticlePlaceholder, though I would appreciate additional eyes on my script.

1#!/usr/bin/env python3
3import os
4import subprocess
5import sys
7last = 'SemanticForms'
9name = os.getcwd().split('/')[-1]
10if name <= last:
11 sys.exit(0)
14patches = subprocess.check_output(['git', 'log', '--oneline']).decode()
15splitlines = patches.splitlines()
16for i, line in enumerate(splitlines):
17 sp = line.split()
18 sha1 = sp[0]
19 message = ' '.join(sp[1:])
20 if message == 'build: Updating mediawiki/mediawiki-codesniffer to 0.7.1':
21 subprocess.check_call(['composer', 'update'])
22 subprocess.check_call(['git', 'checkout', splitlines[i+1].split()[0]])
23 try:
24 out = subprocess.check_output(['vendor/bin/phpcs', '-s']).decode()
25 print('No errors? All good.')
26 sys.exit(0)
27 except subprocess.CalledProcessError as e:
28 out = e.output.decode()
29 print('---')
30 # print(out)
31 if 'MediaWiki.WhiteSpace.SpaceyParenthesis.SingleSpaceAfterOpenParenthesis' in out\
32 or 'MediaWiki.WhiteSpace.SpaceyParenthesis.SingleSpaceBeforeCloseParenthesis' in out:
33 print('BADDDDDD')
34 sys.exit(1)

I will be releasing 0.7.2 with this bug fix, and submitting patches to upgrade all 0.7.1 repos to 0.7.2.

Legoktm assigned this task to PleaseStand.