wikimedia/mediawiki-core

View on GitHub

Showing 9,426 of 11,461 total issues

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

    protected function removeNonexistentFiles( $triplets ) {
        $files = [];

        foreach ( $triplets as $file ) {
            $files[$file[0]] = $file[0];
Severity: Minor
Found in includes/filerepo/file/LocalFileMoveBatch.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 extractThumbRequestInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function extractThumbRequestInfo( $thumbRel ) {
        $repo = $this->getServiceContainer()->getRepoGroup()->getLocalRepo();

        $hashDirReg = $subdirReg = '';
        $hashLevels = $repo->getHashLevels();
Severity: Minor
Found in includes/filerepo/Thumbnail404EntryPoint.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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( $title, $id = 0, $key = '', $sha1 = '' ) {
        $this->id = -1;
        $this->title = null;
        $this->name = false;
        $this->group = 'deleted'; // needed for direct use of constructor
Severity: Minor
Found in includes/filerepo/file/ArchivedFile.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 getZoneUrl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getZoneUrl( $zone, $ext = null ) {
        if ( in_array( $zone, [ 'public', 'thumb', 'transcoded' ] ) ) {
            // standard public zones
            if ( $ext !== null && isset( $this->zones[$zone]['urlsByExt'][$ext] ) ) {
                // custom URL for extension/zone
Severity: Minor
Found in includes/filerepo/FileRepo.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 mungeOpPaths has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function mungeOpPaths( array $ops ) {
        // Ops that use 'src' and do not mutate core file data there
        static $srcRefOps = [ 'store', 'copy', 'describe' ];
        foreach ( $ops as &$op ) {
            if ( isset( $op['src'] ) && in_array( $op['op'], $srcRefOps ) ) {
Severity: Minor
Found in includes/filerepo/FileBackendDBRepoWrapper.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 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

Severity
Category
Status
Source
Language