wikimedia/mediawiki-core

View on GitHub

Showing 11,461 of 11,461 total issues

Function getThumbnails has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getThumbnails( $archiveName = false ) {
        if ( $archiveName ) {
            $dir = $this->getArchiveThumbPath( $archiveName );
        } else {
            $dir = $this->getThumbPath();
Severity: Minor
Found in includes/filerepo/file/LocalFile.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

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

    public function execute() {
        $searchEngine = $this->createSearchEngine();
        $pageInfos = $this->doSearch( $searchEngine );

        // We can only pass validated "real" PageIdentities to our hook handlers below
Severity: Minor
Found in includes/Rest/Handler/SearchHandler.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

Function getContentType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getContentType(
        string $format, ?string $contentVersion = null
    ): string {
        if ( $format !== self::FORMAT_WIKITEXT && !$contentVersion ) {
            throw new InvalidArgumentException( '$contentVersion is required for this format' );
Severity: Minor
Found in includes/Rest/Handler/Helper/ParsoidFormatHelper.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

Function validateBodyParams has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function validateBodyParams( array $paramSettings ) {
        $validatedParams = [];
        foreach ( $paramSettings as $name => $settings ) {
            $source = $settings[Handler::PARAM_SOURCE] ?? 'body';
            if ( $source !== 'body' ) {
Severity: Minor
Found in includes/Rest/Validator/Validator.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

Function stripParsoidSectionTags has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function stripParsoidSectionTags( Element $elt ): void {
        $n = $elt->firstChild;
        while ( $n ) {
            $next = $n->nextSibling;
            if ( $n instanceof Element ) {
Severity: Minor
Found in includes/Rest/Handler/Helper/HtmlOutputRendererHelper.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

Function getOpenAPISpec has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getOpenAPISpec(): array {
        $body = [];
        $required = [];

        // XXX: Maybe we want to be able to define a spec file in the route definition?
Severity: Minor
Found in includes/Rest/Validator/JsonBodyValidator.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

Function assertDomainIsCorrect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function assertDomainIsCorrect( $domain ): void {
        // We are cutting some corners here (IDN, non-ASCII casing)
        // since domain name support is provisional.
        // TODO use a proper validator instead
        $server = RequestContext::getMain()->getConfig()->get( MainConfigNames::Server );
Severity: Minor
Found in includes/Rest/Handler/ParsoidHandler.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

Function run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function run(): Response {
        $this->contentHelper->checkAccess();
        $page = $this->contentHelper->getPageIdentity();

        if ( !$page->exists() ) {
Severity: Minor
Found in includes/Rest/Handler/PageSourceHandler.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

Function loadRoutes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function loadRoutes( string $fileName ) {
        $spec = $this->loadJsonFile( $fileName );

        if ( isset( $spec['routes'] ) ) {
            if ( !isset( $spec['module'] ) ) {
Severity: Minor
Found in includes/Rest/Module/RouteFileModule.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

Function validateParams has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function validateParams( array $paramSettings ) {
        $validatedParams = [];
        foreach ( $paramSettings as $name => $settings ) {
            try {
                $source = $settings[Handler::PARAM_SOURCE] ?? 'unspecified';
Severity: Minor
Found in includes/Rest/Validator/Validator.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

Function validateBody has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function validateBody( RequestInterface $request, Handler $handler ) {
        $method = strtoupper( trim( $request->getMethod() ) );

        // If the method should never have a body, don't bother validating.
        if ( in_array( $method, self::NO_BODY_METHODS, true ) ) {
Severity: Minor
Found in includes/Rest/Validator/Validator.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

Function tryToCreatePageConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function tryToCreatePageConfig(
        array $attribs, ?string $wikitextOverride = null, bool $html2WtMode = false
    ): PageConfig {
        $revId = $attribs['oldid'];
        $pagelanguageOverride = $attribs['pagelanguage'];
Severity: Minor
Found in includes/Rest/Handler/ParsoidHandler.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

Function detectExtraneousBodyFields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function detectExtraneousBodyFields( array $paramSettings, array $parsedBody ) {
        $validatedKeys = [];
        $remainingBodyFields = $parsedBody;
        foreach ( $paramSettings as $name => $settings ) {
            $source = $settings[Handler::PARAM_SOURCE] ?? 'unspecified';
Severity: Minor
Found in includes/Rest/Validator/Validator.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

Function getHtml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getHtml(): ParserOutput {
        if ( $this->processedParserOutput ) {
            return $this->processedParserOutput;
        }

Severity: Minor
Found in includes/Rest/Handler/Helper/HtmlOutputRendererHelper.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

Function throwHttpExceptionForActionModuleError has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function throwHttpExceptionForActionModuleError( IApiMessage $msg, $statusCode = 400 ) {
        $code = $msg->getApiCode();

        if ( $code === 'protectedpage' ) {
            throw new LocalizedHttpException( $this->makeMessageValue( $msg ), 403 );
Severity: Minor
Found in includes/Rest/Handler/EditHandler.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

Function areDatabaseTransactionsActive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function areDatabaseTransactionsActive(): bool {
        $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
        if ( $lbFactory->hasTransactionRound()
            || !$lbFactory->isReadyForRoundOperations()
        ) {
Severity: Minor
Found in includes/deferred/DeferredUpdatesScopeMediaWikiStack.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

Function onRunUpdateStart has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function onRunUpdateStart( DeferrableUpdate $update ): void {
        // Increment a counter metric
        $type = get_class( $update )
            . ( $update instanceof DeferrableCallback ? '_' . $update->getOrigin() : '' );
        $httpMethod = MW_ENTRY_POINT === 'cli' ? 'cli' : strtolower( $_SERVER['REQUEST_METHOD'] ?? 'GET' );
Severity: Minor
Found in includes/deferred/DeferredUpdatesScopeMediaWikiStack.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

Function doUpdate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function doUpdate() {
        if ( !$this->mId ) {
            // NOTE: subclasses may initialize mId directly!
            $this->mId = $this->mTitle->getArticleID( IDBAccessObject::READ_LATEST );
        }
Severity: Minor
Found in includes/deferred/LinksUpdate/LinksUpdate.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

Function emit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function emit( $text, $file ) {
        if ( str_starts_with( $file, 'udp:' ) ) {
            $transport = UDPTransport::newFromString( $file );
            $transport->emit( $text );
        } else {
Severity: Minor
Found in includes/debug/logger/LegacyLogger.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

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

    public function execute(): Response {
        $ctype = $this->getContentType();

        $response = $this->getResponseFactory()->create();
        $response->setHeader( 'Content-type', $ctype );
Severity: Minor
Found in includes/Rest/Handler/OpenSearchDescriptionHandler.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

Severity
Category
Status
Source
Language