wikimedia/mediawiki-core

View on GitHub
includes/page/ParserOutputAccess.php

Summary

Maintainability
D
3 days
Test Coverage

File ParserOutputAccess.php has 409 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: Minor
Found in includes/page/ParserOutputAccess.php - About 5 hrs to fix

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

        public function getParserOutput(
            PageRecord $page,
            ParserOptions $parserOptions,
            ?RevisionRecord $revision = null,
            int $options = 0
    Severity: Major
    Found in includes/page/ParserOutputAccess.php - About 2 hrs to fix

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

          public function getParserOutput(
              PageRecord $page,
              ParserOptions $parserOptions,
              ?RevisionRecord $revision = null,
              int $options = 0
      Severity: Minor
      Found in includes/page/ParserOutputAccess.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 newPoolWorkArticleView has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function newPoolWorkArticleView(
              PageRecord $page,
              ParserOptions $parserOptions,
              RevisionRecord $revision,
              int $options
      Severity: Major
      Found in includes/page/ParserOutputAccess.php - About 2 hrs to fix

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

            private function renderRevision(
                PageRecord $page,
                ParserOptions $parserOptions,
                RevisionRecord $revision,
                int $options,
        Severity: Major
        Found in includes/page/ParserOutputAccess.php - About 2 hrs to fix

          Method getCachedParserOutput has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getCachedParserOutput(
                  PageRecord $page,
                  ParserOptions $parserOptions,
                  ?RevisionRecord $revision = null,
                  int $options = 0
          Severity: Major
          Found in includes/page/ParserOutputAccess.php - About 2 hrs to fix

            Function renderRevision has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                private function renderRevision(
                    PageRecord $page,
                    ParserOptions $parserOptions,
                    RevisionRecord $revision,
                    int $options,
            Severity: Minor
            Found in includes/page/ParserOutputAccess.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

            Function getCachedParserOutput has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getCachedParserOutput(
                    PageRecord $page,
                    ParserOptions $parserOptions,
                    ?RevisionRecord $revision = null,
                    int $options = 0
            Severity: Minor
            Found in includes/page/ParserOutputAccess.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 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    ParserCacheFactory $parserCacheFactory,
                    RevisionLookup $revisionLookup,
                    RevisionRenderer $revisionRenderer,
                    StatsFactory $statsFactory,
                    ILBFactory $lbFactory,
            Severity: Major
            Found in includes/page/ParserOutputAccess.php - About 1 hr to fix

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

                      PageRecord $page,
                      ParserOptions $parserOptions,
                      RevisionRecord $revision,
                      int $options,
                      ?ParserOutput $previousOutput = null
              Severity: Minor
              Found in includes/page/ParserOutputAccess.php - About 35 mins to fix

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

                    private function shouldUseCache(
                        PageRecord $page,
                        ?RevisionRecord $rev
                    ) {
                        if ( $rev && !$rev->getId() ) {
                Severity: Minor
                Found in includes/page/ParserOutputAccess.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 checkPreconditions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function checkPreconditions(
                        PageRecord $page,
                        ?RevisionRecord $revision = null,
                        int $options = 0
                    ): ?Status {
                Severity: Minor
                Found in includes/page/ParserOutputAccess.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

                Avoid too many return statements within this method.
                Open

                        return self::CACHE_SECONDARY;
                Severity: Major
                Found in includes/page/ParserOutputAccess.php - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status