wikimedia/mediawiki-extensions-Translate

View on GitHub
src/HookHandler.php

Summary

Maintainability
F
4 days
Test Coverage

File HookHandler.php has 726 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare( strict_types=1 );

namespace MediaWiki\Extension\Translate;

Severity: Major
Found in src/HookHandler.php - About 1 day to fix

    Method setupTranslate has 258 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function setupTranslate(): void {
            global $wgTranslateYamlLibrary, $wgLogTypes;
            $hooks = [];
    
            /*
    Severity: Major
    Found in src/HookHandler.php - About 1 day to fix

      HookHandler has 27 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class HookHandler implements
          ChangeTagsListActiveHook,
          ListDefinedTagsHook,
          ParserFirstCallInitHook,
          RevisionRecordInsertedHook,
      Severity: Minor
      Found in src/HookHandler.php - About 3 hrs to fix

        Function setupTranslate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function setupTranslate(): void {
                global $wgTranslateYamlLibrary, $wgLogTypes;
                $hooks = [];
        
                /*
        Severity: Minor
        Found in src/HookHandler.php - About 3 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 validateMessage has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function validateMessage(
                IContextSource $context,
                Content $content,
                Status $status,
                string $summary,
        Severity: Minor
        Found in src/HookHandler.php - About 1 hr to fix

          Method searchProfileForm has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function searchProfileForm(
                  SpecialSearch $search,
                  string &$form,
                  string $profile,
                  string $term,
          Severity: Minor
          Found in src/HookHandler.php - About 1 hr to fix

            Function validateMessage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function validateMessage(
                    IContextSource $context,
                    Content $content,
                    Status $status,
                    string $summary,
            Severity: Minor
            Found in src/HookHandler.php - About 1 hr 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

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

                private static function registerHookHandlers( array $hooks ): void {
                    if ( defined( 'MW_PHPUNIT_TEST' ) && MediaWikiServices::hasInstance() ) {
                        // When called from a test case's setUp() method,
                        // we can use HookContainer, but we cannot use SettingsBuilder.
                        $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
            Severity: Minor
            Found in src/HookHandler.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 validateMessage has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    IContextSource $context,
                    Content $content,
                    Status $status,
                    string $summary,
                    User $user
            Severity: Minor
            Found in src/HookHandler.php - About 35 mins to fix

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

                      SpecialSearch $search,
                      string &$form,
                      string $profile,
                      string $term,
                      array $opts
              Severity: Minor
              Found in src/HookHandler.php - About 35 mins to fix

                Avoid too many return statements within this method.
                Open

                        return true;
                Severity: Major
                Found in src/HookHandler.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return false;
                  Severity: Major
                  Found in src/HookHandler.php - About 30 mins to fix

                    Function preventCategorization has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function preventCategorization( Parser $parser, string &$html ): void {
                            if ( $parser->getOptions()->getInterfaceMessage() ) {
                                return;
                            }
                            $pageReference = $parser->getPage();
                    Severity: Minor
                    Found in src/HookHandler.php - About 25 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

                    Function onAbuseFilterComputeVariable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function onAbuseFilterComputeVariable(
                            string $method,
                            VariableHolder $vars,
                            array $parameters,
                            ?string &$result
                    Severity: Minor
                    Found in src/HookHandler.php - About 25 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

                    There are no issues that match your filters.

                    Category
                    Status