Showing 275 of 311 total issues
Function setLocaleAndTranslations
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function setLocaleAndTranslations( config, localeFromServer ) {
// Adyen supports the locales listed below, according to
// https://docs.adyen.com/online-payments/classic-integrations/checkout-sdks/web-sdk/customization/localization/
var adyenSupportedLocale = [
'zh-CN', 'zh-TW', 'hr-HR', 'cs-CZ',
Method filter
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
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' ) );
Method chooseGatewayByPriority
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
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?
Method getQueueDonationMessage
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function getQueueDonationMessage(): array {
$gatewayTxnId = $this->getData_Unstaged_Escaped( 'gateway_txn_id' );
if ( $gatewayTxnId === null ) {
$gatewayTxnId = false;
}
File GatewayChooser.php
has 258 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
/**
* GatewayChooser acts as a gateway-agnostic landing page.
* When passed a country, currency, and payment method combination, it determines the
Method tuneForPaymentMethod
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function tuneForPaymentMethod() {
switch ( $this->getPaymentMethod() ) {
case 'dd':
$this->transactions['authorize']['request'] =
array_merge( $this->transactions['authorize']['request'], [
Method fallbackToDefaultCurrency
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function fallbackToDefaultCurrency() {
$defaultCurrency = null;
if ( $this->getGlobal( 'FallbackCurrencyByCountry' ) ) {
$country = $this->dataObj->getVal( 'country' );
if ( $country !== null ) {
Method doRecurringConversion
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function doRecurringConversion(): PaymentResult {
$sessionData = $this->session_getData( 'Donor' );
if (
empty( $sessionData['recurring_payment_token'] ) ||
empty( $sessionData['gateway_txn_id'] )
Method getTemplateParams
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function getTemplateParams() {
global $wgDonationInterfaceEmailFormHelpEmail, $wgDonationInterfaceRecurringDonateURL;
$paramList = [
'campaign',
Method addFormFields
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function addFormFields( &$data ) {
// If any of these are required, show the address block
$address_fields = [
'city',
'state_province',
Function getLocalizedValidationErrorResult
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function getLocalizedValidationErrorResult( array $validationErrors ): PaymentResult {
$localizedErrors = [];
foreach ( $validationErrors as $error ) {
$field = $error->getField();
$debugMessage = $error->getDebugMessage();
- Read upRead up
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 addSubmethods
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function addSubmethods( &$data ) {
if ( !$this->gatewayPage->showSubmethodButtons() ) {
$data['show_submethods'] = false;
return;
}
Method getCleanTrackingData
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function getCleanTrackingData( $unset = false ) {
// define valid tracking fields
$tracking_fields = [
'amount',
'appeal',
Method displayResultsForDebug
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function displayResultsForDebug( ?PaymentTransactionResponse $results = null ) {
$results = !$results ? $this->adapter->getTransactionResponse() : $results;
if ( $this->adapter->getGlobal( 'DisplayDebug' ) !== true ) {
return;
File adyen_submit_payment.api.php
has 251 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
use SmashPig\Core\DataStores\QueueWrapper;
use SmashPig\Core\SequenceGenerators;
use SmashPig\Core\UtcDate;
use SmashPig\PaymentData\FinalStatus;
Method execute
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function execute( $subpage ) {
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
Method getSupportedGateways
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function getSupportedGateways(
string $country,
?string $currency,
string $paymentMethod,
?string $paymentSubmethod,
Method getLocalizedValidationErrorResult
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function getLocalizedValidationErrorResult( array $validationErrors ): PaymentResult {
$localizedErrors = [];
foreach ( $validationErrors as $error ) {
$field = $error->getField();
$debugMessage = $error->getDebugMessage();
Method getLocalizedValidationErrorResult
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function getLocalizedValidationErrorResult( array $validationErrors ): PaymentResult {
$localizedErrors = [];
foreach ( $validationErrors as $error ) {
$field = $error->getField();
$debugMessage = $error->getDebugMessage();
Function validateAmount
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
window.validateAmount = function () {
var error = true,
amount = $( 'input[name="amount"]' ).val(), // get the amount
currency = '',
rates = mw.config.get( 'wgDonationInterfaceCurrencyRates' ),