Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/350491 )

Change subject: Add priority to a linter category + organize lint categories by 
priority
......................................................................

Add priority to a linter category + 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/SpecialLintErrors.php
5 files changed, 80 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Linter 
refs/changes/91/350491/1

diff --git a/extension.json b/extension.json
index 533253f..31af050 100644
--- a/extension.json
+++ b/extension.json
@@ -59,39 +59,48 @@
                "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..b42bc70 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -42,6 +42,9 @@
        "linker-page-history": "history",
        "linter-heading-errors": "Errors",
        "linter-heading-warnings": "Warnings",
+       "linter-heading-high-priority": "High Priority Categories",
+       "linter-heading-medium-priority": "Medium Priority Categories",
+       "linter-heading-low-priority": "Low Priority Categories",
        "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..66eb978 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -45,6 +45,9 @@
        "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]]\n{{Identical|High Priority Categories}}",
+       "linter-heading-medium-priority": "Heading on 
[[Special:LintErrors]]\n{{Identical|Medium Priority Categories}}",
+       "linter-heading-low-priority": "Heading on 
[[Special:LintErrors]]\n{{Identical|Low Priority Categories}}",
        "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..6cff424 100644
--- a/includes/CategoryManager.php
+++ b/includes/CategoryManager.php
@@ -27,6 +27,9 @@
 
        const ERROR = 'error';
        const WARNING = 'warning';
+       const HIGH = 'high';
+       const MEDIUM = 'medium';
+       const LOW = 'low';
 
        /**
         * Map of category names to their hardcoded
@@ -56,15 +59,39 @@
         */
        private $warnings = [];
 
+       /**
+        * @var string[]
+        */
+       private $highProrityCategories = [];
+
+       /**
+        * @var string[]
+        */
+       private $mediumProrityCategories = [];
+
+       /**
+        * @var string[]
+        */
+       private $lowProrityCategories = [];
+
        public function __construct() {
                global $wgLinterCategories;
                foreach ( $wgLinterCategories as $name => $info ) {
                        if ( $info['enabled'] ) {
+                               // Classify as errors / warnings
                                if ( $info['severity'] === self::ERROR ) {
                                        $this->errors[] = $name;
                                } elseif ( $info['severity'] === self::WARNING 
) {
                                        $this->warnings[] = $name;
                                }
+
+                               // Classify by priority
+                               if ( $info['priority'] === self::HIGH ) {
+                                       $this->highPriorityCategories[] = $name;
+                               } elseif ( $info['priority'] === self::MEDIUM ) 
{
+                                       $this->mediumPriorityCategories[] = 
$name;
+                               } elseif ( $info['priority'] === self::LOW ) {
+                                       $this->lowPriorityCategories[] = $name;
                        }
                }
                sort( $this->errors );
@@ -86,6 +113,27 @@
        }
 
        /**
+        * @return string[]
+        */
+       public function getHighPriorityCategories() {
+               return $this->highPriorityCategories;
+       }
+
+       /**
+        * @return string[]
+        */
+       public function getMediumPriorityCategories() {
+               return $this->mediumPriorityCategories;
+       }
+
+       /**
+        * @return string[]
+        */
+       public function getLowPriorityCategories() {
+               return $this->lowPriorityCategories;
+       }
+
+       /**
         * Categories that are configure to be displayed to users
         *
         * @return string[]
diff --git a/includes/SpecialLintErrors.php b/includes/SpecialLintErrors.php
index 540aaf4..c78f395 100644
--- a/includes/SpecialLintErrors.php
+++ b/includes/SpecialLintErrors.php
@@ -85,10 +85,14 @@
                $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 (rather than as errors / 
warnings)
+               $out->addHTML( Html::element( 'h2', [], $this->msg( 
'linter-heading-high-priority' )->text() ) );
+               $out->addHTML( $this->buildCategoryList( 
$catManager->getHighPriorityCategories(), $totals ) );
+               $out->addHTML( Html::element( 'h2', [], $this->msg( 
'linter-heading-medium-priority' )->text() ) );
+               $out->addHTML( $this->buildCategoryList( 
$catManager->getMediumPriorityCategories(), $totals ) );
+               $out->addHTML( Html::element( 'h2', [], $this->msg( 
'linter-heading-low-priority' )->text() ) );
+               $out->addHTML( $this->buildCategoryList( 
$catManager->getLowPriorityCategories(), $totals ) );
        }
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If6f28570189e24a67b4380f666f4cd64a2296989
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Linter
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>

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

Reply via email to