wikimedia/mediawiki-core

View on GitHub
includes/title/MediaWikiTitleCodec.php

Summary

Maintainability
D
2 days
Test Coverage

Method splitTitleString has 194 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function splitTitleString( $text, $defaultNamespace = NS_MAIN ) {
        $dbkey = str_replace( ' ', '_', $text );

        # Initialisation
        $parts = [
Severity: Major
Found in includes/title/MediaWikiTitleCodec.php - About 7 hrs to fix

    Function splitTitleString has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

        public function splitTitleString( $text, $defaultNamespace = NS_MAIN ) {
            $dbkey = str_replace( ' ', '_', $text );
    
            # Initialisation
            $parts = [
    Severity: Minor
    Found in includes/title/MediaWikiTitleCodec.php - About 7 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

    File MediaWikiTitleCodec.php has 389 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * A codec for MediaWiki page titles.
     *
     * This program is free software; you can redistribute it and/or modify
    Severity: Minor
    Found in includes/title/MediaWikiTitleCodec.php - About 5 hrs to fix

      Consider simplifying this complex logical expression.
      Open

              if (
                  str_contains( $dbkey, '.' ) &&
                  (
                      $dbkey === '.' || $dbkey === '..' ||
                      str_starts_with( $dbkey, './' ) ||
      Severity: Critical
      Found in includes/title/MediaWikiTitleCodec.php - About 1 hr to fix

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

                Language $language,
                GenderCache $genderCache,
                $localInterwikis,
                InterwikiLookup $interwikiLookup,
                NamespaceInfo $nsInfo
        Severity: Minor
        Found in includes/title/MediaWikiTitleCodec.php - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status