wikimedia/mediawiki-extensions-DonationInterface

View on GitHub

Showing 302 of 302 total issues

Avoid too many return statements within this method.
Open

        return $employerList;
Severity: Major
Found in gateway_common/employerSearch.api.php - About 30 mins to fix

    Function setupOptIn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function setupOptIn( $params ) {
            $message = [
                'email' => $params['email'],
            ];
            if ( !empty( $params['variant'] ) ) {
    Severity: Minor
    Found in special/EmailPreferences.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 validateEmail has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function validateEmail( array $params, $posted ) {
            if ( empty( $params['email'] ) ) {
                // When we post back, we need an email
                if ( $posted ) {
                    return false;
    Severity: Minor
    Found in special/EmailPreferences.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 validateToken has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function validateToken( array $params, $posted ) {
            if ( empty( $params['token'] ) ) {
                if ( $posted ) {
                    return false;
                }
    Severity: Minor
    Found in special/EmailPreferences.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 validateToken has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function validateToken( array $params, $posted ) {
            if ( empty( $params['token'] ) ) {
                if ( $posted ) {
                    return false;
                }
    Severity: Minor
    Found in includes/RecurUpgrade/Validator.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 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

    Function addRetryLink has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function addRetryLink( &$data ) {
            $params = [];
            if ( !$this->gateway->session_hasDonorData() ) {
                foreach ( DonationData::getRetryFields() as $field ) {
                    if ( isset( $data[$field] ) ) {
    Severity: Minor
    Found in gateway_forms/MustacheErrorForm.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 determineAction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function determineAction() {
            $risk_score = $this->getRiskScore();
            // possible risk scores are between 0 and 100
            if ( $risk_score < 0 ) {
                $risk_score = 0;
    Severity: Minor
    Found in extras/custom_filters/custom_filters.body.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 getRiskScore has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getRiskScore( $scoreArray = null ) {
            if ( $scoreArray === null ) {
                $scoreArray = $this->risk_score;
            }
    
    
    Severity: Minor
    Found in extras/custom_filters/custom_filters.body.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 addDonorDetailsToSession has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function addDonorDetailsToSession( PaymentDetailResponse $detailResponse ): void {
            $donorDetails = $detailResponse->getDonorDetails();
            if ( $donorDetails !== null ) {
                $responseData = [
                    'first_name' => $donorDetails->getFirstName(),
    Severity: Minor
    Found in paypal_ec_gateway/paypal_express.adapter.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 setClientVariables has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function setClientVariables( &$vars ): void {
            parent::setClientVariables( $vars );
            $vars['dlocalScript'] = $this->adapter->getAccountConfig( 'dlocalScript' );
            $vars['DonationInterfaceThankYouPage'] = ResultPages::getThankYouPage( $this->adapter );
            $supportedSubmethods = array_keys( $this->adapter->getAvailableSubmethods() );
    Severity: Minor
    Found in dlocal_gateway/dlocal_gateway.body.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 getScoreUtmMediumMap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getScoreUtmMediumMap() {
            $score = 0;
    
            $medium = $this->getData_Unstaged_Escaped( 'utm_medium' );
            $mediumMap = $this->getGlobal( 'UtmMediumMap' );
    Severity: Minor
    Found in gateway_common/gateway.adapter.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 getErrorMap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getErrorMap( $code, $options = [] ) {
            $defaults = [
                'translate' => false,
            ];
            $options = array_merge( $defaults, $options );
    Severity: Minor
    Found in gateway_common/gateway.adapter.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 getScoreUtmCampaignMap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getScoreUtmCampaignMap() {
            $score = 0;
    
            $campaign = $this->getData_Unstaged_Escaped( 'utm_campaign' );
            $campaignMap = $this->getGlobal( 'UtmCampaignMap' );
    Severity: Minor
    Found in gateway_common/gateway.adapter.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 renderResponse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function renderResponse( PaymentResult $result ) {
            if ( $result->isFailed() ) {
                $this->logger->info( 'Displaying fail page for failed PaymentResult' );
                $this->displayFailPage();
            } elseif ( $url = $result->getRedirect() ) {
    Severity: Minor
    Found in gateway_common/GatewayPage.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 getPaymentSubmethodMeta has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getPaymentSubmethodMeta( $payment_submethod = null, $payment_method = null ) {
            if ( $payment_submethod === null ) {
                $payment_submethod = $this->getPaymentSubmethod();
            }
    
    
    Severity: Minor
    Found in gateway_common/gateway.adapter.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 getEmployersList has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function getEmployersList() {
            $employersListDataFile = $this->getConfig()->get( 'DonationInterfaceEmployersListDataFileLocation' );
            // Check the employer data file exists
            if ( !file_exists( $employersListDataFile ) ) {
                $this->setError( 'Employer data file doesn\'t exist: ' . $employersListDataFile );
    Severity: Minor
    Found in gateway_common/employerSearch.api.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 getScoreUtmSourceMap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getScoreUtmSourceMap() {
            $score = 0;
    
            $source = $this->getData_Unstaged_Escaped( 'utm_source' );
            $sourceMap = $this->getGlobal( 'UtmSourceMap' );
    Severity: Minor
    Found in gateway_common/gateway.adapter.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 ensureState has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function ensureState() {
            if ( !$this->donationData ) {
                $this->donationData = $this->extractRequestParams();
            }
    
    
    Severity: Minor
    Found in gateway_common/DonationApiBase.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

    Severity
    Category
    Status
    Source
    Language