jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/350491 )

Change subject: Organize lint categories by priority
......................................................................


Organize lint categories by priority

Displaying categories by priority provides editors with better
guidance about what to spend time on. The Linter help page provides
more information about why the specific priorities have been chosen.

Change-Id: If6f28570189e24a67b4380f666f4cd64a2296989
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M includes/CategoryManager.php
M includes/Hooks.php
M includes/SpecialLintErrors.php
6 files changed, 73 insertions(+), 50 deletions(-)

Approvals:
  jenkins-bot: Verified
  Arlolra: Looks good to me, approved



diff --git a/extension.json b/extension.json
index 533253f..b2dc946 100644
--- a/extension.json
+++ b/extension.json
@@ -58,40 +58,40 @@
        "config": {
                "LinterCategories": {
                        "fostered": {
-                               "severity": "error",
-                               "enabled": true
+                               "enabled": true,
+                               "priority": "medium"
                        },
                        "obsolete-tag": {
-                               "severity": "warning",
-                               "enabled": true
+                               "enabled": true,
+                               "priority": "low"
                        },
                        "bogus-image-options": {
-                               "severity": "error",
-                               "enabled": true
+                               "enabled": true,
+                               "priority": "medium"
                        },
                        "missing-end-tag": {
-                               "severity": "error",
-                               "enabled": true
+                               "enabled": true,
+                               "priority": "low"
                        },
                        "stripped-tag": {
-                               "severity": "warning",
-                               "enabled": true
+                               "enabled": true,
+                               "priority": "low"
                        },
                        "self-closed-tag": {
-                               "severity": "warning",
-                               "enabled": true
+                               "enabled": true,
+                               "priority": "high"
                        },
                        "deletable-table-tag": {
-                               "severity": "error",
-                               "enabled": true
+                               "enabled": true,
+                               "priority": "high"
                        },
                        "misnested-tag": {
-                               "severity": "error",
-                               "enabled": true
+                               "enabled": true,
+                               "priority": "medium"
                        },
                        "pwrap-bug-workaround": {
-                               "severity": "warning",
-                               "enabled": true
+                               "enabled": true,
+                               "priority": "high"
                        }
                },
                "LinterSubmitterWhitelist": {
diff --git a/i18n/en.json b/i18n/en.json
index d00799e..253dafc 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -40,8 +40,9 @@
        "linker-page-title-edit": "$1 ($2)",
        "linker-page-edit": "edit",
        "linker-page-history": "history",
-       "linter-heading-errors": "Errors",
-       "linter-heading-warnings": "Warnings",
+       "linter-heading-high-priority": "High priority",
+       "linter-heading-medium-priority": "Medium priority",
+       "linter-heading-low-priority": "Low priority",
        "pageinfo-linter": "Lint errors",
        "apihelp-query+linterrors-description": "Get a list of lint errors",
        "apihelp-query+linterrors-param-categories": "Categories of lint 
errors",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 5ae5b14..de4b255 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -43,8 +43,9 @@
        "linker-page-title-edit": "Used in a table cell. $1 is a link to the 
page, $2 is pipe separated links to the edit and history pages, the link text 
is {{msg-mw|linker-page-edit}} and {{msg-mw|linker-page-history}}",
        "linker-page-edit": "Link text for edit link in 
{{msg-mw|linker-page-title-edit}}\n{{Identical|Edit}}",
        "linker-page-history": "Link text for history link in 
{{msg-mw|linker-page-title-edit}}\n{{Identical|History}}",
-       "linter-heading-errors": "Heading on 
[[Special:LintErrors]]\n{{Identical|Error}}",
-       "linter-heading-warnings": "Heading on 
[[Special:LintErrors]]\n{{Identical|Warning}}",
+       "linter-heading-high-priority": "Heading on [[Special:LintErrors]]",
+       "linter-heading-medium-priority": "Heading on [[Special:LintErrors]]",
+       "linter-heading-low-priority": "Heading on [[Special:LintErrors]]",
        "pageinfo-linter": "Heading on ?action=info for a page if it has lint 
errors",
        "apihelp-query+linterrors-description": 
"{{doc-apihelp-description|query+linterrors}}",
        "apihelp-query+linterrors-param-categories": 
"{{doc-apihelp-param|query+linterrors|categories}}",
diff --git a/includes/CategoryManager.php b/includes/CategoryManager.php
index b7a7b78..7eaeb8e 100644
--- a/includes/CategoryManager.php
+++ b/includes/CategoryManager.php
@@ -25,8 +25,9 @@
  */
 class CategoryManager {
 
-       const ERROR = 'error';
-       const WARNING = 'warning';
+       const HIGH = 'high';
+       const MEDIUM = 'medium';
+       const LOW = 'low';
 
        /**
         * Map of category names to their hardcoded
@@ -49,49 +50,57 @@
        /**
         * @var string[]
         */
-       private $errors = [];
-
-       /**
-        * @var string[]
-        */
-       private $warnings = [];
+       private $categories = [
+               self::HIGH => [],
+               self::MEDIUM => [],
+               self::LOW => [],
+       ];
 
        public function __construct() {
                global $wgLinterCategories;
                foreach ( $wgLinterCategories as $name => $info ) {
                        if ( $info['enabled'] ) {
-                               if ( $info['severity'] === self::ERROR ) {
-                                       $this->errors[] = $name;
-                               } elseif ( $info['severity'] === self::WARNING 
) {
-                                       $this->warnings[] = $name;
-                               }
+                               $this->categories[$info['priority']][] = $name;
                        }
                }
-               sort( $this->errors );
-               sort( $this->warnings );
+
+               sort( $this->categories[self::HIGH] );
+               sort( $this->categories[self::MEDIUM] );
+               sort( $this->categories[self::LOW] );
        }
 
        /**
         * @return string[]
         */
-       public function getErrors() {
-               return $this->errors;
+       public function getHighPriority() {
+               return $this->categories[self::HIGH];
        }
 
        /**
         * @return string[]
         */
-       public function getWarnings() {
-               return $this->warnings;
+       public function getMediumPriority() {
+               return $this->categories[self::MEDIUM];
        }
 
        /**
-        * Categories that are configure to be displayed to users
+        * @return string[]
+        */
+       public function getLowPriority() {
+               return $this->categories[self::LOW];
+       }
+
+       /**
+        * Categories that are configured to be displayed to users
         *
         * @return string[]
         */
        public function getVisibleCategories() {
-               return array_merge( $this->errors, $this->warnings );
+               return array_merge(
+                       $this->categories[self::HIGH],
+                       $this->categories[self::MEDIUM],
+                       $this->categories[self::LOW]
+               );
        }
 
        /**
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 6498eeb..08a9c72 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -99,8 +99,9 @@
        public static function onAPIQuerySiteInfoGeneralInfo( ApiQuerySiteInfo 
$api, array &$data ) {
                $catManager = new CategoryManager();
                $data['linter'] = [
-                       'errors' => $catManager->getErrors(),
-                       'warnings' => $catManager->getWarnings(),
+                       'high' => $catManager->getHighPriority(),
+                       'medium' => $catManager->getMediumPriority(),
+                       'low' => $catManager->getLowPriority(),
                ];
        }
 
diff --git a/includes/SpecialLintErrors.php b/includes/SpecialLintErrors.php
index 540aaf4..7b1a105 100644
--- a/includes/SpecialLintErrors.php
+++ b/includes/SpecialLintErrors.php
@@ -81,14 +81,25 @@
                }
        }
 
+       /**
+        * @param string $priority
+        * @param int[] $totals name => count
+        * @param string[] $categories
+        */
+       private function displayList( $priority, $totals, array $categories ) {
+               $out = $this->getOutput();
+               $msgName = 'linter-heading-' . $priority . '-priority';
+               $out->addHTML( Html::element( 'h2', [], $this->msg( $msgName 
)->text() ) );
+               $out->addHTML( $this->buildCategoryList( $categories, $totals ) 
);
+       }
+
        private function showCategoryListings( CategoryManager $catManager ) {
                $totals = ( new Database( 0 ) )->getTotals();
 
-               $out = $this->getOutput();
-               $out->addHTML( Html::element( 'h2', [], $this->msg( 
'linter-heading-errors' )->text() ) );
-               $out->addHTML( $this->buildCategoryList( 
$catManager->getErrors(), $totals ) );
-               $out->addHTML( Html::element( 'h2', [], $this->msg( 
'linter-heading-warnings' )->text() ) );
-               $out->addHTML( $this->buildCategoryList( 
$catManager->getWarnings(), $totals ) );
+               // Display lint issues by priority
+               $this->displayList( 'high', $totals, 
$catManager->getHighPriority() );
+               $this->displayList( 'medium', $totals, 
$catManager->getMediumPriority() );
+               $this->displayList( 'low', $totals, 
$catManager->getLowPriority() );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/350491
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If6f28570189e24a67b4380f666f4cd64a2296989
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/Linter
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to