File RADIUSTests.php
has 813 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
* *****************************************************************************
* Contributions to this work were made on behalf of the GÉANT project, a
RADIUSTests
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class RADIUSTests extends AbstractTest {
/**
* Was the reachability check executed already?
*
Function extractIncomingCertsfromEAP
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private function extractIncomingCertsfromEAP(&$testresults, $tmpDir) {
/*
* EAP's house rules:
* 1) it is unnecessary to include the root CA itself (adding it has
* detrimental effects on performance)
- 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 propertyCheckServercert
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
private function propertyCheckServercert(&$servercert) {
// we share the same checks as for CAs when it comes to signature algorithm and basicconstraints
// so call that function and memorise the outcome
$returnarray = $this->propertyCheckIntermediate($servercert, TRUE);
$sANdns = [];
- 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 autodetectCAWithProbe
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function autodetectCAWithProbe($outerId) {
// for EAP-TLS to be a viable option, we need to pass a random client cert to make eapol_test happy
// the following PEM data is one of the SENSE EAPLab client certs (not secret at all)
$clientcert = file_get_contents(dirname(__FILE__) . "/clientcert.p12");
if ($clientcert === FALSE) {
Function checkLineparse
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private function checkLineparse($inputarray, $desiredCheck) {
foreach ($inputarray as $lineid => $line) {
switch ($desiredCheck) {
case self::LINEPARSE_CHECK_REJECTIGNORE:
if (preg_match("/Attribute 18 (Reply-Message)/", $line) && preg_match("/Reject instead of Ignore at eduroam.org/", $inputarray[$lineid + 1])) {
- 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 consolidateUdpResult
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function consolidateUdpResult($host) {
\core\common\Entity::intoThePotatoes();
$ret = [];
$serverCert = [];
$udpResult = $this->UDP_reachability_result[$host];
- 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 createCArepository
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private function createCArepository($tmpDir, &$intermOdditiesCAT, $servercert, $eapIntermediates, $eapIntermediateCRLs) {
if (!mkdir($tmpDir . "/root-ca-allcerts/", 0700, true)) {
throw new Exception("unable to create root CA directory (RADIUS Tests): $tmpDir/root-ca-allcerts/\n");
}
if (!mkdir($tmpDir . "/root-ca-eaponly/", 0700, 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 udpLogin
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function udpLogin($probeindex, $eaptype, $innerUser, $password, $opnameCheck = TRUE, $frag = TRUE, $clientcertdata = NULL) {
$preliminaries = $this->udpLoginPreliminaries($probeindex, $eaptype, $clientcertdata);
if ($preliminaries !== TRUE) {
return $preliminaries;
}
- 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 extractIncomingCertsfromEAP
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function extractIncomingCertsfromEAP(&$testresults, $tmpDir) {
/*
* EAP's house rules:
* 1) it is unnecessary to include the root CA itself (adding it has
* detrimental effects on performance)
Function autodetectCAWithProbe
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function autodetectCAWithProbe($outerId) {
// for EAP-TLS to be a viable option, we need to pass a random client cert to make eapol_test happy
// the following PEM data is one of the SENSE EAPLab client certs (not secret at all)
$clientcert = file_get_contents(dirname(__FILE__) . "/clientcert.p12");
if ($clientcert === 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 packetCountEvaluation
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private function packetCountEvaluation(&$testresults, $packetcount) {
$reqs = $packetcount[1] ?? 0;
$accepts = $packetcount[2] ?? 0;
$rejects = $packetcount[3] ?? 0;
$challenges = $packetcount[11] ?? 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 udpLogin
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function udpLogin($probeindex, $eaptype, $innerUser, $password, $opnameCheck = TRUE, $frag = TRUE, $clientcertdata = NULL) {
$preliminaries = $this->udpLoginPreliminaries($probeindex, $eaptype, $clientcertdata);
if ($preliminaries !== TRUE) {
return $preliminaries;
}
Method consolidateUdpResult
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function consolidateUdpResult($host) {
\core\common\Entity::intoThePotatoes();
$ret = [];
$serverCert = [];
$udpResult = $this->UDP_reachability_result[$host];
Method checkLineparse
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function checkLineparse($inputarray, $desiredCheck) {
foreach ($inputarray as $lineid => $line) {
switch ($desiredCheck) {
case self::LINEPARSE_CHECK_REJECTIGNORE:
if (preg_match("/Attribute 18 (Reply-Message)/", $line) && preg_match("/Reject instead of Ignore at eduroam.org/", $inputarray[$lineid + 1])) {
Method createCArepository
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function createCArepository($tmpDir, &$intermOdditiesCAT, $servercert, $eapIntermediates, $eapIntermediateCRLs) {
if (!mkdir($tmpDir . "/root-ca-allcerts/", 0700, true)) {
throw new Exception("unable to create root CA directory (RADIUS Tests): $tmpDir/root-ca-allcerts/\n");
}
if (!mkdir($tmpDir . "/root-ca-eaponly/", 0700, true)) {
Function thoroughChainChecks
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function thoroughChainChecks(&$testresults, &$intermOdditiesCAT, $tmpDir, $servercert, $eapIntermediates, $eapIntermediateCRLs) {
$crlCheckString = $this->createCArepository($tmpDir, $intermOdditiesCAT, $servercert, $eapIntermediates, $eapIntermediateCRLs);
// ... and run the verification test
$verifyResultEaponly = [];
- 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 __construct
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($realm, $outerUsernameForChecks, $supportedEapTypes = [], $expectedServerNames = [], $expectedCABundle = []) {
parent::__construct();
$this->realm = $realm;
$this->outerUsernameForChecks = $outerUsernameForChecks;
- 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 thoroughChainChecks
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function thoroughChainChecks(&$testresults, &$intermOdditiesCAT, $tmpDir, $servercert, $eapIntermediates, $eapIntermediateCRLs) {
$crlCheckString = $this->createCArepository($tmpDir, $intermOdditiesCAT, $servercert, $eapIntermediates, $eapIntermediateCRLs);
// ... and run the verification test
$verifyResultEaponly = [];
Method propertyCheckServercert
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function propertyCheckServercert(&$servercert) {
// we share the same checks as for CAs when it comes to signature algorithm and basicconstraints
// so call that function and memorise the outcome
$returnarray = $this->propertyCheckIntermediate($servercert, TRUE);
$sANdns = [];
Method addCrltoCert
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function addCrltoCert(&$cert) {
$crlUrl = [];
$returnresult = 0;
if (!isset($cert['full_details']['extensions']['crlDistributionPoints'])) {
return RADIUSTests::CERTPROB_NO_CDP;
Method __construct
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($realm, $outerUsernameForChecks, $supportedEapTypes = [], $expectedServerNames = [], $expectedCABundle = []) {
parent::__construct();
$this->realm = $realm;
$this->outerUsernameForChecks = $outerUsernameForChecks;
Method wpaSupplicantConfig
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function wpaSupplicantConfig(array $eaptype, string $inner, string $outer, string $password) {
$eapText = \core\common\EAP::eapDisplayName($eaptype);
$config = '
network={
ssid="' . \config\Master::APPEARANCE['productname'] . ' testing"
Function thoroughNameChecks
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function thoroughNameChecks($servercert, &$testresults) {
// Strategy for checks: we are TOTALLY happy if any one of the
// configured names shows up in both the CN and a sAN
// This is the primary check.
// If that was not the case, we are PARTIALLY happy if any one of
- 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 propertyCheckIntermediate
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function propertyCheckIntermediate(&$intermediateCa, $serverCert = FALSE) {
$returnarray = [];
if (preg_match("/md5/i", $intermediateCa['full_details']['signatureTypeSN'])) {
$returnarray[] = RADIUSTests::CERTPROB_MD5_SIGNATURE;
}
Function propertyCheckIntermediate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function propertyCheckIntermediate(&$intermediateCa, $serverCert = FALSE) {
$returnarray = [];
if (preg_match("/md5/i", $intermediateCa['full_details']['signatureTypeSN'])) {
$returnarray[] = RADIUSTests::CERTPROB_MD5_SIGNATURE;
}
- 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 packetCountEvaluation
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function packetCountEvaluation(&$testresults, $packetcount) {
$reqs = $packetcount[1] ?? 0;
$accepts = $packetcount[2] ?? 0;
$rejects = $packetcount[3] ?? 0;
$challenges = $packetcount[11] ?? 0;
Method executeEapolTest
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
private function executeEapolTest($tmpDir, $probeindex, $eaptype, $outerUser, $innerUser, $password, $opnameCheck, $frag) {
Method udpLogin
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function udpLogin($probeindex, $eaptype, $innerUser, $password, $opnameCheck = TRUE, $frag = TRUE, $clientcertdata = NULL) {
Function printDN
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function printDN($distinguishedName) {
$out = '';
foreach (array_reverse($distinguishedName) as $nameType => $nameValue) { // to give an example: "CN" => "some.host.example"
if (!is_array($nameValue)) { // single-valued: just a string
$nameValue = ["$nameValue"]; // convert it to a multi-value attrib with just one value :-) for unified processing later on
- 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 thoroughChainChecks
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private function thoroughChainChecks(&$testresults, &$intermOdditiesCAT, $tmpDir, $servercert, $eapIntermediates, $eapIntermediateCRLs) {
Method createCArepository
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function createCArepository($tmpDir, &$intermOdditiesCAT, $servercert, $eapIntermediates, $eapIntermediateCRLs) {
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct($realm, $outerUsernameForChecks, $supportedEapTypes = [], $expectedServerNames = [], $expectedCABundle = []) {
Avoid too many return
statements within this method. Open
return self::TLS_VERSION_1_0;
Avoid too many return
statements within this method. Open
return self::TLS_VERSION_1_2;
Avoid too many return
statements within this method. Open
return FALSE;
Avoid too many return
statements within this method. Open
return [
"NAME" => $serverName,
"INTERMEDIATE_CA" => $bundle['INTERMEDIATE_CA'],
"HIGHEST_ISSUER" => $currentHighestKnownIssuer,
"ROOT_CA" => NULL,
Avoid too many return
statements within this method. Open
return $returnresult;
Avoid too many return
statements within this method. Open
return self::TLS_VERSION_ANCIENT;
Avoid too many return
statements within this method. Open
return self::TLS_VERSION_1_1;
Function addCrltoCert
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function addCrltoCert(&$cert) {
$crlUrl = [];
$returnresult = 0;
if (!isset($cert['full_details']['extensions']['crlDistributionPoints'])) {
return RADIUSTests::CERTPROB_NO_CDP;
- 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 determineCertificateType
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function determineCertificateType(&$cert, $totalCertCount) {
if ($cert['ca'] == 0 && $cert['root'] == 0) {
return RADIUSTests::SERVER_NO_CA_EXTENSION;
}
if ($cert['ca'] == 1 && $cert['root'] == 1) {
- 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 2 locations. Consider refactoring. Open
if (!preg_match("/OK$/", $verifyResultAllcerts[0])) { // case 1
if (preg_match("/certificate revoked$/", $verifyResultAllcerts[1])) {
$testresults['cert_oddities'][] = RADIUSTests::CERTPROB_SERVER_CERT_REVOKED;
} elseif (preg_match("/unable to get certificate CRL/", $verifyResultAllcerts[1])) {
$testresults['cert_oddities'][] = RADIUSTests::CERTPROB_UNABLE_TO_GET_CRL;
- 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 112.
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 2 locations. Consider refactoring. Open
if (!preg_match("/OK$/", $verifyResultEaponly[0])) { // case 2
if (preg_match("/certificate revoked$/", $verifyResultEaponly[1])) {
$testresults['cert_oddities'][] = RADIUSTests::CERTPROB_SERVER_CERT_REVOKED;
} elseif (preg_match("/unable to get certificate CRL/", $verifyResultEaponly[1])) {
$testresults['cert_oddities'][] = RADIUSTests::CERTPROB_UNABLE_TO_GET_CRL;
- 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 112.
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