wikimedia/mediawiki-core

View on GitHub
includes/parser/ParserCache.php

Summary

Maintainability
D
3 days
Test Coverage

File ParserCache.php has 410 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Cache for outputs of the PHP parser
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Minor
Found in includes/parser/ParserCache.php - About 5 hrs to fix

    Method save has 128 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function save(
            ParserOutput $parserOutput,
            PageRecord $page,
            $popts,
            $cacheTime = null,
    Severity: Major
    Found in includes/parser/ParserCache.php - About 5 hrs to fix

      Function save has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public function save(
              ParserOutput $parserOutput,
              PageRecord $page,
              $popts,
              $cacheTime = null,
      Severity: Minor
      Found in includes/parser/ParserCache.php - About 2 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 get has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function get( PageRecord $page, $popts, $useOutdated = false ) {
              $page->assertWiki( PageRecord::LOCAL );
      
              if ( !$page->exists() ) {
                  $this->incrementStats( $page, 'miss', 'nonexistent' );
      Severity: Major
      Found in includes/parser/ParserCache.php - About 2 hrs to fix

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

                string $name,
                BagOStuff $cache,
                string $cacheEpoch,
                HookContainer $hookContainer,
                JsonCodec $jsonCodec,
        Severity: Major
        Found in includes/parser/ParserCache.php - About 1 hr to fix

          Method getMetadata has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getMetadata(
                  PageRecord $page,
                  int $staleConstraint = self::USE_ANYTHING
              ): ?ParserCacheMetadata {
                  $page->assertWiki( PageRecord::LOCAL );
          Severity: Minor
          Found in includes/parser/ParserCache.php - About 1 hr to fix

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

                public function get( PageRecord $page, $popts, $useOutdated = false ) {
                    $page->assertWiki( PageRecord::LOCAL );
            
                    if ( !$page->exists() ) {
                        $this->incrementStats( $page, 'miss', 'nonexistent' );
            Severity: Minor
            Found in includes/parser/ParserCache.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 save has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    ParserOutput $parserOutput,
                    PageRecord $page,
                    $popts,
                    $cacheTime = null,
                    $revId = null
            Severity: Minor
            Found in includes/parser/ParserCache.php - About 35 mins to fix

              Avoid too many return statements within this method.
              Open

                      return $value;
              Severity: Major
              Found in includes/parser/ParserCache.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return false;
                Severity: Major
                Found in includes/parser/ParserCache.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return;
                  Severity: Major
                  Found in includes/parser/ParserCache.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return false;
                    Severity: Major
                    Found in includes/parser/ParserCache.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return false;
                      Severity: Major
                      Found in includes/parser/ParserCache.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return $metadata;
                        Severity: Major
                        Found in includes/parser/ParserCache.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return false;
                          Severity: Major
                          Found in includes/parser/ParserCache.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return;
                            Severity: Major
                            Found in includes/parser/ParserCache.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return false;
                              Severity: Major
                              Found in includes/parser/ParserCache.php - About 30 mins to fix

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

                                    public function getMetadata(
                                        PageRecord $page,
                                        int $staleConstraint = self::USE_ANYTHING
                                    ): ?ParserCacheMetadata {
                                        $page->assertWiki( PageRecord::LOCAL );
                                Severity: Minor
                                Found in includes/parser/ParserCache.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