wikimedia/mediawiki-extensions-DonationInterface

View on GitHub
gateway_forms/Mustache.php

Summary

Maintainability
D
3 days
Test Coverage

File Mustache.php has 435 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use LightnCandy\LightnCandy;
use MediaWiki\MediaWikiServices;
use SmashPig\Core\PaymentError;
Severity: Minor
Found in gateway_forms/Mustache.php - About 6 hrs to fix

    Function addFormFields has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function addFormFields( &$data ) {
            // If any of these are required, show the address block
            $address_fields = [
                'city',
                'state_province',
    Severity: Minor
    Found in gateway_forms/Mustache.php - About 3 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 addSubmethods has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function addSubmethods( &$data ) {
            if ( !$this->gatewayPage->showSubmethodButtons() ) {
                $data['show_submethods'] = false;
                return;
            }
    Severity: Minor
    Found in gateway_forms/Mustache.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 addFormFields has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function addFormFields( &$data ) {
            // If any of these are required, show the address block
            $address_fields = [
                'city',
                'state_province',
    Severity: Major
    Found in gateway_forms/Mustache.php - About 2 hrs to fix

      Method addSubmethods has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function addSubmethods( &$data ) {
              if ( !$this->gatewayPage->showSubmethodButtons() ) {
                  $data['show_submethods'] = false;
                  return;
              }
      Severity: Major
      Found in gateway_forms/Mustache.php - About 2 hrs 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

        Method getErrors has 39 lines of code (exceeds 25 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

          Method getData has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function getData() {
                  $data = $this->gateway->getData_Unstaged_Escaped();
                  $output = $this->gatewayPage->getContext()->getOutput();
          
                  $data['script_path'] = $this->scriptPath;
          Severity: Minor
          Found in gateway_forms/Mustache.php - About 1 hr to fix

            Method handleOptIn has 26 lines of code (exceeds 25 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 1 hr to fix

              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 getPartials has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function getPartials( array $data ) {
                      $partials = [];
                      if ( empty( $data['variant'] ) ) {
                          $variantDir = false;
                      } else {
              Severity: Minor
              Found in gateway_forms/Mustache.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 setAmountLabelKey has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function setAmountLabelKey( &$data ): void {
                      if ( $data['recurring'] ) {
                          $isAnnual = ( isset( $data['frequency_unit'] ) && $data['frequency_unit'] == 'year' );
                          if ( $isAnnual ) {
                              $key = 'donate_interface-annual-amount';
              Severity: Minor
              Found in gateway_forms/Mustache.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