wikimedia/mediawiki-extensions-DonationInterface

View on GitHub
special/EmailPreferences.php

Summary

Maintainability
D
1 day
Test Coverage

File EmailPreferences.php has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use MediaWiki\Extension\CLDR\CountryNames;
use MediaWiki\Extension\CLDR\LanguageNames;
use SmashPig\Core\DataStores\QueueWrapper;
Severity: Minor
Found in special/EmailPreferences.php - About 3 hrs to fix

    Method paramsForPreferencesForm has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function paramsForPreferencesForm( $checksum, $contact_id ) {
            $preferences = CiviproxyConnect::getEmailPreferences( $checksum, $contact_id );
    
            if ( $preferences[ 'is_error' ] ) {
                $logger = DonationLoggerFactory::getLoggerFromParams(
    Severity: Major
    Found in special/EmailPreferences.php - About 2 hrs to fix

      Method execute has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function execute( $subpage ) {
              $this->setHeaders();
              $this->outputHeader();
              $out = $this->getOutput();
      
      
      Severity: Minor
      Found in special/EmailPreferences.php - About 2 hrs to fix

        Method setupQueueParams has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function setupQueueParams( $params, $queueName ) {
                switch ( $queueName ) {
                    case 'email-preferences':
                        $message = [
                            'checksum' => $params['checksum'],
        Severity: Minor
        Found in special/EmailPreferences.php - About 1 hr to fix

          Function execute has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              public function execute( $subpage ) {
                  $this->setHeaders();
                  $this->outputHeader();
                  $out = $this->getOutput();
          
          
          Severity: Minor
          Found in special/EmailPreferences.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 setupQueueParams has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function setupQueueParams( $params, $queueName ) {
                  switch ( $queueName ) {
                      case 'email-preferences':
                          $message = [
                              'checksum' => $params['checksum'],
          Severity: Minor
          Found in special/EmailPreferences.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 paramsForPreferencesForm has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function paramsForPreferencesForm( $checksum, $contact_id ) {
                  $preferences = CiviproxyConnect::getEmailPreferences( $checksum, $contact_id );
          
                  if ( $preferences[ 'is_error' ] ) {
                      $logger = DonationLoggerFactory::getLoggerFromParams(
          Severity: Minor
          Found in special/EmailPreferences.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 validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function validate( array $params, $posted ) {
                  if ( !$this->validateEmail( $params, $posted ) ) {
                      return false;
                  }
                  if ( !$this->validateToken( $params, $posted ) ) {
          Severity: Minor
          Found in special/EmailPreferences.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 validateEmail has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function validateEmail( array $params, $posted ) {
                  if ( empty( $params['email'] ) ) {
                      // When we post back, we need an email
                      if ( $posted ) {
                          return false;
          Severity: Minor
          Found in special/EmailPreferences.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 validateToken has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function validateToken( array $params, $posted ) {
                  if ( empty( $params['token'] ) ) {
                      if ( $posted ) {
                          return false;
                      }
          Severity: Minor
          Found in special/EmailPreferences.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