mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Linter
synced 2024-09-23 18:29:58 +00:00
Merge "Allow registration of hidden lint rules"
This commit is contained in:
commit
9aa8b8fee2
|
@ -191,10 +191,8 @@
|
|||
},
|
||||
"large-tables": {
|
||||
"dbid": 20,
|
||||
"enabled": false,
|
||||
"priority": "low",
|
||||
"has-name": true,
|
||||
"parser-migration": true
|
||||
"enabled": true,
|
||||
"priority": "none"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -115,6 +115,7 @@ class ApiQueryLintErrors extends ApiQueryBase {
|
|||
/** @inheritDoc */
|
||||
public function getAllowedParams() {
|
||||
$visibleCats = ( new CategoryManager() )->getVisibleCategories();
|
||||
$invisibleCats = ( new CategoryManager() )->getinvisibleCategories();
|
||||
return [
|
||||
'categories' => [
|
||||
ParamValidator::PARAM_TYPE => $visibleCats,
|
||||
|
@ -122,6 +123,12 @@ class ApiQueryLintErrors extends ApiQueryBase {
|
|||
// Default is to show all categories
|
||||
ParamValidator::PARAM_DEFAULT => implode( '|', $visibleCats ),
|
||||
],
|
||||
'invisible-categories' => [
|
||||
ParamValidator::PARAM_TYPE => $invisibleCats,
|
||||
ParamValidator::PARAM_ISMULTI => true,
|
||||
// Default is to show all categories
|
||||
ParamValidator::PARAM_DEFAULT => implode( '|', $invisibleCats ),
|
||||
],
|
||||
'limit' => [
|
||||
ParamValidator::PARAM_DEFAULT => 10,
|
||||
ParamValidator::PARAM_TYPE => 'limit',
|
||||
|
|
|
@ -31,6 +31,7 @@ class CategoryManager {
|
|||
private const HIGH = 'high';
|
||||
private const MEDIUM = 'medium';
|
||||
private const LOW = 'low';
|
||||
private const NONE = 'none';
|
||||
|
||||
/**
|
||||
* Map of category names to their hardcoded
|
||||
|
@ -47,6 +48,7 @@ class CategoryManager {
|
|||
self::HIGH => [],
|
||||
self::MEDIUM => [],
|
||||
self::LOW => [],
|
||||
self::NONE => [],
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -95,6 +97,7 @@ class CategoryManager {
|
|||
sort( $this->categories[self::HIGH] );
|
||||
sort( $this->categories[self::MEDIUM] );
|
||||
sort( $this->categories[self::LOW] );
|
||||
sort( $this->categories[self::NONE] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -142,6 +145,13 @@ class CategoryManager {
|
|||
return $this->categories[self::LOW];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getNonePriority() {
|
||||
return $this->categories[self::NONE];
|
||||
}
|
||||
|
||||
/**
|
||||
* Categories that are configured to be displayed to users
|
||||
*
|
||||
|
@ -155,6 +165,17 @@ class CategoryManager {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Categories that are configured to be displayed to users
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getInvisibleCategories() {
|
||||
return array_merge(
|
||||
$this->categories[self::NONE]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this category has a hardcoded id and can be
|
||||
* inserted into the database
|
||||
|
|
|
@ -158,6 +158,7 @@ class Hooks implements
|
|||
'high' => $catManager->getHighPriority(),
|
||||
'medium' => $catManager->getMediumPriority(),
|
||||
'low' => $catManager->getLowPriority(),
|
||||
'none' => $catManager->getNonePriority(),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ class SpecialLintErrors extends SpecialPage {
|
|||
}
|
||||
|
||||
$catManager = new CategoryManager();
|
||||
if ( in_array( $par, $catManager->getVisibleCategories() ) ) {
|
||||
if ( in_array( $par, $this->getSubpagesForPrefixSearch() ) ) {
|
||||
$this->category = $par;
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,8 @@ class SpecialLintErrors extends SpecialPage {
|
|||
* @return string[]
|
||||
*/
|
||||
protected function getSubpagesForPrefixSearch() {
|
||||
return ( new CategoryManager() )->getVisibleCategories();
|
||||
$categoryManager = new CategoryManager();
|
||||
return array_merge( $categoryManager->getVisibleCategories(), $categoryManager->getInvisibleCategories() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue