wikimedia/mediawiki-core

View on GitHub
includes/actions/HistoryAction.php

Summary

Maintainability
D
1 day
Test Coverage

Method onView has 148 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function onView() {
        $out = $this->getOutput();
        $request = $this->getRequest();
        $config = $this->context->getConfig();
        $services = MediaWikiServices::getInstance();
Severity: Major
Found in includes/actions/HistoryAction.php - About 5 hrs to fix

    File HistoryAction.php has 334 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Page history
     *
     * This program is free software; you can redistribute it and/or modify
    Severity: Minor
    Found in includes/actions/HistoryAction.php - About 4 hrs to fix

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

          public function onView() {
              $out = $this->getOutput();
              $request = $this->getRequest();
              $config = $this->context->getConfig();
              $services = MediaWikiServices::getInstance();
      Severity: Minor
      Found in includes/actions/HistoryAction.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 feedItem has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function feedItem( $row, $formattedComment ) {
              $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
              $rev = $revisionStore->newRevisionFromRow( $row, 0, $this->getTitle() );
              $prevRev = $revisionStore->getPreviousRevision( $rev );
              $revComment = $rev->getComment() === null ? null : $rev->getComment()->text;
      Severity: Minor
      Found in includes/actions/HistoryAction.php - About 1 hr to fix

        Function getTimestampFromRequest has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            private function getTimestampFromRequest( WebRequest $request ) {
                // Backwards compatibility checks for URIs with only year and/or month.
                $year = $request->getInt( 'year' );
                $month = $request->getInt( 'month' );
                $day = null;
        Severity: Minor
        Found in includes/actions/HistoryAction.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 feed has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function feed( $type ) {
                if ( !FeedUtils::checkFeedOutput( $type, $this->getOutput() ) ) {
                    return;
                }
                $request = $this->getRequest();
        Severity: Minor
        Found in includes/actions/HistoryAction.php - About 1 hr to fix

          There are no issues that match your filters.

          Category
          Status