wikimedia/mediawiki-core

View on GitHub
includes/parser/Parsoid/HtmlToContentTransform.php

Summary

Maintainability
C
1 day
Test Coverage

HtmlToContentTransform has 37 functions (exceeds 20 allowed). Consider refactoring.
Open

class HtmlToContentTransform {
    private array $options = [];
    private ?int $oldid = null;
    private ?Bcp47Code $contentLanguage = null;
    private ?Content $originalContent = null;
Severity: Minor
Found in includes/parser/Parsoid/HtmlToContentTransform.php - About 4 hrs to fix

    File HtmlToContentTransform.php has 365 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace MediaWiki\Parser\Parsoid;
    
    use Composer\Semver\Semver;
    Severity: Minor
    Found in includes/parser/Parsoid/HtmlToContentTransform.php - About 4 hrs to fix

      Method getPageConfig has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function getPageConfig(): PageConfig {
              if ( !$this->pageConfig ) {
      
                  // XXX: do we even have to support wikitext overrides? What's the use case?
                  if ( $this->originalContent !== null ) {
      Severity: Minor
      Found in includes/parser/Parsoid/HtmlToContentTransform.php - About 1 hr to fix

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

            private function getPageConfig(): PageConfig {
                if ( !$this->pageConfig ) {
        
                    // XXX: do we even have to support wikitext overrides? What's the use case?
                    if ( $this->originalContent !== null ) {
        Severity: Minor
        Found in includes/parser/Parsoid/HtmlToContentTransform.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

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

                string $modifiedHTML,
                PageIdentity $page,
                Parsoid $parsoid,
                array $parsoidSettings,
                PageConfigFactory $pageConfigFactory,
        Severity: Minor
        Found in includes/parser/Parsoid/HtmlToContentTransform.php - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status