wikimedia/mediawiki-extensions-Wikibase

View on GitHub
repo/includes/RepoHooks.php

Summary

Maintainability
F
4 days
Test Coverage

File RepoHooks.php has 718 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Wikibase\Repo;

use LogEntry;
Severity: Major
Found in repo/includes/RepoHooks.php - About 1 day to fix

    RepoHooks has 36 functions (exceeds 20 allowed). Consider refactoring.
    Open

    final class RepoHooks {
    
        /**
         * Handler for the BeforePageDisplay hook, that conditionally adds the wikibase
         * mobile styles and injects the wikibase.ui.entitysearch module replacing the
    Severity: Minor
    Found in repo/includes/RepoHooks.php - About 4 hrs to fix

      Method onResourceLoaderRegisterModules has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function onResourceLoaderRegisterModules( ResourceLoader $resourceLoader ) {
              $moduleTemplate = [
                  'localBasePath' => __DIR__ . '/..',
                  'remoteExtPath' => 'Wikibase/repo',
              ];
      Severity: Major
      Found in repo/includes/RepoHooks.php - About 2 hrs to fix

        Function onApiCheckCanExecute has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function onApiCheckCanExecute( ApiBase $module, User $user, &$message ) {
                if ( $module instanceof ApiEditPage ) {
                    $params = $module->extractRequestParams();
                    $pageObj = $module->getTitleOrPageId( $params );
                    $namespace = $pageObj->getTitle()->getNamespace();
        Severity: Minor
        Found in repo/includes/RepoHooks.php - About 2 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 onSkinTemplateNavigationUniversal has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function onSkinTemplateNavigationUniversal( SkinTemplate $skinTemplate, array &$links ) {
                $entityContentFactory = WikibaseRepo::getEntityContentFactory();
        
                $title = $skinTemplate->getRelevantTitle();
        
        
        Severity: Minor
        Found in repo/includes/RepoHooks.php - About 1 hr to fix

          Function onSkinTemplateNavigationUniversal has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function onSkinTemplateNavigationUniversal( SkinTemplate $skinTemplate, array &$links ) {
                  $entityContentFactory = WikibaseRepo::getEntityContentFactory();
          
                  $title = $skinTemplate->getRelevantTitle();
          
          
          Severity: Minor
          Found in repo/includes/RepoHooks.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

          Method onApiCheckCanExecute has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function onApiCheckCanExecute( ApiBase $module, User $user, &$message ) {
                  if ( $module instanceof ApiEditPage ) {
                      $params = $module->extractRequestParams();
                      $pageObj = $module->getTitleOrPageId( $params );
                      $namespace = $pageObj->getTitle()->getNamespace();
          Severity: Minor
          Found in repo/includes/RepoHooks.php - About 1 hr to fix

            Function onBeforePageDisplay has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
                    $entityNamespaceLookup = WikibaseRepo::getEntityNamespaceLookup();
                    $namespace = $out->getTitle()->getNamespace();
                    $isEntityTitle = $entityNamespaceLookup->isNamespaceWithEntities( $namespace );
                    $settings = WikibaseRepo::getSettings();
            Severity: Minor
            Found in repo/includes/RepoHooks.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

            Method onPageHistoryLineEnding has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function onPageHistoryLineEnding( HistoryPager $history, $row, &$html, array $classes ) {
                    // Note: This assumes that HistoryPager::getTitle returns a Title.
                    $entityContentFactory = WikibaseRepo::getEntityContentFactory();
                    $services = MediaWikiServices::getInstance();
            
            
            Severity: Minor
            Found in repo/includes/RepoHooks.php - About 1 hr to fix

              Method onBeforePageDisplay has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
                      $entityNamespaceLookup = WikibaseRepo::getEntityNamespaceLookup();
                      $namespace = $out->getTitle()->getNamespace();
                      $isEntityTitle = $entityNamespaceLookup->isNamespaceWithEntities( $namespace );
                      $settings = WikibaseRepo::getSettings();
              Severity: Minor
              Found in repo/includes/RepoHooks.php - About 1 hr to fix

                Method onArticleDeleteComplete has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        WikiPage $wikiPage,
                        User $user,
                        $reason,
                        $id,
                        ?Content $content,
                Severity: Minor
                Found in repo/includes/RepoHooks.php - About 45 mins to fix

                  Method onFormat has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public static function onFormat( &$comment, $pre, $auto, $post, $title, $local ) {
                  Severity: Minor
                  Found in repo/includes/RepoHooks.php - About 45 mins to fix

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

                        public static function onRevisionFromEditComplete(
                            WikiPage $wikiPage,
                            RevisionRecord $revisionRecord,
                            $baseID,
                            UserIdentity $user
                    Severity: Minor
                    Found in repo/includes/RepoHooks.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

                    Avoid too many return statements within this method.
                    Open

                            return false;
                    Severity: Major
                    Found in repo/includes/RepoHooks.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return true;
                      Severity: Major
                      Found in repo/includes/RepoHooks.php - About 30 mins to fix

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

                            public static function onOutputPageParserOutput( OutputPage $outputPage, ParserOutput $parserOutput ) {
                                // Set in PlaceholderEmittingEntityTermsView.
                                $placeholders = $parserOutput->getExtensionData( 'wikibase-view-chunks' );
                                if ( $placeholders !== null ) {
                                    $outputPage->setProperty( 'wikibase-view-chunks', $placeholders );
                        Severity: Minor
                        Found in repo/includes/RepoHooks.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 onSetupAfterCache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public static function onSetupAfterCache() {
                                global $wgContentHandlers,
                                    $wgNamespaceContentModels;
                        
                                if ( WikibaseRepo::getSettings()->getSetting( 'defaultEntityNamespaces' ) ) {
                        Severity: Minor
                        Found in repo/includes/RepoHooks.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 inheritDefaultRateLimits has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public static function inheritDefaultRateLimits( array &$rateLimits ) {
                                if ( isset( $rateLimits['wikibase-idgenerator']['&inherit-create-edit'] ) ) {
                                    unset( $rateLimits['wikibase-idgenerator']['&inherit-create-edit'] );
                                    $limits = $rateLimits['create'] ?? $rateLimits['edit'] ?? [];
                                    foreach ( $limits as $group => $limit ) {
                        Severity: Minor
                        Found in repo/includes/RepoHooks.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