wikimedia/mediawiki-core

View on GitHub
includes/ResourceLoader/VueComponentParser.php

Summary

Maintainability
B
5 hrs
Test Coverage

Method newTemplateFormatter has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function newTemplateFormatter( $minify ) {
        return new class( $minify ) extends HtmlFormatter {
            private $minify;

            public function __construct( $minify ) {
Severity: Minor
Found in includes/ResourceLoader/VueComponentParser.php - About 1 hr to fix

    Method newFilteringDispatcher has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function newFilteringDispatcher( TreeBuilder $treeBuilder, $nodeName ) {
            return new class( $treeBuilder, $nodeName ) extends Dispatcher {
                private $nodeName;
                private $nodeDepth = 0;
                private $seenTag = false;
    Severity: Minor
    Found in includes/ResourceLoader/VueComponentParser.php - About 1 hr to fix

      Method startTag has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

                  public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) {
      Severity: Minor
      Found in includes/ResourceLoader/VueComponentParser.php - About 35 mins to fix

        Method characters has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                    public function characters( $text, $start, $length, $sourceStart, $sourceLength ) {
        Severity: Minor
        Found in includes/ResourceLoader/VueComponentParser.php - About 35 mins to fix

          Function validateAttributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              private function validateAttributes( DOMNode $node, array $allowedAttributes ): void {
                  if ( $allowedAttributes ) {
                      foreach ( $node->attributes as $attr ) {
                          if ( !in_array( $attr->name, $allowedAttributes ) ) {
                              throw new InvalidArgumentException( "<{$node->nodeName}> may not have the " .
          Severity: Minor
          Found in includes/ResourceLoader/VueComponentParser.php - About 35 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

          There are no issues that match your filters.

          Category
          Status