wikimedia/mediawiki-core

View on GitHub
includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php

Summary

Maintainability
F
3 days
Test Coverage

File HtmlOutputRendererHelper.php has 503 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
Severity: Major
Found in includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php - About 1 day to fix

    Function getParserOutputInternal has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getParserOutputInternal( ParserOptions $parserOptions ): Status {
            // NOTE: ParsoidOutputAccess::getParserOutput() should be used for revisions
            //       that comes from the database. Either this revision is null to indicate
            //       the current revision or the revision must have an ID.
            // If we have a revision and the ID is 0 or null, then it's a fake revision
    Severity: Minor
    Found in includes/Rest/Handler/Helper/HtmlOutputRendererHelper.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

    Method getParserOutputInternal has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function getParserOutputInternal( ParserOptions $parserOptions ): Status {
            // NOTE: ParsoidOutputAccess::getParserOutput() should be used for revisions
            //       that comes from the database. Either this revision is null to indicate
            //       the current revision or the revision must have an ID.
            // If we have a revision and the ID is 0 or null, then it's a fake revision
    Severity: Major
    Found in includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php - About 3 hrs to fix

      HtmlOutputRendererHelper has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class HtmlOutputRendererHelper implements HtmlOutputHelper {
          use RestAuthorizeTrait;
          use RestStatusTrait;
      
          /**
      Severity: Minor
      Found in includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php - About 2 hrs to fix

        Function getParserOutput has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            private function getParserOutput(): ParserOutput {
                if ( !$this->parserOutput ) {
                    $parserOptions = ParserOptions::newFromAnon();
                    $parserOptions->setRenderReason( __METHOD__ );
        
        
        Severity: Minor
        Found in includes/Rest/Handler/Helper/HtmlOutputRendererHelper.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 getHtml has 47 lines of code (exceeds 25 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 1 hr to fix

          Method getParserOutput has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function getParserOutput(): ParserOutput {
                  if ( !$this->parserOutput ) {
                      $parserOptions = ParserOptions::newFromAnon();
                      $parserOptions->setRenderReason( __METHOD__ );
          
          
          Severity: Minor
          Found in includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php - About 1 hr to fix

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

                    ParsoidOutputStash $parsoidOutputStash,
                    StatsdDataFactoryInterface $statsDataFactory,
                    ParsoidOutputAccess $parsoidOutputAccess,
                    ParserOutputAccess $parserOutputAccess,
                    PageLookup $pageLookup,
            Severity: Major
            Found in includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php - About 1 hr to fix

              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 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

              There are no issues that match your filters.

              Category
              Status