wikimedia/mediawiki-extensions-DonationInterface

View on GitHub

Showing 275 of 275 total issues

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

    protected function filter( $filterListGlobal ) {
        $functions = $this->gateway_adapter->getGlobal( $filterListGlobal );

        if (
            !$this->gateway_adapter->getGlobal( 'EnableFunctionsFilter' ) ||
Severity: Minor
Found in extras/custom_filters/filters/functions/functions.body.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 processDonorReturn has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function processDonorReturn( $requestValues ) {
        if (
            empty( $requestValues['token'] )
        ) {
            throw new ResponseProcessingException(
Severity: Minor
Found in paypal_ec_gateway/paypal_express.adapter.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 fallbackToDefaultCurrency has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    protected function fallbackToDefaultCurrency() {
        $defaultCurrency = null;
        if ( $this->getGlobal( 'FallbackCurrencyByCountry' ) ) {
            $country = $this->dataObj->getVal( 'country' );
            if ( $country !== null ) {
Severity: Minor
Found in gateway_common/gateway.adapter.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 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 handleCreatedPayment has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function handleCreatedPayment(
        PaymentDetailResponse $paymentDetailResponse,
        IPaymentProvider $paymentProvider
    ): PaymentResult {
        // Log details of the payment in case we need to reconstruct it for
Severity: Minor
Found in dlocal_gateway/dlocal.adapter.php - About 1 hr to fix

    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 getMessageFields has 43 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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            protected function confirmOrderReference() {
                $orderReferenceId = $this->getData_Staged( 'order_reference_id' );
        
                $this->setOrderReferenceDetailsIfUnset( $orderReferenceId );
        
        
        Severity: Major
        Found in amazon_gateway/amazon.adapter.php and 1 other location - About 1 hr to fix
        amazon_gateway/amazon.adapter.php on lines 323..340

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 115.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            protected function confirmBillingAgreement() {
                $billingAgreementId = $this->getData_Staged( 'subscr_id' );
                $this->setBillingAgreementDetailsIfUnset( $billingAgreementId );
        
                $this->logger->info( "Confirming billing agreement $billingAgreementId" );
        Severity: Major
        Found in amazon_gateway/amazon.adapter.php and 1 other location - About 1 hr to fix
        amazon_gateway/amazon.adapter.php on lines 259..279

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 115.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method getEmailPreferences has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function getEmailPreferences( $checksum, $contact_id ) {
                global $wgDonationInterfaceCiviproxyURLBase;
        
                $client = new GuzzleHttp\Client();
                $logger = DonationLoggerFactory::getLoggerFromParams(
        Severity: Minor
        Found in extras/civiproxy/CiviproxyConnect.php - About 1 hr to fix

          Method paramsForRecurUpgradeForm has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function paramsForRecurUpgradeForm( $checksum, $contactID, $country ): ?array {
                  $recurData = CiviproxyConnect::getRecurDetails( $checksum, $contactID );
                  if ( $recurData[ 'is_error' ] ) {
                      $logger = self::getLogger();
          
          
          Severity: Minor
          Found in special/RecurUpgrade.php - About 1 hr to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            ( function ( $ ) {
                $( function () {
                    var $employerRow = $( '#employer' ).closest( 'div' ),
                        message = 'We\'ll let you know if your employer will match your gift';
            
            
            Severity: Major
            Found in modules/js/ext.donationInterface.employerExplain.js and 1 other location - About 1 hr to fix
            modules/js/ext.donationInterface.employerExplainAlt.js on lines 1..8

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 68.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            ( function ( $ ) {
                $( function () {
                    var $employerRow = $( '#employer' ).closest( 'div' ),
                        message = 'Your employer might match your gift, doubling the impact you can have. If your employer is on our list of partners, we\'ll follow up with you.';
            
            
            Severity: Major
            Found in modules/js/ext.donationInterface.employerExplainAlt.js and 1 other location - About 1 hr to fix
            modules/js/ext.donationInterface.employerExplain.js on lines 1..8

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 68.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method defineTransactions has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function defineTransactions() {
                    $this->transactions = [
                        'authorize' => [
                            'request' => [
                                'amount',
            Severity: Minor
            Found in dlocal_gateway/dlocal.adapter.php - About 1 hr to fix

              Method doPayment has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function doPayment() {
                      $this->ensureUniqueOrderID();
                      $this->session_addDonorData();
                      $this->setCurrentTransaction( 'authorize' );
                      Gateway_Extras_CustomFilters::onGatewayReady( $this );
              Severity: Minor
              Found in adyen_gateway/adyen_checkout.adapter.php - About 1 hr to fix

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

                    public static function cc_number_exists_in_str( string $str ): bool {
                        $luhnRegex = <<<EOT
                /
                (?#amex)(3[47][0-9]{13})|
                (?#bankcard)(5610[0-9]{12})|(56022[1-5][0-9]{10})|
                Severity: Minor
                Found in gateway_common/DataValidator.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 getErrors has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function getErrors() {
                            $errors = $this->gateway->getErrorState()->getErrors();
                            $return = [ 'errors' => [
                                'general' => [],
                                'field' => [],
                    Severity: Minor
                    Found in gateway_forms/Mustache.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 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function validate( GatewayType $adapter, $normalized, &$errors ) {
                            if (
                                !isset( $normalized['amount'] ) ||
                                !isset( $normalized['currency'] )
                            ) {
                    Severity: Minor
                    Found in gateway_common/Amount.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 validateAmount has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    window.validateAmount = function () {
                        var error = true,
                            amount = $( 'input[name="amount"]' ).val(), // get the amount
                            currency = '',
                            rates = mw.config.get( 'wgDonationInterfaceCurrencyRates' ),
                    Severity: Minor
                    Found in modules/validate_input.js - 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

                    Severity
                    Category
                    Status
                    Source
                    Language