wikimedia/mediawiki-extensions-Translate

View on GitHub
src/MessageLoading/QueryMessageCollectionActionApi.php

Summary

Maintainability
D
1 day
Test Coverage

Function run has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    private function run( ApiPageSet $resultPageSet = null ): void {
        $params = $this->extractRequestParams();

        $group = MessageGroups::getGroup( $params['group'] );
        if ( !$group ) {
Severity: Minor
Found in src/MessageLoading/QueryMessageCollectionActionApi.php - About 5 hrs 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 run has 111 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function run( ApiPageSet $resultPageSet = null ): void {
        $params = $this->extractRequestParams();

        $group = MessageGroups::getGroup( $params['group'] );
        if ( !$group ) {
Severity: Major
Found in src/MessageLoading/QueryMessageCollectionActionApi.php - About 4 hrs to fix

    File QueryMessageCollectionActionApi.php has 261 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    declare( strict_types = 1 );
    
    namespace MediaWiki\Extension\Translate\MessageLoading;
    
    
    Severity: Minor
    Found in src/MessageLoading/QueryMessageCollectionActionApi.php - About 2 hrs to fix

      Method getAllowedParams has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getAllowedParams(): array {
              return [
                  'group' => [
                      ParamValidator::PARAM_TYPE => 'string',
                      ParamValidator::PARAM_REQUIRED => true,
      Severity: Minor
      Found in src/MessageLoading/QueryMessageCollectionActionApi.php - About 1 hr to fix

        Function extractMessageData has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            private function extractMessageData(
                ApiResult $result,
                array $props,
                Message $message
            ): array {
        Severity: Minor
        Found in src/MessageLoading/QueryMessageCollectionActionApi.php - About 55 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 __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                ApiQuery $query,
                string $moduleName,
                ConfigHelper $configHelper,
                LanguageNameUtils $languageNameUtils,
                ILoadBalancer $loadBalancer,
        Severity: Minor
        Found in src/MessageLoading/QueryMessageCollectionActionApi.php - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status