wikimedia/mediawiki-core

View on GitHub
includes/logging/ProtectLogFormatter.php

Summary

Maintainability
B
5 hrs
Test Coverage

Method getActionLinks has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getActionLinks() {
        $linkRenderer = $this->getLinkRenderer();
        $subtype = $this->entry->getSubtype();
        if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden
            || $subtype === 'move_prot' // the move log entry has the right action link
Severity: Minor
Found in includes/logging/ProtectLogFormatter.php - About 1 hr to fix

    Method getParametersForApi has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function getParametersForApi() {
            $entry = $this->entry;
            $subtype = $this->entry->getSubtype();
            $params = $entry->getParameters();
    
    
    Severity: Minor
    Found in includes/logging/ProtectLogFormatter.php - About 1 hr to fix

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

          protected function getMessageParameters() {
              $params = parent::getMessageParameters();
      
              $subtype = $this->entry->getSubtype();
              if ( $subtype === 'protect' || $subtype === 'modify' ) {
      Severity: Minor
      Found in includes/logging/ProtectLogFormatter.php - About 55 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 getParametersForApi has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getParametersForApi() {
              $entry = $this->entry;
              $subtype = $this->entry->getSubtype();
              $params = $entry->getParameters();
      
      
      Severity: Minor
      Found in includes/logging/ProtectLogFormatter.php - About 45 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 formatParametersForApi has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function formatParametersForApi() {
              $ret = parent::formatParametersForApi();
              if ( isset( $ret['details'] ) && is_array( $ret['details'] ) ) {
                  $contLang = $this->getContentLanguage();
                  foreach ( $ret['details'] as &$detail ) {
      Severity: Minor
      Found in includes/logging/ProtectLogFormatter.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 getActionLinks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getActionLinks() {
              $linkRenderer = $this->getLinkRenderer();
              $subtype = $this->entry->getSubtype();
              if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden
                  || $subtype === 'move_prot' // the move log entry has the right action link
      Severity: Minor
      Found in includes/logging/ProtectLogFormatter.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

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

          public function createProtectDescription( array $details ) {
              $protectDescription = '';
      
              foreach ( $details as $param ) {
                  $expiryText = $this->formatExpiry( $param['expiry'] );
      Severity: Minor
      Found in includes/logging/ProtectLogFormatter.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