wikimedia/mediawiki-core

View on GitHub
includes/block/DatabaseBlockStore.php

Summary

Maintainability
F
2 wks
Test Coverage

File DatabaseBlockStore.php has 1440 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Class for DatabaseBlock objects to interact with the database
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Major
Found in includes/block/DatabaseBlockStore.php - About 3 days to fix

    Function newLoad has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

        private function newLoad(
            $specificTarget,
            $specificType,
            $fromPrimary,
            $vagueTarget = null
    Severity: Minor
    Found in includes/block/DatabaseBlockStore.php - About 6 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

    DatabaseBlockStore has 40 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DatabaseBlockStore {
        /** The old schema */
        public const SCHEMA_IPBLOCKS = 'ipblocks';
        /** The new schema */
        public const SCHEMA_BLOCK = 'block';
    Severity: Minor
    Found in includes/block/DatabaseBlockStore.php - About 5 hrs to fix

      Method getQueryInfo has 133 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getQueryInfo( $schema ) {
              if ( $this->readStage === SCHEMA_COMPAT_READ_OLD ) {
                  $commentQuery = $this->commentStore->getJoin( 'ipb_reason' );
                  if ( $schema === self::SCHEMA_IPBLOCKS ) {
                      return [
      Severity: Major
      Found in includes/block/DatabaseBlockStore.php - About 5 hrs to fix

        Method newLoad has 110 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function newLoad(
                $specificTarget,
                $specificType,
                $fromPrimary,
                $vagueTarget = null
        Severity: Major
        Found in includes/block/DatabaseBlockStore.php - About 4 hrs to fix

          Method acquireTarget has 68 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function acquireTarget(
                  DatabaseBlock $block,
                  IDatabase $dbw,
                  $expectedTargetCount
              ) {
          Severity: Major
          Found in includes/block/DatabaseBlockStore.php - About 2 hrs to fix

            Method updateBlock has 65 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function updateBlock( DatabaseBlock $block ) {
                    $this->logger->debug( 'Updating block; timestamp ' . $block->getTimestamp() );
            
                    $block->assertWiki( $this->wikiId );
            
            
            Severity: Major
            Found in includes/block/DatabaseBlockStore.php - About 2 hrs to fix

              Method getArrayForBlockUpdate has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function getArrayForBlockUpdate(
                      DatabaseBlock $block,
                      IDatabase $dbw,
                      $schema
                  ): array {
              Severity: Major
              Found in includes/block/DatabaseBlockStore.php - About 2 hrs to fix

                Method doAutoblock has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function doAutoblock( DatabaseBlock $parentBlock, $autoblockIP ) {
                        // If autoblocks are disabled, go away.
                        if ( !$parentBlock->isAutoblocking() ) {
                            return false;
                        }
                Severity: Major
                Found in includes/block/DatabaseBlockStore.php - About 2 hrs to fix

                  Function updateBlock has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function updateBlock( DatabaseBlock $block ) {
                          $this->logger->debug( 'Updating block; timestamp ' . $block->getTimestamp() );
                  
                          $block->assertWiki( $this->wikiId );
                  
                  
                  Severity: Minor
                  Found in includes/block/DatabaseBlockStore.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 getArrayForAutoblockUpdate has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function getArrayForAutoblockUpdate( DatabaseBlock $block, $schema ): array {
                          $blocker = $block->getBlocker();
                          if ( !$blocker ) {
                              throw new RuntimeException( __METHOD__ . ': this block does not have a blocker' );
                          }
                  Severity: Major
                  Found in includes/block/DatabaseBlockStore.php - About 2 hrs to fix

                    Method updateTarget has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function updateTarget( DatabaseBlock $block, $newTarget ) {
                            $dbw = $this->getPrimaryDB();
                            $blockId = $block->getId( $this->wikiId );
                            if ( !$blockId ) {
                                throw new InvalidArgumentException(
                    Severity: Minor
                    Found in includes/block/DatabaseBlockStore.php - About 2 hrs to fix

                      Method newFromRow has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function newFromRow( IReadableDatabase $db, $row ) {
                              if ( isset( $row->ipb_id ) ) {
                                  return new DatabaseBlock( [
                                      'address' => $row->ipb_address,
                                      'wiki' => $this->wikiId,
                      Severity: Minor
                      Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

                        Method newListFromIPs has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function newListFromIPs( array $addresses, $applySoftBlocks, $fromPrimary = false ) {
                                if ( $addresses === [] ) {
                                    return [];
                                }
                        
                        
                        Severity: Minor
                        Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

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

                              public function deleteBlocksMatchingConds( array $conds, $limit = null ) {
                                  $dbw = $this->getPrimaryDB();
                                  $affected = 0;
                                  if ( $this->writeStage & SCHEMA_COMPAT_WRITE_OLD ) {
                                      $oldConds = self::mapCondsToOldSchema( $conds );
                          Severity: Minor
                          Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

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

                                public function deleteBlock( DatabaseBlock $block ): bool {
                                    if ( $this->readOnlyMode->isReadOnly( $this->wikiId ) ) {
                                        return false;
                                    }
                            
                            
                            Severity: Minor
                            Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

                              Function newListFromIPs has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function newListFromIPs( array $addresses, $applySoftBlocks, $fromPrimary = false ) {
                                      if ( $addresses === [] ) {
                                          return [];
                                      }
                              
                              
                              Severity: Minor
                              Found in includes/block/DatabaseBlockStore.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 acquireTarget has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private function acquireTarget(
                                      DatabaseBlock $block,
                                      IDatabase $dbw,
                                      $expectedTargetCount
                                  ) {
                              Severity: Minor
                              Found in includes/block/DatabaseBlockStore.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 attemptInsert has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private function attemptInsert(
                                      DatabaseBlock $block,
                                      IDatabase $dbw,
                                      $expectedTargetCount
                                  ) {
                              Severity: Minor
                              Found in includes/block/DatabaseBlockStore.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 attemptInsert has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private function attemptInsert(
                                      DatabaseBlock $block,
                                      IDatabase $dbw,
                                      $expectedTargetCount
                                  ) {
                              Severity: Minor
                              Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

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

                                        ServiceOptions $options,
                                        LoggerInterface $logger,
                                        ActorStoreFactory $actorStoreFactory,
                                        BlockRestrictionStore $blockRestrictionStore,
                                        CommentStore $commentStore,
                                Severity: Major
                                Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

                                  Method getRangeCond has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function getRangeCond( $start, $end, $schema ) {
                                          // Per T16634, we want to include relevant active range blocks; for
                                          // range blocks, we want to include larger ranges which enclose the given
                                          // range. We know that all blocks must be smaller than $wgBlockCIDRLimit,
                                          // so we can improve performance by filtering on a LIKE clause
                                  Severity: Minor
                                  Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

                                    Method purgeExpiredBlocks has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function purgeExpiredBlocks() {
                                            if ( $this->readOnlyMode->isReadOnly( $this->wikiId ) ) {
                                                return;
                                            }
                                    
                                    
                                    Severity: Minor
                                    Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

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

                                          public function doAutoblock( DatabaseBlock $parentBlock, $autoblockIP ) {
                                              // If autoblocks are disabled, go away.
                                              if ( !$parentBlock->isAutoblocking() ) {
                                                  return false;
                                              }
                                      Severity: Minor
                                      Found in includes/block/DatabaseBlockStore.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 deleteBlocksMatchingConds has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          public function deleteBlocksMatchingConds( array $conds, $limit = null ) {
                                              $dbw = $this->getPrimaryDB();
                                              $affected = 0;
                                              if ( $this->writeStage & SCHEMA_COMPAT_WRITE_OLD ) {
                                                  $oldConds = self::mapCondsToOldSchema( $conds );
                                      Severity: Minor
                                      Found in includes/block/DatabaseBlockStore.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 insertBlock has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          public function insertBlock(
                                              DatabaseBlock $block,
                                              $expectedTargetCount = 0
                                          ) {
                                              $block->assertWiki( $this->wikiId );
                                      Severity: Minor
                                      Found in includes/block/DatabaseBlockStore.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 insertBlock has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          public function insertBlock(
                                              DatabaseBlock $block,
                                              $expectedTargetCount = 0
                                          ) {
                                              $block->assertWiki( $this->wikiId );
                                      Severity: Minor
                                      Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

                                        Method updateTimestamp has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            public function updateTimestamp( DatabaseBlock $block ) {
                                                $block->assertWiki( $this->wikiId );
                                                if ( $block->getType() !== Block::TYPE_AUTO ) {
                                                    return;
                                                }
                                        Severity: Minor
                                        Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

                                          Method performRetroactiveAutoblock has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              private function performRetroactiveAutoblock( DatabaseBlock $block ): array {
                                                  if ( !$this->options->get( MainConfigNames::PutIPinRC ) ) {
                                                      // No IPs in the recent changes table to autoblock
                                                      return [];
                                                  }
                                          Severity: Minor
                                          Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

                                            Method purgeExpiredConflicts has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                                private function purgeExpiredConflicts(
                                                    DatabaseBlock $block,
                                                    IDatabase $dbw
                                                ) {
                                                    $ipblocksIDs = [];
                                            Severity: Minor
                                            Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

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

                                                  private function deleteBlockRows( $rows ) {
                                                      $ids = [];
                                                      $deltasByTarget = [];
                                                      foreach ( $rows as $row ) {
                                                          $ids[] = (int)$row->bl_id;
                                              Severity: Minor
                                              Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

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

                                                    public function __construct(
                                                        ServiceOptions $options,
                                                        LoggerInterface $logger,
                                                        ActorStoreFactory $actorStoreFactory,
                                                        BlockRestrictionStore $blockRestrictionStore,
                                                Severity: Minor
                                                Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

                                                  Method newListFromConds has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                                  Open

                                                      public function newListFromConds( $conds, $fromPrimary = false, $includeExpired = false ) {
                                                          $db = $fromPrimary ? $this->getPrimaryDB() : $this->getReplicaDB();
                                                          if ( $this->readStage === SCHEMA_COMPAT_READ_OLD ) {
                                                              $conds = self::mapCondsToOldSchema( $conds );
                                                              if ( !$includeExpired ) {
                                                  Severity: Minor
                                                  Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

                                                    Method newFromID has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                                    Open

                                                        public function newFromID( $id ) {
                                                            $dbr = $this->getReplicaDB();
                                                            if ( $this->readStage === SCHEMA_COMPAT_READ_OLD ) {
                                                                $blockQuery = $this->getQueryInfo( self::SCHEMA_IPBLOCKS );
                                                                $res = $dbr->selectRow(
                                                    Severity: Minor
                                                    Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix

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

                                                          public function getQueryInfo( $schema ) {
                                                              if ( $this->readStage === SCHEMA_COMPAT_READ_OLD ) {
                                                                  $commentQuery = $this->commentStore->getJoin( 'ipb_reason' );
                                                                  if ( $schema === self::SCHEMA_IPBLOCKS ) {
                                                                      return [
                                                      Severity: Minor
                                                      Found in includes/block/DatabaseBlockStore.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

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

                                                          public function updateTarget( DatabaseBlock $block, $newTarget ) {
                                                              $dbw = $this->getPrimaryDB();
                                                              $blockId = $block->getId( $this->wikiId );
                                                              if ( !$blockId ) {
                                                                  throw new InvalidArgumentException(
                                                      Severity: Minor
                                                      Found in includes/block/DatabaseBlockStore.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

                                                      Function newListFromConds has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                      Open

                                                          public function newListFromConds( $conds, $fromPrimary = false, $includeExpired = false ) {
                                                              $db = $fromPrimary ? $this->getPrimaryDB() : $this->getReplicaDB();
                                                              if ( $this->readStage === SCHEMA_COMPAT_READ_OLD ) {
                                                                  $conds = self::mapCondsToOldSchema( $conds );
                                                                  if ( !$includeExpired ) {
                                                      Severity: Minor
                                                      Found in includes/block/DatabaseBlockStore.php - About 35 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 chooseMostSpecificBlock has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                      Open

                                                          private function chooseMostSpecificBlock( array $blocks ) {
                                                              if ( count( $blocks ) === 1 ) {
                                                                  return $blocks[0];
                                                              }
                                                      
                                                      
                                                      Severity: Minor
                                                      Found in includes/block/DatabaseBlockStore.php - About 35 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 getArrayForAutoblockUpdate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                      Open

                                                          private function getArrayForAutoblockUpdate( DatabaseBlock $block, $schema ): array {
                                                              $blocker = $block->getBlocker();
                                                              if ( !$blocker ) {
                                                                  throw new RuntimeException( __METHOD__ . ': this block does not have a blocker' );
                                                              }
                                                      Severity: Minor
                                                      Found in includes/block/DatabaseBlockStore.php - About 35 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 $status
                                                                  ? $status['id']
                                                                  : false;
                                                      Severity: Major
                                                      Found in includes/block/DatabaseBlockStore.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

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

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                      return [];
                                                          Severity: Major
                                                          Found in includes/block/DatabaseBlockStore.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                    return [ $id ];
                                                            Severity: Major
                                                            Found in includes/block/DatabaseBlockStore.php - About 30 mins to fix

                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                              Open

                                                                      if ( $schema === self::SCHEMA_IPBLOCKS ) {
                                                                          $blockArray = [
                                                                              'ipb_by_actor'       => $blockerActor,
                                                                              'ipb_create_account' => $block->isCreateAccountBlocked(),
                                                                              'ipb_deleted'        => (int)$block->getHideName(), // typecast required for SQLite
                                                              Severity: Major
                                                              Found in includes/block/DatabaseBlockStore.php and 1 other location - About 3 hrs to fix
                                                              includes/block/DatabaseBlockStore.php on lines 1816..1841

                                                              Duplicated Code

                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                              Tuning

                                                              This issue has a mass of 148.

                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                              Refactorings

                                                              Further Reading

                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                              Open

                                                                      } else {
                                                                          $blockArray = [
                                                                              'bl_by_actor'       => $blockerActor,
                                                                              'bl_create_account' => $block->isCreateAccountBlocked(),
                                                                              'bl_deleted'        => (int)$block->getHideName(), // typecast required for SQLite
                                                              Severity: Major
                                                              Found in includes/block/DatabaseBlockStore.php and 1 other location - About 3 hrs to fix
                                                              includes/block/DatabaseBlockStore.php on lines 1791..1841

                                                              Duplicated Code

                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                              Tuning

                                                              This issue has a mass of 148.

                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                              Refactorings

                                                              Further Reading

                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                              Open

                                                                      if ( $this->writeStage & SCHEMA_COMPAT_WRITE_OLD ) {
                                                                          $dbw->newUpdateQueryBuilder()
                                                                              ->update( 'ipblocks' )
                                                                              ->set(
                                                                                  [
                                                              Severity: Minor
                                                              Found in includes/block/DatabaseBlockStore.php and 1 other location - About 30 mins to fix
                                                              includes/block/DatabaseBlockStore.php on lines 2049..2060

                                                              Duplicated Code

                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                              Tuning

                                                              This issue has a mass of 90.

                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                              Refactorings

                                                              Further Reading

                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                              Open

                                                                      if ( $this->writeStage & SCHEMA_COMPAT_WRITE_NEW ) {
                                                                          $dbw->newUpdateQueryBuilder()
                                                                              ->update( 'block' )
                                                                              ->set(
                                                                                  [
                                                              Severity: Minor
                                                              Found in includes/block/DatabaseBlockStore.php and 1 other location - About 30 mins to fix
                                                              includes/block/DatabaseBlockStore.php on lines 2037..2048

                                                              Duplicated Code

                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                              Tuning

                                                              This issue has a mass of 90.

                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                              Refactorings

                                                              Further Reading

                                                              There are no issues that match your filters.

                                                              Category
                                                              Status