File gateway.adapter.php
has 1616 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Wikimedia Foundation
*
GatewayAdapter
has 133 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class GatewayAdapter implements GatewayType {
/**
* Don't change these strings without fixing cross-repo usages.
*/
const REDIRECT_PREFACE = 'Redirecting for transaction: ';
Function buildOrderIDSources
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
public function buildOrderIDSources() {
static $built = false;
if ( $built && isset( $this->order_id_candidates ) ) { // once per request is plenty
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 getFormFields
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function getFormFields( ?array $knownData = null ): array {
if ( $knownData === null ) {
$knownData = $this->getData_Unstaged_Escaped();
}
$fields = [];
- 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 session_resetOnSwitch
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
protected function session_resetOnSwitch() {
$oldData = $this->session_getData( 'Donor' );
if ( !is_array( $oldData ) ) {
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 getDonationRules
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function getDonationRules(): array {
$rules = $this->config['donation_rules'];
foreach ( $rules as $rule ) {
// Do our $params match all the conditions for this rule?
$ruleMatches = true;
- 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 calculateKeyMashScore
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function calculateKeyMashScore( $stringToCheck ) {
$letters = str_split( strtolower( $stringToCheck ) );
$rules = $this->getGlobal( 'NameFilterRules' );
$score = 0;
- 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 getQueueDonationMessage
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected function getQueueDonationMessage(): array {
$gatewayTxnId = $this->getData_Unstaged_Escaped( 'gateway_txn_id' );
if ( $gatewayTxnId === null ) {
$gatewayTxnId = false;
}
- 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 buildOrderIDSources
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildOrderIDSources() {
static $built = false;
if ( $built && isset( $this->order_id_candidates ) ) { // once per request is plenty
return;
Method getFormFields
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getFormFields( ?array $knownData = null ): array {
if ( $knownData === null ) {
$knownData = $this->getData_Unstaged_Escaped();
}
$fields = [];
Method getQueueDonationMessage
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getQueueDonationMessage(): array {
$gatewayTxnId = $this->getData_Unstaged_Escaped( 'gateway_txn_id' );
if ( $gatewayTxnId === null ) {
$gatewayTxnId = false;
}
Method fallbackToDefaultCurrency
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function fallbackToDefaultCurrency() {
$defaultCurrency = null;
if ( $this->getGlobal( 'FallbackCurrencyByCountry' ) ) {
$country = $this->dataObj->getVal( 'country' );
if ( $country !== null ) {
Function session_resetForNewAttempt
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function session_resetForNewAttempt( $force = false ) {
$reset = $force;
if ( $this->session_getData( 'numAttempt' ) > 3 ) {
$reset = true;
WmfFramework::setSessionValue( 'numAttempt', 0 );
- 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 session_resetForNewAttempt
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function session_resetForNewAttempt( $force = false ) {
$reset = $force;
if ( $this->session_getData( 'numAttempt' ) > 3 ) {
$reset = true;
WmfFramework::setSessionValue( 'numAttempt', 0 );
Method session_resetOnSwitch
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function session_resetOnSwitch() {
$oldData = $this->session_getData( 'Donor' );
if ( !is_array( $oldData ) ) {
return;
}
Function fallbackToDefaultCurrency
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function fallbackToDefaultCurrency() {
$defaultCurrency = null;
if ( $this->getGlobal( 'FallbackCurrencyByCountry' ) ) {
$country = $this->dataObj->getVal( 'country' );
if ( $country !== null ) {
- 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
Method normalizeOrderID
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function normalizeOrderID( $override = null, $dataObj = null ) {
$selected = false;
$source = null;
$value = null;
if ( $override !== null && $this->validateDataConstraintsMet( 'order_id', $override ) ) {
Method showMonthlyConvert
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function showMonthlyConvert() {
$monthlyConvertAmounts = $this->getMonthlyConvertAmounts();
if ( $monthlyConvertAmounts !== null ) {
$mcMinimumAmount = $monthlyConvertAmounts[0][0];
// check if amount is up to monthly convert minimum amount for specified currency
Method getTransactionSpecificValue
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTransactionSpecificValue( $gateway_field_name ) {
if ( !$this->transactions ) {
$msg = self::getGatewayName() . ': Transactions structure is empty! No transaction can be constructed.';
$this->logger->critical( $msg );
throw new LogicException( $msg );
Method __construct
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( $options = [] ) {
$defaults = [
'external_data' => null,
'variant' => null,
];
Method finalizeInternalStatus
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function finalizeInternalStatus( $status ) {
/**
* Handle session stuff!
* -Behavior-
* * Always, always increment numAttempt.
Method validate
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validate() {
$normalized = $this->dataObj->getData();
if ( $this->transaction_option( 'check_required' ) ) {
// The fields returned by getRequiredFields only make sense
Function normalizeOrderID
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function normalizeOrderID( $override = null, $dataObj = null ) {
$selected = false;
$source = null;
$value = null;
if ( $override !== null && $this->validateDataConstraintsMet( 'order_id', $override ) ) {
- 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 getAvailableSubmethods
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getAvailableSubmethods() {
$method = $this->getPaymentMethod();
$isRecurring = $this->getData_Unstaged_Escaped( 'recurring' );
$country = $this->getData_Unstaged_Escaped( 'country' );
$methodSupportsRecurring = $method ? $this->getPaymentMethodMeta( $method )['recurring'] : false;
- 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 getTransactionSpecificValue
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getTransactionSpecificValue( $gateway_field_name ) {
if ( !$this->transactions ) {
$msg = self::getGatewayName() . ': Transactions structure is empty! No transaction can be constructed.';
$this->logger->critical( $msg );
throw new LogicException( $msg );
- 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 9 (exceeds 5 allowed). Consider refactoring. Open
public function validate() {
$normalized = $this->dataObj->getData();
if ( $this->transaction_option( 'check_required' ) ) {
// The fields returned by getRequiredFields only make sense
- 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 showMonthlyConvert
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function showMonthlyConvert() {
$monthlyConvertAmounts = $this->getMonthlyConvertAmounts();
if ( $monthlyConvertAmounts !== null ) {
$mcMinimumAmount = $monthlyConvertAmounts[0][0];
// check if amount is up to monthly convert minimum amount for specified 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 finalizeInternalStatus
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function finalizeInternalStatus( $status ) {
/**
* Handle session stuff!
* -Behavior-
* * Always, always increment numAttempt.
- 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 trimFieldToConstraints
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function trimFieldToConstraints( $value, $field ) {
// Trim all values if they are a string
$value = is_string( $value ) ? trim( $value ) : $value;
if ( isset( $this->dataConstraints[$field] ) && is_string( $value ) ) {
- 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
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return !$isRecurring && $isMonthlyConvert;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return '';
Avoid too many return
statements within this method. Open
return $convertAmounts['USD'];
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' );
- 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 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' );
- 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 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();
}
- 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 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 );
- 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 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' );
- 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
Similar blocks of code found in 3 locations. Consider refactoring. Open
public function getScoreUtmSourceMap() {
$score = 0;
$source = $this->getData_Unstaged_Escaped( 'utm_source' );
$sourceMap = $this->getGlobal( 'UtmSourceMap' );
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 150.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
public function getScoreUtmCampaignMap() {
$score = 0;
$campaign = $this->getData_Unstaged_Escaped( 'utm_campaign' );
$campaignMap = $this->getGlobal( 'UtmCampaignMap' );
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 150.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
public function getScoreUtmMediumMap() {
$score = 0;
$medium = $this->getData_Unstaged_Escaped( 'utm_medium' );
$mediumMap = $this->getGlobal( 'UtmMediumMap' );
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 150.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76