wikimedia/mediawiki-extensions-Wikibase

View on GitHub
repo/includes/Specials/SpecialSetSiteLink.php

Summary

Maintainability
D
1 day
Test Coverage

File SpecialSetSiteLink.php has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Wikibase\Repo\Specials;

use InvalidArgumentException;
Severity: Minor
Found in repo/includes/Specials/SpecialSetSiteLink.php - About 4 hrs to fix

    Method getForm has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function getForm( EntityDocument $entity = null ) {
            if ( $this->page === null ) {
                $this->page = $this->site === null ? '' : $this->getSiteLink( $entity, $this->site );
            }
            if ( !$this->badges ) {
    Severity: Major
    Found in repo/includes/Specials/SpecialSetSiteLink.php - About 2 hrs to fix

      Method __construct has 12 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              array $tags,
              SpecialPageCopyrightView $copyrightView,
              SummaryFormatter $summaryFormatter,
              EntityTitleLookup $entityTitleLookup,
              MediaWikiEditEntityFactory $editEntityFactory,
      Severity: Major
      Found in repo/includes/Specials/SpecialSetSiteLink.php - About 1 hr to fix

        Method factory has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                AnonymousEditWarningBuilder $anonymousEditWarningBuilder,
                ChangeOpFactoryProvider $changeOpFactoryProvider,
                MediaWikiEditEntityFactory $editEntityFactory,
                EntityTitleLookup $entityTitleLookup,
                FallbackLabelDescriptionLookupFactory $labelDescriptionLookupFactory,
        Severity: Major
        Found in repo/includes/Specials/SpecialSetSiteLink.php - About 1 hr to fix

          Method processArguments has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function processArguments( $subPage ) {
                  parent::processArguments( $subPage );
          
                  $request = $this->getRequest();
                  // explode the subpage from the format Special:SetSitelink/q123/enwiki
          Severity: Minor
          Found in repo/includes/Specials/SpecialSetSiteLink.php - About 1 hr to fix

            Method getMultiSelectForBadges has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getMultiSelectForBadges() {
                    $options = [];
                    $default = [];
            
                    /** @var ItemId[] $badgeItemIds */
            Severity: Minor
            Found in repo/includes/Specials/SpecialSetSiteLink.php - About 1 hr to fix

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

                  protected function getForm( EntityDocument $entity = null ) {
                      if ( $this->page === null ) {
                          $this->page = $this->site === null ? '' : $this->getSiteLink( $entity, $this->site );
                      }
                      if ( !$this->badges ) {
              Severity: Minor
              Found in repo/includes/Specials/SpecialSetSiteLink.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

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

                  private function parseBadges( array $badges, Status $status ) {
                      $badgesObjects = [];
              
                      foreach ( $badges as $badge ) {
                          try {
              Severity: Minor
              Found in repo/includes/Specials/SpecialSetSiteLink.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 setSiteLink has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private function setSiteLink( EntityDocument $item, $siteId, $pageName, array $badgeIds, Summary &$summary = null ) {
              Severity: Minor
              Found in repo/includes/Specials/SpecialSetSiteLink.php - About 35 mins to fix

                Avoid too many return statements within this method.
                Open

                        return $status;
                Severity: Major
                Found in repo/includes/Specials/SpecialSetSiteLink.php - About 30 mins to fix

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

                      protected function processArguments( $subPage ) {
                          parent::processArguments( $subPage );
                  
                          $request = $this->getRequest();
                          // explode the subpage from the format Special:SetSitelink/q123/enwiki
                  Severity: Minor
                  Found in repo/includes/Specials/SpecialSetSiteLink.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