wikimedia/mediawiki-extensions-DonationInterface

View on GitHub

Showing 275 of 275 total issues

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

    public function getTransactionSpecificValue( $gateway_field_name ) {
        if ( !$this->transactions ) {
            $msg = self::getGatewayName() . ': Transactions structure is empty! No transaction can be constructed.';
            $this->logger->critical( $msg );
            throw new LogicException( $msg );
Severity: Minor
Found in gateway_common/gateway.adapter.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 validate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate( GatewayType $adapter, $normalized, &$errors ) {
        global $wgDonationInterfaceForbiddenCountries;
        $hasCountryCode = false;
        $country = '';

Severity: Minor
Found in gateway_common/CountryValidation.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 addArrayElement has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    protected static function addArrayElement( &$targetElement, $structureElement, $key, $value, $callback ) {
        if ( is_numeric( $key ) ) {
            // it's just a value, not an associative array key
            $fieldName = $value;
            $fieldValue = $callback( $fieldName );
Severity: Minor
Found in gateway_common/ArrayHelper.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 getAvailableSubmethods has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAvailableSubmethods() {
        $method = $this->getPaymentMethod();
        $isRecurring = $this->getData_Unstaged_Escaped( 'recurring' );
        $country = $this->getData_Unstaged_Escaped( 'country' );
        $methodSupportsRecurring = $method ? $this->getPaymentMethodMeta( $method )['recurring'] : false;
Severity: Minor
Found in gateway_common/gateway.adapter.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 showMonthlyConvert has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function showMonthlyConvert() {
        $monthlyConvertAmounts = $this->getMonthlyConvertAmounts();
        if ( $monthlyConvertAmounts !== null ) {
            $mcMinimumAmount = $monthlyConvertAmounts[0][0];
            // check if amount is up to monthly convert minimum amount for specified currency
Severity: Minor
Found in gateway_common/gateway.adapter.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

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

        if ( billingContact && billingContact.givenName && billingContact.givenName.length > 1 ) {
            first_name = billingContact.givenName;
            if ( billingContact.familyName && billingContact.familyName.length > 1 ) {
                last_name = billingContact.familyName;
            }
Severity: Minor
Found in adyen_gateway/forms/adyen.js and 1 other location - About 55 mins to fix
adyen_gateway/forms/adyen.js on lines 251..256

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 53.

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

            if ( shippingContact && shippingContact.givenName && shippingContact.givenName.length > 1 ) {
                first_name = shippingContact.givenName;
                if ( shippingContact.familyName && shippingContact.familyName.length > 1 ) {
                    last_name = shippingContact.familyName;
                }
Severity: Minor
Found in adyen_gateway/forms/adyen.js and 1 other location - About 55 mins to fix
adyen_gateway/forms/adyen.js on lines 242..247

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 53.

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

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

    protected function tuneForPaymentMethod() {
        switch ( $this->getPaymentMethod() ) {
            case 'dd':
                $this->transactions['authorize']['request'] =
                    array_merge( $this->transactions['authorize']['request'], [
Severity: Minor
Found in adyen_gateway/adyen_checkout.adapter.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 validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate( GatewayType $adapter, $normalized, &$errors ) {
        // validate() is called at various points in the process. We only want to require these
        // parameters for card payments, and only during the 'donate' action (not during initial
        // form load nor during recurring upgrade). It's a bit odd to find the action in the
        // $normalized array, but there it is!
Severity: Minor
Found in adyen_gateway/EncryptedCardParameters.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 handleOptIn has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function handleOptIn( &$data ) {
        // Since this value can be 1, 0, or unset, we need to make
        // special conditionals for the mustache logic
        if ( !isset( $data['opt_in'] ) || $data['opt_in'] === '' ) {
            return;
Severity: Minor
Found in gateway_forms/Mustache.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 stage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function stage( GatewayType $adapter, $normalized, &$stagedData ) {
        if ( !empty( $normalized['return_url'] ) ) {
            $returnto = $normalized['return_url'];
        } else {
            $returnto = '';
Severity: Minor
Found in ingenico_gateway/IngenicoReturnUrlHelper.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 filter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function filter() {
        $user_ip = $this->gateway_adapter->getData_Unstaged_Escaped( 'user_ip' );

        // Determine IP status before doing anything complex
        $wl = DataValidator::ip_is_listed( $user_ip, $this->gateway_adapter->getGlobal( 'IPAllowList' ) );
Severity: Minor
Found in extras/session_velocity/session_velocity.body.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 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

Method getSupportedGateways has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        string $country,
        ?string $currency,
        string $paymentMethod,
        ?string $paymentSubmethod,
        bool $recurring,
Severity: Minor
Found in special/GatewayChooser.php - About 45 mins to fix

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

        protected function stage_postal_code( $normalized ) {
            $postalCode = '';
            if ( isset( $normalized['postal_code'] ) ) {
                $postalCode = trim( $normalized['postal_code'] );
            }
    Severity: Minor
    Found in gateway_common/StreetAddress.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 luhn_check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function luhn_check( $str ) {
            $odd = ( strlen( $str ) % 2 );
            $sum = 0;
            $len = strlen( $str );
    
    
    Severity: Minor
    Found in gateway_common/DataValidator.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 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

    Method getLoggerFromParams has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public static function getLoggerFromParams( $identifier, $useSyslog, $debug, $suffix, $prefixer ) {
    Severity: Minor
    Found in gateway_common/DonationLoggerFactory.php - About 35 mins to fix

      Function onerror has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          window.onerror = function ( message, file, line, col, error ) {
      Severity: Minor
      Found in modules/js/ext.donationInterface.errorLog.js - About 35 mins to fix

        Method addArrayElement has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            protected static function addArrayElement( &$targetElement, $structureElement, $key, $value, $callback ) {
        Severity: Minor
        Found in gateway_common/ArrayHelper.php - About 35 mins to fix
          Severity
          Category
          Status
          Source
          Language