From 37b3383e8b5260a9674cef834d272874c0ea2589 Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Wed, 27 Feb 2019 16:29:35 +0100 Subject: [PATCH] Remove comments literally repeating the next line of code I would argue that these comments do not add any information that would not be there already. Having them adds mental overhead, because one needs to read both the comment and the next line of code first to understand they say the exact same. I don't find this helpful, but more distracting. Change-Id: I39c98f25225947ebffdcc2fd8f0243e7a6c070d7 --- includes/Html.php | 1 - includes/api/ApiFeedWatchlist.php | 2 -- includes/api/ApiMain.php | 3 --- includes/api/ApiQuery.php | 2 +- includes/changetags/ChangeTagsLogItem.php | 2 +- includes/clientpool/SquidPurgeClient.php | 2 +- includes/config/EtcdConfig.php | 2 +- includes/media/Exif.php | 3 +-- includes/parser/CoreParserFunctions.php | 1 - includes/preferences/DefaultPreferencesFactory.php | 1 - includes/resourceloader/ResourceLoaderModule.php | 1 - includes/revisiondelete/RevDelLogItem.php | 2 +- includes/specials/SpecialNewpages.php | 3 --- includes/specials/SpecialTags.php | 4 ---- includes/user/BotPassword.php | 1 - maintenance/syncFileBackend.php | 2 +- resources/Resources.php | 2 +- tests/phpunit/includes/linker/LinkRendererTest.php | 1 - 18 files changed, 8 insertions(+), 27 deletions(-) diff --git a/includes/Html.php b/includes/Html.php index 0aea7eabc3f..1e597b65924 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -983,7 +983,6 @@ class Html { $attribs["xmlns:$tag"] = $ns; } } else { // HTML5 - // DOCTYPE $ret .= "\n"; } diff --git a/includes/api/ApiFeedWatchlist.php b/includes/api/ApiFeedWatchlist.php index 935bb096ab0..11b5d91854a 100644 --- a/includes/api/ApiFeedWatchlist.php +++ b/includes/api/ApiFeedWatchlist.php @@ -102,10 +102,8 @@ class ApiFeedWatchlist extends ApiBase { $fauxReqArr['wlallrev'] = ''; } - // Create the request $fauxReq = new FauxRequest( $fauxReqArr ); - // Execute $module = new ApiMain( $fauxReq ); $module->execute(); diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 8255269ad6e..680e7dcab5c 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -1592,17 +1592,14 @@ class ApiMain extends ApiBase { $this->setupExternalResponse( $module, $params ); } - // Execute $module->execute(); Hooks::run( 'APIAfterExecute', [ &$module ] ); $this->reportUnusedParams(); if ( !$this->mInternalMode ) { - // append Debug information MWDebug::appendDebugInfoToApiResult( $this->getContext(), $this->getResult() ); - // Print result data $this->printResult(); } } diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index c68ec2b9491..ae6b1a1dbca 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -287,7 +287,7 @@ class ApiQuery extends ApiBase { } } elseif ( $modCacheMode === 'public' ) { // do nothing, if it's public already it will stay public - } else { // private + } else { $cacheMode = 'private'; } diff --git a/includes/changetags/ChangeTagsLogItem.php b/includes/changetags/ChangeTagsLogItem.php index a248c6e8b5e..75b713ef0d7 100644 --- a/includes/changetags/ChangeTagsLogItem.php +++ b/includes/changetags/ChangeTagsLogItem.php @@ -85,7 +85,7 @@ class ChangeTagsLogItem extends RevisionItemBase { $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped(); // User links and action text $action = $formatter->getActionText(); - // Comment + $comment = $this->list->getLanguage()->getDirMark() . $formatter->getComment(); diff --git a/includes/clientpool/SquidPurgeClient.php b/includes/clientpool/SquidPurgeClient.php index 36d72c2b67b..005b326f3ec 100644 --- a/includes/clientpool/SquidPurgeClient.php +++ b/includes/clientpool/SquidPurgeClient.php @@ -315,7 +315,7 @@ class SquidPurgeClient { } if ( $this->readState == 'status' ) { $this->processStatusLine( $lines[0] ); - } else { // header + } else { $this->processHeaderLine( $lines[0] ); } $this->readBuffer = $lines[1]; diff --git a/includes/config/EtcdConfig.php b/includes/config/EtcdConfig.php index 7020159fd7d..09d0189a940 100644 --- a/includes/config/EtcdConfig.php +++ b/includes/config/EtcdConfig.php @@ -326,7 +326,7 @@ class EtcdConfig implements Config, LoggerAwareInterface { private function unserialize( $string ) { if ( $this->encoding === 'YAML' ) { return yaml_parse( $string ); - } else { // JSON + } else { return json_decode( $string, true ); } } diff --git a/includes/media/Exif.php b/includes/media/Exif.php index c32a72052d3..0fde38636b7 100644 --- a/includes/media/Exif.php +++ b/includes/media/Exif.php @@ -455,8 +455,7 @@ class Exif { $val = substr( $this->mFilteredExifData[$prop], 8 ); switch ( $charCode ) { - case "\x4A\x49\x53\x00\x00\x00\x00\x00": - // JIS + case "JIS\x00\x00\x00\x00\x00": $charset = "Shift-JIS"; break; case "UNICODE\x00": diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 8ab5c31433c..d1d1a9c442e 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -327,7 +327,6 @@ class CoreParserFunctions { $username = trim( $username ); - // default $gender = User::getDefaultOption( 'gender' ); // allow prefix and normalize (e.g. "*foo" -> "*foo" ). diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php index 512a6b38297..032c836da2f 100644 --- a/includes/preferences/DefaultPreferencesFactory.php +++ b/includes/preferences/DefaultPreferencesFactory.php @@ -373,7 +373,6 @@ class DefaultPreferencesFactory implements PreferencesFactory { ]; } - // Language $languages = Language::fetchLanguageNames( null, 'mwfile' ); $languageCode = $this->config->get( 'LanguageCode' ); if ( !array_key_exists( $languageCode, $languages ) ) { diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index b39262527c9..aed036b9142 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -734,7 +734,6 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { } $content['scripts'] = $scripts; - // Styles $styles = []; // Don't create empty stylesheets like [ '' => '' ] for modules // that don't *have* any stylesheets (T40024). diff --git a/includes/revisiondelete/RevDelLogItem.php b/includes/revisiondelete/RevDelLogItem.php index bf28f60e870..54a715d2bcd 100644 --- a/includes/revisiondelete/RevDelLogItem.php +++ b/includes/revisiondelete/RevDelLogItem.php @@ -105,7 +105,7 @@ class RevDelLogItem extends RevDelItem { $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped(); // User links and action text $action = $formatter->getActionText(); - // Comment + $comment = CommentStore::getStore()->getComment( 'log_comment', $this->row )->text; $comment = $this->list->getLanguage()->getDirMark() . Linker::commentBlock( $comment ); diff --git a/includes/specials/SpecialNewpages.php b/includes/specials/SpecialNewpages.php index 2bbc0bf4863..1f81cf0a6d5 100644 --- a/includes/specials/SpecialNewpages.php +++ b/includes/specials/SpecialNewpages.php @@ -40,7 +40,6 @@ class SpecialNewpages extends IncludableSpecialPage { } protected function setup( $par ) { - // Options $opts = new FormOptions(); $this->opts = $opts; // bind $opts->add( 'hideliu', false ); @@ -63,13 +62,11 @@ class SpecialNewpages extends IncludableSpecialPage { $opts->add( $key, $params['default'] ); } - // Set values $opts->fetchValuesFromRequest( $this->getRequest() ); if ( $par ) { $this->parseParams( $par ); } - // Validate $opts->validateIntBounds( 'limit', 0, 5000 ); } diff --git a/includes/specials/SpecialTags.php b/includes/specials/SpecialTags.php index 0c74e762979..110fb1ff042 100644 --- a/includes/specials/SpecialTags.php +++ b/includes/specials/SpecialTags.php @@ -237,10 +237,8 @@ class SpecialTags extends SpecialPage { // add raw $hitcount for sorting, because tags-hitcount contains numbers and letters $newRow .= Xml::tags( 'td', [ 'data-sort-value' => $hitcount ], $hitcountLabel ); - // actions $actionLinks = []; - // delete if ( $showDeleteActions && ChangeTags::canDeleteTag( $tag )->isOK() ) { $actionLinks[] = $linkRenderer->makeKnownLink( $this->getPageTitle( 'delete' ), @@ -250,7 +248,6 @@ class SpecialTags extends SpecialPage { } if ( $showManageActions ) { // we've already checked that the user had the requisite userright - // activate if ( ChangeTags::canActivateTag( $tag )->isOK() ) { $actionLinks[] = $linkRenderer->makeKnownLink( $this->getPageTitle( 'activate' ), @@ -259,7 +256,6 @@ class SpecialTags extends SpecialPage { [ 'tag' => $tag ] ); } - // deactivate if ( ChangeTags::canDeactivateTag( $tag )->isOK() ) { $actionLinks[] = $linkRenderer->makeKnownLink( $this->getPageTitle( 'deactivate' ), diff --git a/includes/user/BotPassword.php b/includes/user/BotPassword.php index e8cd94a8a2f..6db219deecd 100644 --- a/includes/user/BotPassword.php +++ b/includes/user/BotPassword.php @@ -473,7 +473,6 @@ class BotPassword implements IDBAccessObject { return Status::newFatal( 'botpasswords-locked' ); } - // Throttle $throttle = null; if ( !empty( $wgPasswordAttemptThrottle ) ) { $throttle = new MediaWiki\Auth\Throttler( $wgPasswordAttemptThrottle, [ diff --git a/maintenance/syncFileBackend.php b/maintenance/syncFileBackend.php index 49627c3e5fe..76a5721977f 100644 --- a/maintenance/syncFileBackend.php +++ b/maintenance/syncFileBackend.php @@ -254,7 +254,7 @@ class SyncFileBackend extends Maintenance { 'src' => $fsFile->getPath(), 'dst' => $dPath, 'overwrite' => 1 ]; } elseif ( $sExists === false ) { // does not exist in source $ops[] = [ 'op' => 'delete', 'src' => $dPath, 'ignoreMissingSource' => 1 ]; - } else { // error + } else { $this->error( "Unable to sync '$dPath': could not stat file." ); $status->fatal( 'backend-fail-internal', $src->getName() ); diff --git a/resources/Resources.php b/resources/Resources.php index 1edfdd3eb7c..dfabf4bbc0e 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -643,7 +643,7 @@ return [ 'group' => 'jquery.ui', 'targets' => [ 'desktop', 'mobile' ], ], - // Effects + 'jquery.effects.core' => [ 'deprecated' => true, 'scripts' => 'resources/lib/jquery.ui/jquery.ui.effect.js', diff --git a/tests/phpunit/includes/linker/LinkRendererTest.php b/tests/phpunit/includes/linker/LinkRendererTest.php index d550dcbe26e..9b1a3ddeb2a 100644 --- a/tests/phpunit/includes/linker/LinkRendererTest.php +++ b/tests/phpunit/includes/linker/LinkRendererTest.php @@ -55,7 +55,6 @@ class LinkRendererTest extends MediaWikiLangTestCase { $linkRenderer->makeKnownLink( $target, null, [], [ 'foo' => 'bar' ] ) ); - // forcearticlepath $linkRenderer->setForceArticlePath( true ); $this->assertEquals( 'Foobar',