wikimedia/mediawiki-extensions-DonationInterface

View on GitHub
special/GatewayChooser.php

Summary

Maintainability
D
3 days
Test Coverage

Function chooseGatewayByPriority has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

    public function chooseGatewayByPriority( $supportedGateways, $params ) {
        $rules = $this->getConfig()->get( 'DonationInterfaceGatewayPriorityRules' );

        foreach ( $rules as $rule ) {
            // Do our $params match all the conditions for this rule?
Severity: Minor
Found in special/GatewayChooser.php - About 6 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

Function getSupportedGateways has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    private function getSupportedGateways(
        string $country,
        ?string $currency,
        string $paymentMethod,
        ?string $paymentSubmethod,
Severity: Minor
Found in special/GatewayChooser.php - About 4 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 chooseGatewayByPriority has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function chooseGatewayByPriority( $supportedGateways, $params ) {
        $rules = $this->getConfig()->get( 'DonationInterfaceGatewayPriorityRules' );

        foreach ( $rules as $rule ) {
            // Do our $params match all the conditions for this rule?
Severity: Major
Found in special/GatewayChooser.php - About 2 hrs to fix

    File GatewayChooser.php has 258 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     * GatewayChooser acts as a gateway-agnostic landing page.
     * When passed a country, currency, and payment method combination, it determines the
    Severity: Minor
    Found in special/GatewayChooser.php - About 2 hrs to fix

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

          private function getSupportedGateways(
              string $country,
              ?string $currency,
              string $paymentMethod,
              ?string $paymentSubmethod,
      Severity: Minor
      Found in special/GatewayChooser.php - About 2 hrs to fix

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

            private function getParamsFromURL(): array {
                // Get country code from request param, or, if it's not sent or is invalid, use
                // geoip lookup
                $country = $this->sanitizedValOrNull( 'country' );
        
        
        Severity: Minor
        Found in special/GatewayChooser.php - About 1 hr to fix

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

              private function getParamsFromURL(): array {
                  // Get country code from request param, or, if it's not sent or is invalid, use
                  // geoip lookup
                  $country = $this->sanitizedValOrNull( 'country' );
          
          
          Severity: Minor
          Found in special/GatewayChooser.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 execute has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function execute( $par ) {
                  // Bow out if gateway chooser is not enabled
                  if ( !$this->getConfig()->get( 'DonationInterfaceEnableGatewayChooser' ) ) {
                      throw new BadTitleError();
                  }
          Severity: Minor
          Found in special/GatewayChooser.php - About 1 hr to fix

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

                public function execute( $par ) {
                    // Bow out if gateway chooser is not enabled
                    if ( !$this->getConfig()->get( 'DonationInterfaceEnableGatewayChooser' ) ) {
                        throw new BadTitleError();
                    }
            Severity: Minor
            Found in special/GatewayChooser.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 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

              There are no issues that match your filters.

              Category
              Status