wikimedia/mediawiki-core

View on GitHub
maintenance/refreshImageMetadata.php

Summary

Maintainability
C
1 day
Test Coverage

Function execute has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $force = $this->hasOption( 'force' );
        $brokenOnly = $this->hasOption( 'broken-only' );
        $verbose = $this->hasOption( 'verbose' );
        $start = $this->getOption( 'start', false );
Severity: Minor
Found in maintenance/refreshImageMetadata.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 execute has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function execute() {
        $force = $this->hasOption( 'force' );
        $brokenOnly = $this->hasOption( 'broken-only' );
        $verbose = $this->hasOption( 'verbose' );
        $start = $this->getOption( 'start', false );
Severity: Major
Found in maintenance/refreshImageMetadata.php - About 3 hrs to fix

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

        public function __construct() {
            parent::__construct();
    
            $this->addDescription( 'Script to update image metadata records' );
            $this->setBatchSize( 200 );
    Severity: Major
    Found in maintenance/refreshImageMetadata.php - About 2 hrs to fix

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

          private function newLocalRepo( $force, $brokenOnly, $reserialize, $split ): LocalRepo {
              if ( $brokenOnly && $force ) {
                  $this->fatalError( 'Cannot use --broken-only and --force together. ', 2 );
              }
              $reserialize = $reserialize || $split;
      Severity: Minor
      Found in maintenance/refreshImageMetadata.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 setConditions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          private function setConditions( IReadableDatabase $dbw, SelectQueryBuilder $queryBuilder, $fieldPrefix ) {
              $end = $this->getOption( 'end', false );
              $mime = $this->getOption( 'mime', false );
              $mediatype = $this->getOption( 'mediatype', false );
              $like = $this->getOption( 'metadata-contains', false );
      Severity: Minor
      Found in maintenance/refreshImageMetadata.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