Re-enable MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment sniff

Bug: T170580
Change-Id: Ib5bcab3414f44013cf57c0d006b212dea175473a
This commit is contained in:
Pppery 2017-11-29 19:47:01 -05:00
parent 624da67ec6
commit d05f289032
3 changed files with 18 additions and 10 deletions

View file

@ -3,7 +3,6 @@
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="MediaWiki.Commenting.FunctionComment.MissingParamComment" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
</rule>
<file>.</file>
<arg name="extensions" value="php,php5,inc" />

View file

@ -54,9 +54,12 @@ class ExtractFormatter extends HtmlFormatter {
$text = parent::getText();
if ( $this->plainText ) {
$text = html_entity_decode( $text );
$text = str_replace( "\xC2\xA0", ' ', $text ); // replace nbsp with space
$text = str_replace( "\r", "\n", $text ); // for Windows
$text = preg_replace( "/\n{3,}/", "\n\n", $text ); // normalise newlines
// replace nbsp with space
$text = str_replace( "\xC2\xA0", ' ', $text );
// for Windows
$text = str_replace( "\r", "\n", $text );
// normalise newlines
$text = preg_replace( "/\n{3,}/", "\n\n", $text );
}
return $text;
}
@ -85,10 +88,14 @@ class ExtractFormatter extends HtmlFormatter {
// Based on code from OpenSearchXml by Brion Vibber
$endchars = [
'[^\p{Lu}]\.(?:[ \n]|$)', '[\!\?](?:[ \n]|$)', // regular ASCII
'。', // full-width ideographic full-stop
'', '', '', // double-width roman forms
'。', // half-width ideographic full stop
// regular ASCII
'[^\p{Lu}]\.(?:[ \n]|$)', '[\!\?](?:[ \n]|$)',
// full-width ideographic full-stop
'。',
// double-width roman forms
'', '', '',
// half-width ideographic full stop
'。',
];
$endgroup = implode( '|', $endchars );

View file

@ -19,7 +19,8 @@ class ExtractFormatterTest extends MediaWikiTestCase {
$po->setEditSection( true );
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'textextracts' );
$fmt = new ExtractFormatter( $text, $plainText, $config );
$fmt->remove( '.metadata' ); // Will be added via $wgExtractsRemoveClasses on WMF
// .metadata class will be added via $wgExtractsRemoveClasses on WMF
$fmt->remove( '.metadata' );
$text = trim( $fmt->getText() );
$this->assertEquals( $expected, $text );
}
@ -191,7 +192,8 @@ class ExtractFormatterTest extends MediaWikiTestCase {
[ $text, 8, 'Lullzy lulz' ],
// HTML processing
[ $html, 1, 'foo' ],
[ $html, 4, 'foo<tag>' ], // let HTML sanitizer clean it up later
// let HTML sanitizer clean it up later
[ $html, 4, 'foo<tag>' ],
[ $html, 12, 'foo<tag>bar</tag>' ],
[ $html, 13, 'foo<tag>bar</tag>' ],
[ $html, 16, 'foo<tag>bar</tag>' ],