wikimedia/mediawiki-core

View on GitHub

Showing 11,498 of 11,498 total issues

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

    private function readAndDecode( SettingsFormat $format ): array {
        $contents = AtEase::quietCall( 'file_get_contents', $this->path );

        if ( $contents === false ) {
            if ( !is_readable( $this->path ) ) {
Severity: Minor
Found in includes/Settings/Source/FileSource.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( $params = [] ) {
        parent::__construct();

        if ( isset( $params['sessionCookieName'] ) ) {
            if ( !is_string( $params['sessionCookieName'] ) ) {
Severity: Minor
Found in includes/session/ImmutableSessionProviderWithCookie.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 loadLocalSettingsFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function loadLocalSettingsFile( string $file ) {
        // If $file is not a PHP file, just load it as a data file.
        if ( !str_ends_with( $file, '.php' ) ) {
            $this->settingsBuilder->loadFile( $file );
            return;
Severity: Minor
Found in includes/Settings/LocalSettingsLoader.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 newFromTitle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function newFromTitle( PageIdentity $pageIdentity ): WikiPage {
        if ( $pageIdentity instanceof WikiPage ) {
            return $pageIdentity;
        }

Severity: Minor
Found in includes/page/WikiPageFactory.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 deleteUnsafe has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function deleteUnsafe( string $reason ): Status {
        $this->setDeletionAttempted();
        $origReason = $reason;
        $hookStatus = $this->runPreDeleteHooks( $this->page, $reason );
        if ( !$hookStatus->isGood() ) {
Severity: Minor
Found in includes/page/DeletePage.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 showDiffPage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function showDiffPage() {
        $context = $this->getContext();
        $outputPage = $context->getOutput();
        $outputPage->addBodyClasses( 'mw-article-diff' );
        $request = $context->getRequest();
Severity: Minor
Found in includes/page/Article.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 makeMetadataTable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function makeMetadataTable( $metadata ) {
        $r = $this->getContext()->msg( 'metadata-help' )->plain();
        // Initial state of collapsible rows is collapsed
        // see mediawiki.action.view.filepage.less and mediawiki.action.view.metadata module.
        $r .= "<table id=\"mw_metadata\" class=\"mw_metadata collapsed\">\n";
Severity: Minor
Found in includes/page/ImagePage.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 printSharedImageText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function printSharedImageText() {
        $out = $this->getContext()->getOutput();
        $this->loadFile();

        $descUrl = $this->getFile()->getDescriptionUrl();
Severity: Minor
Found in includes/page/ImagePage.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 closeShowCategory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function closeShowCategory() {
        // Use these as defaults for back compat --catrope
        $request = $this->getContext()->getRequest();
        $oldFrom = $request->getVal( 'from' );
        $oldUntil = $request->getVal( 'until' );
Severity: Minor
Found in includes/page/CategoryPage.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 renderRevision has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function renderRevision(
        PageRecord $page,
        ParserOptions $parserOptions,
        RevisionRecord $revision,
        int $options
Severity: Minor
Found in includes/page/ParserOutputAccess.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 tryFileCache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function tryFileCache() {
        static $called = false;

        if ( $called ) {
            wfDebug( "Article::tryFileCache(): called twice!?" );
Severity: Minor
Found in includes/page/Article.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 getBlobs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getBlobs( array $modules, $lang ) {
        // Each cache key for a message blob by module name and language code also has a generic
        // check key without language code. This is used to invalidate any and all language subkeys
        // that exist for a module from the updateMessage() method.
        $checkKeys = [
Severity: Minor
Found in includes/ResourceLoader/MessageBlobStore.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 getCombinedVersion has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getCombinedVersion( Context $context, array $moduleNames ) {
        if ( !$moduleNames ) {
            return '';
        }
        $hashes = [];
Severity: Minor
Found in includes/ResourceLoader/ResourceLoader.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 replaceSectionContent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function replaceSectionContent(
        $sectionId, Content $sectionContent, $sectionTitle = '', $edittime = null
    ) {
        $baseRevId = null;
        if ( $edittime && $sectionId !== 'new' ) {
Severity: Minor
Found in includes/page/WikiPage.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 getModule has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getModule( $name ) {
        if ( !isset( $this->modules[$name] ) ) {
            if ( !isset( $this->moduleInfos[$name] ) ) {
                // No such module
                return null;
Severity: Minor
Found in includes/ResourceLoader/ResourceLoader.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 fetchTitleInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected static function fetchTitleInfo( IReadableDatabase $db, array $pages, $fname = __METHOD__ ) {
        $titleInfo = [];
        $linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
        $batch = $linkBatchFactory->newLinkBatch();
        foreach ( $pages as $titleText ) {
Severity: Minor
Found in includes/ResourceLoader/WikiModule.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 loadLastEdit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function loadLastEdit() {
        if ( $this->mLastRevision !== null ) {
            return; // already loaded
        }

Severity: Minor
Found in includes/page/WikiPage.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 getContent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getContent( $titleText, Context $context ) {
        $pageStore = MediaWikiServices::getInstance()->getPageStore();
        $title = $pageStore->getPageByText( $titleText );
        if ( !$title ) {
            return null; // Bad title
Severity: Minor
Found in includes/ResourceLoader/WikiModule.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 findUniqueTags has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function findUniqueTags( DOMNode $rootNode, array $tagNames ): array {
        $nodes = [];
        foreach ( $rootNode->childNodes as $node ) {
            $tagName = strtolower( $node->nodeName );
            if ( in_array( $tagName, $tagNames ) ) {
Severity: Minor
Found in includes/ResourceLoader/VueComponentParser.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 getStyles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getStyles( Context $context ) {
        $styles = $this->readStyleFiles(
            $this->getStyleFiles( $context ),
            $context
        );
Severity: Minor
Found in includes/ResourceLoader/FileModule.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