wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

    protected function doUnlockByType( array $pathsByType ) {
        $status = StatusValue::newGood();

        $pathsByTypeByBucket = []; // (bucket => type => paths)
        foreach ( $pathsByType as $type => $paths ) {
Severity: Minor
Found in includes/libs/lockmanager/QuorumLockManager.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

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

    public function getDirectoryListInternal( $container, $dir, array $params ) {
        $dirs = [];
        $prefix = rtrim( "$container/$dir", '/' ) . '/';
        $prefixLen = strlen( $prefix );
        foreach ( $this->files as $path => $data ) {
Severity: Minor
Found in includes/libs/filebackend/MemoryFileBackend.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

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

    final public function getFileStat( array $params ) {
        /** @noinspection PhpUnusedLocalVariableInspection */
        $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );

        $path = self::normalizeStoragePath( $params['src'] );
Severity: Minor
Found in includes/libs/filebackend/FileBackendStore.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

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

    public static function objectToArray( $object ) {
        $vars = (array)$object;
        $class = new \ReflectionClass( $object );
        while ( $class ) {
            foreach ( $class->getProperties() as $property ) {
Severity: Minor
Found in includes/libs/DebugInfo/DumpUtils.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

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

    protected function loadFiles(): void {
        # Allow media handling extensions adding MIME-types and MIME-info
        if ( $this->initCallback ) {
            call_user_func( $this->initCallback, $this );
        }
Severity: Minor
Found in includes/libs/mime/MimeAnalyzer.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

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

    final public function assertValidUpsertSetArray(
        array $set,
        array $uniqueKey,
        array $rows
    ) {
Severity: Minor
Found in includes/libs/rdbms/platform/SQLPlatform.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

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

    final protected function executeQuery( $sql, $fname, $flags ) {
        $this->assertHasConnectionHandle();

        $isPermWrite = false;
        $isWrite = $sql->isWriteQuery();
Severity: Minor
Found in includes/libs/rdbms/database/Database.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

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

    protected function reallyOpenConnection( $i, DatabaseDomain $domain, array $lbInfo ) {
        if ( $this->disabled ) {
            throw new DBAccessError();
        }

Severity: Minor
Found in includes/libs/rdbms/loadbalancer/LoadBalancer.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 __construct has 18 arguments (exceeds 4 allowed). Consider refactoring.
Open

        ServiceOptions $options,
        BlockRestrictionStore $blockRestrictionStore,
        BlockPermissionCheckerFactory $blockPermissionCheckerFactory,
        BlockUtils $blockUtils,
        BlockActionInfo $blockActionInfo,
Severity: Major
Found in includes/block/BlockUser.php - About 2 hrs to fix

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

            Article $article,
            IContextSource $context,
            Language $contentLanguage,
            LanguageNameUtils $languageNameUtils,
            LinkBatchFactory $linkBatchFactory,
    Severity: Major
    Found in includes/actions/InfoAction.php - About 2 hrs to fix

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

          protected function getTemplate( $templateName ) {
              $templateKey = $templateName . '|' . $this->compileFlags;
      
              // If a renderer has already been defined for this template, reuse it
              if ( isset( $this->renderers[$templateKey] ) &&
      Severity: Minor
      Found in includes/Html/TemplateParser.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

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

          public function onView() {
              $this->getOutput()->disable();
              $request = $this->getRequest();
              $response = $request->response();
              $config = $this->context->getConfig();
      Severity: Minor
      Found in includes/actions/RawAction.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

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

          public function getButtons() {
              $buttons = [];
      
              if ( $this->mShowSubmit ) {
                  $value = $this->getSubmitText();
      Severity: Minor
      Found in includes/htmlform/CodexHTMLForm.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

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

          private function getLanguageNamesUncached( $inLanguage, $include ) {
              // If passed an invalid language code to use, fallback to en
              if ( $inLanguage !== self::AUTONYMS && !$this->isValidCode( $inLanguage ) ) {
                  $inLanguage = 'en';
              }
      Severity: Minor
      Found in includes/language/LanguageNameUtils.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

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

          public static function simplifyFormDescriptor( array $descriptor ) {
              foreach ( $descriptor as $name => &$params ) {
                  // Info fields are useless and can use complicated closure to provide
                  // text, skip all of them.
                  if ( ( isset( $params['type'] ) && $params['type'] === 'info' ) ||
      Severity: Minor
      Found in includes/preferences/DefaultPreferencesFactory.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

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

          public function firstChar( $s ) {
              $firstChar = mb_substr( $s, 0, 1 );
      
              if ( $firstChar === '' || strlen( $firstChar ) != 3 ) {
                  return $firstChar;
      Severity: Minor
      Found in includes/language/Language.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

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

          private function loadItem( $code, $key ) {
              if ( isset( $this->loadedItems[$code][$key] ) ) {
                  return;
              }
      
      
      Severity: Minor
      Found in includes/language/LocalisationCache.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

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

          protected function getHeaderVariant() {
              if ( $this->mHeaderVariant ) {
                  return $this->mHeaderVariant;
              }
      
      
      Severity: Minor
      Found in includes/language/LanguageConverter.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

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

          private static function extractPageRecord( $externalData, $pageTitle ) {
              // If there is a special case with only one returned page
              // we can cheat, and only return
              // the single page in the "pages" substructure.
              if ( isset( $externalData['query']['pages'] ) ) {
      Severity: Minor
      Found in includes/site/MediaWikiPageNameNormalizer.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

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

          public function rename() {
              $dbw = $this->dbProvider->getPrimaryDatabase();
              $atomicId = $dbw->startAtomic( __METHOD__, $dbw::ATOMIC_CANCELABLE );
      
              $this->hookRunner->onRenameUserPreRename( $this->uid, $this->old, $this->new );
      Severity: Minor
      Found in includes/RenameUser/RenameuserSQL.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

      Severity
      Category
      Status
      Source
      Language