wikimedia/mediawiki-core

View on GitHub
includes/page/ProtectionForm.php

Summary

Maintainability
F
3 days
Test Coverage

File ProtectionForm.php has 454 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Page protection
 *
 * Copyright © 2005 Brooke Vibber <bvibber@wikimedia.org>
Severity: Minor
Found in includes/page/ProtectionForm.php - About 6 hrs to fix

    Method buildForm has 162 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function buildForm() {
            $this->mOut->enableOOUI();
            $out = '';
            $fields = [];
            if ( !$this->disabled ) {
    Severity: Major
    Found in includes/page/ProtectionForm.php - About 6 hrs to fix

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

          private function buildForm() {
              $this->mOut->enableOOUI();
              $out = '';
              $fields = [];
              if ( !$this->disabled ) {
      Severity: Minor
      Found in includes/page/ProtectionForm.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 save has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function save() {
              # Permission check!
              if ( $this->disabled ) {
                  $this->show();
                  return false;
      Severity: Major
      Found in includes/page/ProtectionForm.php - About 2 hrs to fix

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

            private function save() {
                # Permission check!
                if ( $this->disabled ) {
                    $this->show();
                    return false;
        Severity: Minor
        Found in includes/page/ProtectionForm.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 show has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function show( $err = null ) {
                $out = $this->mOut;
                $out->setRobotPolicy( 'noindex,nofollow' );
                $out->addBacklinkSubtitle( $this->mTitle );
        
        
        Severity: Minor
        Found in includes/page/ProtectionForm.php - About 1 hr to fix

          Method loadData has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function loadData() {
                  $levels = $this->permManager->getNamespaceRestrictionLevels(
                      $this->mTitle->getNamespace(), $this->mPerformer->getUser()
                  );
          
          
          Severity: Minor
          Found in includes/page/ProtectionForm.php - About 1 hr to fix

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

                private function loadData() {
                    $levels = $this->permManager->getNamespaceRestrictionLevels(
                        $this->mTitle->getNamespace(), $this->mPerformer->getUser()
                    );
            
            
            Severity: Minor
            Found in includes/page/ProtectionForm.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 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function __construct( Article $article ) {
                    // Set instance variables.
                    $this->mArticle = $article;
                    $this->mTitle = $article->getTitle();
                    $this->mContext = $article->getContext();
            Severity: Minor
            Found in includes/page/ProtectionForm.php - About 1 hr to fix

              Function getExpiry has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function getExpiry( $action ) {
                      if ( $this->mExpirySelection[$action] == 'existing' ) {
                          return $this->mExistingExpiry[$action];
                      } elseif ( $this->mExpirySelection[$action] == 'othertime' ) {
                          $value = $this->mExpiry[$action];
              Severity: Minor
              Found in includes/page/ProtectionForm.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 show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function show( $err = null ) {
                      $out = $this->mOut;
                      $out->setRobotPolicy( 'noindex,nofollow' );
                      $out->addBacklinkSubtitle( $this->mTitle );
              
              
              Severity: Minor
              Found in includes/page/ProtectionForm.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

              Avoid too many return statements within this method.
              Open

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

                Avoid too many return statements within this method.
                Open

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

                  Avoid too many return statements within this method.
                  Open

                          return true;
                  Severity: Major
                  Found in includes/page/ProtectionForm.php - About 30 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status