wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function isValidFileMove has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function isValidFileMove() {
        $status = new Status();

        if ( !$this->newTitle->inNamespace( NS_FILE ) ) {
            // No need for further errors about the target filename being wrong
Severity: Minor
Found in includes/page/MovePage.php - About 1 hr 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 getSessionFromInfo has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function getSessionFromInfo( SessionInfo $info, WebRequest $request ) {
        // @codeCoverageIgnoreStart
        if ( defined( 'MW_NO_SESSION' ) ) {
            $ep = defined( 'MW_ENTRY_POINT' ) ? MW_ENTRY_POINT : 'this';

Severity: Minor
Found in includes/session/SessionManager.php - About 1 hr 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 logPotentialSessionLeakage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function logPotentialSessionLeakage( Session $session = null ) {
        $proxyLookup = MediaWikiServices::getInstance()->getProxyLookup();
        $session = $session ?: self::getGlobalSession();
        $suspiciousIpExpiry = $this->config->get( MainConfigNames::SuspiciousIpExpiry );

Severity: Minor
Found in includes/session/SessionManager.php - About 1 hr 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 moveUnsafe has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function moveUnsafe( UserIdentity $user, $reason, $createRedirect, array $changeTags ) {
        $status = Status::newGood();

        // TODO: make hooks accept UserIdentity
        $userObj = $this->userFactory->newFromUserIdentity( $user );
Severity: Minor
Found in includes/page/MovePage.php - About 1 hr 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 runPreDeleteHooks has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function runPreDeleteHooks( WikiPage $page, string &$reason ): Status {
        $status = Status::newGood();

        $legacyDeleter = $this->userFactory->newFromAuthority( $this->deleter );
        if ( !$this->hookRunner->onArticleDelete(
Severity: Minor
Found in includes/page/DeletePage.php - About 1 hr 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 replaceSectionAtRev has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function replaceSectionAtRev( $sectionId, Content $sectionContent,
        $sectionTitle = '', $baseRevId = null
    ) {
        if ( strval( $sectionId ) === '' ) {
            // Whole-page edit; let the whole text through
Severity: Minor
Found in includes/page/WikiPage.php - About 1 hr 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 loadOOUIDefinition has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function loadOOUIDefinition( $theme, $unused ): array {
        // This is shared between instances of this class, so we only have to load the JSON files once
        static $data = [];

        if ( !isset( $data[$theme] ) ) {
Severity: Minor
Found in includes/ResourceLoader/OOUIIconPackModule.php - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function run( string $hook, array $args = [], array $options = [] ): bool {
        $checkDeprecation = isset( $options['deprecatedVersion'] );

        $abortable = $options['abortable'] ?? true;
        foreach ( $this->getHandlers( $hook, $options ) as $handler ) {
Severity: Minor
Found in includes/HookContainer/HookContainer.php - About 1 hr 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 makeObjectSchema has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function makeObjectSchema(
        array $required = [], array $optional = [], $additional = false
    ): array {
        $schema = [ 'type' => 'object' ];

Severity: Minor
Found in includes/ParamValidator/TypeDef/ArrayDef.php - About 1 hr 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 composeCommonMailtext has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function composeCommonMailtext( MessageCache $messageCache ) {
        $services = MediaWikiServices::getInstance();
        $config = $services->getMainConfig();
        $userOptionsLookup = $services->getUserOptionsLookup();
        $urlUtils = $services->getUrlUtils();
Severity: Minor
Found in includes/mail/EmailNotification.php - About 1 hr 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 shouldExclude has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function shouldExclude( $name ) {
        if ( $name === '-total' ) {
            return true;
        }
        if ( !empty( $this->params['include'] ) ) {
Severity: Minor
Found in includes/profiler/ProfilerXhprof.php - About 1 hr 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 getPreviewLimitReport has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getPreviewLimitReport( ParserOutput $output = null ) {
        if ( !$output || !$output->getLimitReportData() ) {
            return '';
        }

Severity: Minor
Found in includes/editpage/EditPage.php - About 1 hr 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 convertGrammar has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function convertGrammar( $word, $case ) {
        $grammarForms =
            MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms );
        if ( isset( $grammarForms['hy'][$case][$word] ) ) {
            return $grammarForms['hy'][$case][$word];
Severity: Minor
Found in includes/languages/LanguageHy.php - About 1 hr 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 outputVariesOnRevisionMetaData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function outputVariesOnRevisionMetaData(
        ParserOutput $parserOutput,
        $actualPageId,
        $actualRevId,
        $actualRevTimestamp
Severity: Minor
Found in includes/Revision/RenderedRevision.php - About 1 hr 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 mapDiffPrevNext has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function mapDiffPrevNext( $old, $new ) {
        if ( $new === 'prev' ) {
            // Show diff between revision $old and the previous one. Get previous one from DB.
            $newid = intval( $old );
            $oldid = false;
Severity: Minor
Found in includes/diff/DifferenceEngine.php - About 1 hr 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 addMappings has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function addMappings( $mapArray, &$A2B, &$B2A, $exactCase = false, $prePat = '', $postPat = '' ) {
        foreach ( $mapArray as $WordA => $WordB ) {
            if ( !$exactCase ) {
                $ucA = $this->myUc( $WordA );
                $ucWordA = $this->myUcWord( $WordA );
Severity: Minor
Found in includes/languages/data/CrhExceptions.php - About 1 hr 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 doRenderBatch has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function doRenderBatch( string $oldText, string $newText, array $formats ): array {
        if ( $this->useMultiFormat ) {
            if ( !$this->formatOptions ) {
                /** @var array $result */
                $result = wikidiff2_multi_format_diff(
Severity: Minor
Found in includes/diff/TextDiffer/Wikidiff2TextDiffer.php - About 1 hr 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 guessOriginalRevisionId has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function guessOriginalRevisionId() {
        if ( !$this->originalRevisionId ) {
            if ( $this->revertAfterRevId ) {
                $this->setOriginalRevision( $this->revertAfterRevId );
            } elseif ( $this->newestRevertedRevId ) {
Severity: Minor
Found in includes/Storage/EditResultBuilder.php - About 1 hr 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 getPage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function getPage( ?int $pageId, ?int $revId, int $queryFlags = IDBAccessObject::READ_NORMAL ) {
        if ( !$pageId && !$revId ) {
            throw new InvalidArgumentException( '$pageId and $revId cannot both be 0 or null' );
        }

Severity: Minor
Found in includes/Revision/RevisionStore.php - About 1 hr 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 getParamInfo has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function getParamInfo( $name, $settings, array $options ) {
        $settings = $this->normalizeSettings( $settings );
        $typeDef = $this->getTypeDef( $settings[self::PARAM_TYPE] );
        $info = [];

Severity: Minor
Found in includes/libs/ParamValidator/ParamValidator.php - About 1 hr 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