wikimedia/mediawiki-core

View on GitHub
includes/logging/DeleteLogFormatter.php

Summary

Maintainability
D
2 days
Test Coverage

Function getMessageParameters has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getMessageParameters() {
        if ( $this->parsedParametersDeleteLog !== null ) {
            return $this->parsedParametersDeleteLog;
        }

Severity: Minor
Found in includes/logging/DeleteLogFormatter.php - About 3 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 getActionLinks has 91 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getActionLinks() {
        $linkRenderer = $this->getLinkRenderer();
        if ( !$this->context->getAuthority()->isAllowed( 'deletedhistory' )
            || $this->entry->isDeleted( LogPage::DELETED_ACTION )
        ) {
Severity: Major
Found in includes/logging/DeleteLogFormatter.php - About 3 hrs to fix

    Function getParametersForApi has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function getParametersForApi() {
            $entry = $this->entry;
            $params = [];
    
            $subtype = $this->entry->getSubtype();
    Severity: Minor
    Found in includes/logging/DeleteLogFormatter.php - About 3 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 getParametersForApi has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function getParametersForApi() {
            $entry = $this->entry;
            $params = [];
    
            $subtype = $this->entry->getSubtype();
    Severity: Major
    Found in includes/logging/DeleteLogFormatter.php - About 2 hrs to fix

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

          protected function getMessageParameters() {
              if ( $this->parsedParametersDeleteLog !== null ) {
                  return $this->parsedParametersDeleteLog;
              }
      
      
      Severity: Major
      Found in includes/logging/DeleteLogFormatter.php - About 2 hrs to fix

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

            public function getActionLinks() {
                $linkRenderer = $this->getLinkRenderer();
                if ( !$this->context->getAuthority()->isAllowed( 'deletedhistory' )
                    || $this->entry->isDeleted( LogPage::DELETED_ACTION )
                ) {
        Severity: Minor
        Found in includes/logging/DeleteLogFormatter.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

        Consider simplifying this complex logical expression.
        Open

                    if (
                        ( $subtype === 'event' && count( $params ) === 6 )
                        || (
                            $subtype === 'revision' && isset( $params[3] ) && count( $params ) === 7
                            && in_array( $params[3], [ 'revision', 'archive', 'oldimage', 'filearchive' ] )
        Severity: Major
        Found in includes/logging/DeleteLogFormatter.php - About 40 mins to fix

          Avoid too many return statements within this method.
          Open

                          return '';
          Severity: Major
          Found in includes/logging/DeleteLogFormatter.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
            Severity: Major
            Found in includes/logging/DeleteLogFormatter.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                  return '';
              Severity: Major
              Found in includes/logging/DeleteLogFormatter.php - About 30 mins to fix

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

                    protected function getMessageKey() {
                        $key = parent::getMessageKey();
                        if ( in_array( $this->entry->getSubtype(), [ 'event', 'revision' ] ) ) {
                            if ( count( $this->getMessageParameters() ) < 5 ) {
                                // Messages: logentry-delete-event-legacy, logentry-delete-revision-legacy,
                Severity: Minor
                Found in includes/logging/DeleteLogFormatter.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