wikimedia/mediawiki-extensions-DonationInterface

View on GitHub
gateway_common/DonationData.php

Summary

Maintainability
F
4 days
Test Coverage

File DonationData.php has 723 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
use SmashPig\Core\DataStores\QueueWrapper;
use SmashPig\Core\SequenceGenerators;
use SmashPig\PaymentData\ReferenceData\CurrencyRates;
use SmashPig\PaymentData\ReferenceData\NationalCurrencies;
Severity: Major
Found in gateway_common/DonationData.php - About 1 day to fix

    DonationData has 44 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DonationData implements LogPrefixProvider {
        /** @var array */
        protected $normalized = [];
        /** @var array */
        protected $dataSources = [];
    Severity: Minor
    Found in gateway_common/DonationData.php - About 6 hrs to fix

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

          protected function setCountry() {
              $regen = true;
              $country = '';
      
              if ( $this->isSomething( 'country' ) ) {
      Severity: Minor
      Found in gateway_common/DonationData.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 getCleanTrackingData has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getCleanTrackingData( $unset = false ) {
              // define valid tracking fields
              $tracking_fields = [
                  'amount',
                  'appeal',
      Severity: Major
      Found in gateway_common/DonationData.php - About 2 hrs to fix

        Method getMessageFields has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function getMessageFields() {
                return [
                    'contribution_tracking_id',
                    'anonymous',
                    'utm_source',
        Severity: Minor
        Found in gateway_common/DonationData.php - About 1 hr to fix

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

              public function getCleanTrackingData( $unset = false ) {
                  // define valid tracking fields
                  $tracking_fields = [
                      'amount',
                      'appeal',
          Severity: Minor
          Found in gateway_common/DonationData.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 setUtmSource has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function setUtmSource() {
                  $utm_source = $this->getVal( 'utm_source' );
                  $utm_source_id = $this->getVal( 'utm_source_id' );
          
                  if ( $this->getVal( 'payment_method' ) ) {
          Severity: Minor
          Found in gateway_common/DonationData.php - About 1 hr to fix

            Method setNormalizedAmount has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function setNormalizedAmount() {
                    if ( $this->getVal( 'amount' ) === 'Other' ) {
                        $this->setVal( 'amount', $this->getVal( 'amountGiven' ) );
                    }
            
            
            Severity: Minor
            Found in gateway_common/DonationData.php - About 1 hr to fix

              Function setUtmSource has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function setUtmSource() {
                      $utm_source = $this->getVal( 'utm_source' );
                      $utm_source_id = $this->getVal( 'utm_source_id' );
              
                      if ( $this->getVal( 'payment_method' ) ) {
              Severity: Minor
              Found in gateway_common/DonationData.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 setCountry has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function setCountry() {
                      $regen = true;
                      $country = '';
              
                      if ( $this->isSomething( 'country' ) ) {
              Severity: Minor
              Found in gateway_common/DonationData.php - About 1 hr to fix

                Method normalize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function normalize() {
                        // FIXME: there's a ghost invocation during DonationData construction.
                        // This condition should actually be "did data come from anywhere?"
                        if ( $this->normalized ) {
                            // Cast all values to string.
                Severity: Minor
                Found in gateway_common/DonationData.php - About 1 hr to fix

                  Function setNormalizedAmount has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function setNormalizedAmount() {
                          if ( $this->getVal( 'amount' ) === 'Other' ) {
                              $this->setVal( 'amount', $this->getVal( 'amountGiven' ) );
                          }
                  
                  
                  Severity: Minor
                  Found in gateway_common/DonationData.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 integrateDataFromSession has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function integrateDataFromSession() {
                          /**
                           * if the thing coming in from the session isn't already something,
                           * replace it.
                           * if it is: assume that the session data was meant to be replaced
                  Severity: Minor
                  Found in gateway_common/DonationData.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 populateData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function populateData( $external_data = false ) {
                          $this->normalized = [];
                          if ( is_array( $external_data ) ) {
                              // I don't care if you're a test or not. At all.
                              $this->normalized = $external_data;
                  Severity: Minor
                  Found in gateway_common/DonationData.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 setNormalizedRecurring has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function setNormalizedRecurring() {
                          if ( $this->isSomething( 'recurring_paypal' ) && ( $this->getVal( 'recurring_paypal' ) === '1' || $this->getVal( 'recurring_paypal' ) === 'true' ) ) {
                              $this->setVal( 'recurring', true );
                              $this->expunge( 'recurring_paypal' );
                          }
                  Severity: Minor
                  Found in gateway_common/DonationData.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 addData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function addData( $newdata, $source = 'internal' ) {
                          if ( is_array( $newdata ) ) {
                              foreach ( $newdata as $key => $val ) {
                                  if ( !is_array( $val ) ) {
                                      $this->setVal( $key, $val );
                  Severity: Minor
                  Found in gateway_common/DonationData.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 normalize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function normalize() {
                          // FIXME: there's a ghost invocation during DonationData construction.
                          // This condition should actually be "did data come from anywhere?"
                          if ( $this->normalized ) {
                              // Cast all values to string.
                  Severity: Minor
                  Found in gateway_common/DonationData.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 setReferrer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function setReferrer() {
                          if ( !$this->isSomething( 'referrer' ) ) {
                              // Remove protocol and query strings to avoid tripping modsecurity
                              // TODO it would be a lot more privacy respecting to omit path too.
                              $referrer = '';
                  Severity: Minor
                  Found in gateway_common/DonationData.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