wikimedia/mediawiki-core

View on GitHub
includes/parser/Parsoid/Config/DataAccess.php

Summary

Maintainability
D
2 days
Test Coverage

Function getFileInfo has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    public function getFileInfo( IPageConfig $pageConfig, array $files ): array {
        $page = Title::newFromLinkTarget( $pageConfig->getLinkTarget() );

        $keys = [];
        foreach ( $files as $f ) {
Severity: Minor
Found in includes/parser/Parsoid/Config/DataAccess.php - About 5 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

File DataAccess.php has 309 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Copyright (C) 2011-2022 Wikimedia Foundation and others.
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Minor
Found in includes/parser/Parsoid/Config/DataAccess.php - About 3 hrs to fix

    Method getFileInfo has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getFileInfo( IPageConfig $pageConfig, array $files ): array {
            $page = Title::newFromLinkTarget( $pageConfig->getLinkTarget() );
    
            $keys = [];
            foreach ( $files as $f ) {
    Severity: Major
    Found in includes/parser/Parsoid/Config/DataAccess.php - About 2 hrs to fix

      Method getPageInfo has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getPageInfo( $pageConfigOrTitle, array $titles ): array {
              if ( $pageConfigOrTitle instanceof IPageConfig ) {
                  $context_title = Title::newFromLinkTarget(
                      $pageConfigOrTitle->getLinkTarget()
                  );
      Severity: Major
      Found in includes/parser/Parsoid/Config/DataAccess.php - About 2 hrs to fix

        Function getPageInfo has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getPageInfo( $pageConfigOrTitle, array $titles ): array {
                if ( $pageConfigOrTitle instanceof IPageConfig ) {
                    $context_title = Title::newFromLinkTarget(
                        $pageConfigOrTitle->getLinkTarget()
                    );
        Severity: Minor
        Found in includes/parser/Parsoid/Config/DataAccess.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

        Method __construct has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                ServiceOptions $config,
                RepoGroup $repoGroup,
                BadFileLookup $badFileLookup,
                HookContainer $hookContainer,
                ContentTransformer $contentTransformer,
        Severity: Major
        Found in includes/parser/Parsoid/Config/DataAccess.php - About 1 hr to fix

          Function makeTransformOptions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              private function makeTransformOptions( IPageConfig $pageConfig, $file, array $hp ): array {
                  // Validate the input parameters like Parser::makeImage()
                  $handler = $file->getHandler();
                  if ( !$handler ) {
                      return []; // will get iconThumb()
          Severity: Minor
          Found in includes/parser/Parsoid/Config/DataAccess.php - About 55 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

          There are no issues that match your filters.

          Category
          Status