wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function getFeatureFilePaths has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function getFeatureFilePaths() {
        // Bypass the current module paths so that these files are served from core,
        // instead of the individual skin's module directory.
        [ $defaultLocalBasePath, $defaultRemoteBasePath ] =
            FileModule::extractBasePaths(
Severity: Minor
Found in includes/ResourceLoader/SkinModule.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

Function doSingleLock has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doSingleLock( $path, $type ) {
        $status = StatusValue::newGood();

        if ( isset( $this->locksHeld[$path][$type] ) ) {
            ++$this->locksHeld[$path][$type];
Severity: Minor
Found in includes/libs/lockmanager/FSLockManager.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

Function fetchOrRegenerate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    private function fetchOrRegenerate( $key, $ttl, $callback, array $opts, array $cbParams ) {
        $checkKeys = $opts['checkKeys'] ?? [];
        $graceTTL = $opts['graceTTL'] ?? self::GRACE_TTL_NONE;
        $minAsOf = $opts['minAsOf'] ?? self::MIN_TIMESTAMP_NONE;
        $hotTTR = $opts['hotTTR'] ?? self::HOT_TTR;
Severity: Minor
Found in includes/libs/objectcache/WANObjectCache.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

Function getCurlHandle has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getCurlHandle( array &$req, array $opts ) {
        $ch = curl_init();

        curl_setopt( $ch, CURLOPT_PROXY, $req['proxy'] ?? $this->proxy );
        curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT_MS, intval( $opts['connTimeout'] * 1e3 ) );
Severity: Minor
Found in includes/libs/http/MultiHttpClient.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

Function makeListItem has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    private function makeListItem(
        string $key,
        array $item,
        array $options = [],
        array $linkOptions = []
Severity: Minor
Found in includes/skins/components/SkinComponentListItem.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

Function formatRow has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function formatRow( $row ) {
        $resultOffset = $this->getResultOffset();
        $numRows = min( $this->mResult->numRows(), $this->mLimit );

        $firstInList = $resultOffset === ( $this->mIsBackwards ? $numRows - 1 : 0 );
Severity: Minor
Found in includes/actions/pagers/HistoryPager.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

Function handleRollbackRequest has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function handleRollbackRequest() {
        $this->enableTransactionalTimelimit();
        $this->getOutput()->addModuleStyles( 'mediawiki.interface.helpers.styles' );

        $request = $this->getRequest();
Severity: Minor
Found in includes/actions/RollbackAction.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

Function __construct has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( $params ) {
        $this->mParams = $params;

        if ( isset( $params['parent'] ) && $params['parent'] instanceof HTMLForm ) {
            $this->mParent = $params['parent'];
Severity: Minor
Found in includes/htmlform/HTMLFormField.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

Function createFieldsForKey has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    protected function createFieldsForKey( $key ) {
        $fields = [];
        foreach ( $this->mParams['fields'] as $fieldname => $info ) {
            $name = "{$this->mName}[$key][$fieldname]";
            if ( isset( $info['name'] ) ) {
Severity: Minor
Found in includes/htmlform/fields/HTMLFormFieldCloner.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

Function initializeArticle has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    protected function initializeArticle() {
        $context = $this->getContext();

        $title = $context->getTitle();
        $services = $this->getServiceContainer();
Severity: Minor
Found in includes/actions/ActionEntryPoint.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

Function loadFromDB has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    private function loadFromDB( $code, $mode = null ) {
        $icp = MediaWikiServices::getInstance()->getConnectionProvider();

        $dbr = ( $mode === self::FOR_UPDATE ) ? $icp->getPrimaryDatabase() : $icp->getReplicaDatabase();

Severity: Minor
Found in includes/language/MessageCache.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

Function validateSignature has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function validateSignature( string $signature ) {
        $pstSignature = $this->applyPreSaveTransform( $signature );
        if ( $pstSignature === false ) {
            // Return early because the rest of the validation uses wikitext parsing, which requires
            // the pre-save transform to be applied first, and we just found out that the result of the
Severity: Minor
Found in includes/preferences/SignatureValidator.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

Function findVariantLink has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
        # If the article has already existed, there is no need to
        # check it again. Otherwise it may cause a fault.
        if ( $nt instanceof LinkTarget ) {
            $nt = Title::castFromLinkTarget( $nt );
Severity: Minor
Found in includes/language/LanguageConverter.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

Function transformDOM has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function transformDOM(
        Document $dom, ParserOutput $po, ?ParserOptions $popts, array &$options
    ): Document {
        $skin = $this->resolveSkin( $options );
        $titleText = $po->getTitleText();
Severity: Minor
Found in includes/OutputTransform/Stages/HandleParsoidSectionLinks.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

Function doPSIR has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public static function doPSIR( $app13 ) {
        if ( !$app13 ) {
            throw new InvalidPSIRException( "No App13 segment given" );
        }
        // First compare hash with real thing
Severity: Minor
Found in includes/media/JpegMetadataExtractor.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

Function collapseData has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    private function collapseData() {
        $this->exifGPStoNumber( 'GPSLatitude' );
        $this->exifGPStoNumber( 'GPSDestLatitude' );
        $this->exifGPStoNumber( 'GPSLongitude' );
        $this->exifGPStoNumber( 'GPSDestLongitude' );
Severity: Minor
Found in includes/media/Exif.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

Function getIP has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function getIP(): string {
        global $wgUsePrivateIPs;

        # Return cached result
        if ( $this->ip !== null ) {
Severity: Minor
Found in includes/Request/WebRequest.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

Function getSizeAndMetadataWithFallback has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    final public function getSizeAndMetadataWithFallback( $file, $path ) {
        if ( !$this->useLegacyMetadata() ) {
            if ( $file instanceof MediaHandlerState ) {
                $state = $file;
            } else {
Severity: Minor
Found in includes/media/MediaHandler.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

Function getSearchResultData has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    private function getSearchResultData( SearchResult $result, $prop ) {
        // Silently skip broken and missing titles
        if ( $result->isBrokenTitle() || $result->isMissingRevision() ) {
            return null;
        }
Severity: Minor
Found in includes/api/ApiQuerySearch.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

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

    public function execute() {
        $config = $this->getConfig();
        $feedClasses = $config->get( MainConfigNames::FeedClasses );
        $params = [];
        $feedItems = [];
Severity: Minor
Found in includes/api/ApiFeedWatchlist.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

Severity
Category
Status
Source
Language