Showing 256 of 275 total issues
Method setNormalizedAmount
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function setNormalizedAmount() {
if ( $this->getVal( 'amount' ) === 'Other' ) {
$this->setVal( 'amount', $this->getVal( 'amountGiven' ) );
}
Method cc_number_exists_in_str
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function cc_number_exists_in_str( string $str ): bool {
$luhnRegex = <<<EOT
/
(?#amex)(3[47][0-9]{13})|
(?#bankcard)(5610[0-9]{12})|(56022[1-5][0-9]{10})|
Function stage
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function stage( GatewayType $adapter, $normalized, &$staged_data ) {
if ( isset( $normalized['language'] ) && isset( $normalized['country'] ) ) {
$language = $normalized['language'];
// Get the first part, before any _ or - separator.
foreach ( [ '_', '-' ] as $separator ) {
- 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
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' => [],
- 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
Function validate
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function validate( GatewayType $adapter, $normalized, &$errors ) {
if (
!isset( $normalized['amount'] ) ||
!isset( $normalized['currency'] )
) {
- 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
Function validateAmount
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
window.validateAmount = function () {
var error = true,
amount = $( 'input[name="amount"]' ).val(), // get the amount
currency = '',
rates = mw.config.get( 'wgDonationInterfaceCurrencyRates' ),
- 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
Function setClientVariables
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function setClientVariables( &$vars ) {
$language = $this->adapter->getData_Unstaged_Escaped( 'language' );
$country = $this->adapter->getData_Unstaged_Escaped( 'country' );
$vars['wgDonationInterfaceAmountRules'] = $this->adapter->getDonationRules();
$vars['wgDonationInterfaceLogDebug'] = $this->adapter->getGlobal( 'LogDebug' );
- 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
Function validateDataConstraintsMet
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function validateDataConstraintsMet( $field, $value ) {
$met = true;
if ( is_array( $this->dataConstraints ) && array_key_exists( $field, $this->dataConstraints ) ) {
$type = $this->dataConstraints[$field]['type'];
- 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
Function setUtmSource
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function setUtmSource() {
$utm_source = $this->getVal( 'utm_source' );
$utm_source_id = $this->getVal( 'utm_source_id' );
if ( $this->getVal( 'payment_method' ) ) {
- 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 getErrors
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getErrors() {
$errors = $this->gateway->getErrorState()->getErrors();
$return = [ 'errors' => [
'general' => [],
'field' => [],
Method defineTransactions
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function defineTransactions() {
$this->transactions['createPaymentSession'] = [
'request' => [
'use_3d_secure',
'amount',
Method sendToDonations
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function sendToDonations() {
$message = [
'contribution_tracking_id' => $this->contributionTrackingId,
'date' => UtcDate::getUtcTimestamp(),
'gateway' => $this->gateway,
Method getAllowedParams
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAllowedParams() {
return [
'gateway' => $this->defineParam( true ),
'contact_id' => $this->defineParam( false ),
'contact_hash' => $this->defineParam( false ),
Function postMonthlyConvertDonate
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
mc.postMonthlyConvertDonate = function ( amount, declineMonthlyConvert ) {
var sendData = {
action: 'di_recurring_convert',
format: 'json',
gateway: $( '#gateway' ).val(),
Method validate
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validate( GatewayType $unused, $normalized, &$errors ) {
if (
!isset( $normalized['country'] ) ||
!isset( $normalized[self::$key] )
) {
Method setClientVariables
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setClientVariables( &$vars ) {
$language = $this->adapter->getData_Unstaged_Escaped( 'language' );
$country = $this->adapter->getData_Unstaged_Escaped( 'country' );
$vars['wgDonationInterfaceAmountRules'] = $this->adapter->getDonationRules();
$vars['wgDonationInterfaceLogDebug'] = $this->adapter->getGlobal( 'LogDebug' );
Method setCountry
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function setCountry() {
$regen = true;
$country = '';
if ( $this->isSomething( 'country' ) ) {
Function execute
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
if ( RequestContext::getMain()->getUser()->pingLimiter( 'submitpayment' ) ) {
// Allow rate limiting by setting e.g. $wgRateLimits['submitpayment']['ip']
return;
}
- 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
Function sift3Distance
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
sift3Distance: function(s1, s2) {
// sift3: http://siderite.blogspot.com/2007/04/super-fast-and-accurate-string-distance.html
if (s1 == null || s1.length === 0) {
if (s2 == null || s2.length === 0) {
return 0;
Method defineTransactions
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function defineTransactions() {
$this->transactions = [
TransactionType::AUTHORIZE => [
'request' => [
'amount',