wikimedia/mediawiki-core

View on GitHub
includes/api/Validator/ApiParamValidator.php

Summary

Maintainability
D
3 days
Test Coverage

Function checkSettings has a Cognitive Complexity of 89 (exceeds 5 allowed). Consider refactoring.
Open

    public function checkSettings(
        ApiBase $module, array $params, string $name, array $options
    ): array {
        $options['module'] = $module;
        $settings = $params[$name];
Severity: Minor
Found in includes/api/Validator/ApiParamValidator.php - About 1 day to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method checkSettings has 131 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function checkSettings(
        ApiBase $module, array $params, string $name, array $options
    ): array {
        $options['module'] = $module;
        $settings = $params[$name];
Severity: Major
Found in includes/api/Validator/ApiParamValidator.php - About 5 hrs to fix

    File ApiParamValidator.php has 313 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace MediaWiki\Api\Validator;
    
    use ApiBase;
    Severity: Minor
    Found in includes/api/Validator/ApiParamValidator.php - About 3 hrs to fix

      Function mapDeprecatedSettingsMessages has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private function mapDeprecatedSettingsMessages( array $settings ): array {
              if ( isset( $settings[EnumDef::PARAM_DEPRECATED_VALUES] ) ) {
                  foreach ( $settings[EnumDef::PARAM_DEPRECATED_VALUES] as &$v ) {
                      if ( $v === null || $v === true || $v instanceof MessageValue ) {
                          continue;
      Severity: Minor
      Found in includes/api/Validator/ApiParamValidator.php - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method validateValue has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              ApiBase $module, string $name, $value, $settings, array $options = []
      Severity: Minor
      Found in includes/api/Validator/ApiParamValidator.php - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status