wikimedia/mediawiki-extensions-DonationInterface

View on GitHub

Showing 256 of 275 total issues

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

    protected function setReferrer() {
        if ( !$this->isSomething( 'referrer' ) ) {
            // Remove protocol and query strings to avoid tripping modsecurity
            // TODO it would be a lot more privacy respecting to omit path too.
            $referrer = '';
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 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

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

    public function addData( $newdata, $source = 'internal' ) {
        if ( is_array( $newdata ) ) {
            foreach ( $newdata as $key => $val ) {
                if ( !is_array( $val ) ) {
                    $this->setVal( $key, $val );
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 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 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 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 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

Severity
Category
Status
Source
Language