Method generatePdf
has 130 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function generatePdf()
{
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
$h = $this->internship->getHost();
$s = $this->internship->getSupervisor();
- Create a ticketCreate a ticket
Function generatePdf
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function generatePdf()
{
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
$h = $this->internship->getHost();
$s = $this->internship->getSupervisor();
- Read upRead up
- Create a ticketCreate a ticket
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
The method generatePdf() has an NPath complexity of 1152. The configured NPath complexity threshold is 200. Open
private function generatePdf()
{
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
$h = $this->internship->getHost();
$s = $this->internship->getSupervisor();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method generatePdf() has 209 lines of code. Current threshold is set to 100. Avoid really long methods. Open
private function generatePdf()
{
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
$h = $this->internship->getHost();
$s = $this->internship->getSupervisor();
- Create a ticketCreate a ticket
- Exclude checks
The method generatePdf() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10. Open
private function generatePdf()
{
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
$h = $this->internship->getHost();
$s = $this->internship->getSupervisor();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Missing class import via use statement (line '73', column '26'). Open
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method generatePdf uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
}else{
// Too long, need to use two lines, breaks string at whole word around 55 chars
$addrSup = wordwrap($super_address, 55);
$superLine1 = substr($addrSup, 0, strpos($addrSup, "\n"));
$superLine2 = substr($addrSup, strpos($addrSup, "\n"));
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method generatePdf uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
}else{
//break the string at a word before 50 chars
$addr = wordwrap($fullAddress, 50);
$addrFac1 = substr($addr, 0, strpos($addr, "\n"));
$addrFac2 = substr($addr, strpos($addr, "\n"));
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method generatePdf uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
}else{
//break the string at a word before 50 chars
$addr = wordwrap($host_address, 50);
$addr1 = substr($addr, 0, strpos($addr, "\n"));
$addr2 = substr($addr, strpos($addr, "\n"));
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(55, 5, $this->internship->getFullName());
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(127, 91);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(190, 97);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(12, 5, $this->internship->getCreditHours());
- Create a ticketCreate a ticket
- Exclude checks
Call to method setSourceFile
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setSourceFile(PHPWS_SOURCE_DIR . 'mod/intern/pdf/Acknowledgment_Updated_202120.pdf');
- Create a ticketCreate a ticket
- Exclude checks
Return type of getPdf()
is undeclared type \Intern\FPDI
Open
public function getPdf()
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(24, 5, 'X', 0, 0, 'C');
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(168, 69);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(40, 84);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(109, 103);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setFont
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setFont('Times', null, 10);
- Create a ticketCreate a ticket
- Exclude checks
Call to method addPage
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->addPage();
- Create a ticketCreate a ticket
- Exclude checks
Call to method importPage
from undeclared class \setasign\Fpdi\Fpdi
Open
$tplidx = $this->pdf->importPage(1);
- Create a ticketCreate a ticket
- Exclude checks
Call to method multiCell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->multiCell(60, 3, $d->getName());
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(12, 5, $this->internship->getAvgHoursPerWeek());
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(73, 6, $this->internship->getCourseTitle());
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(147, 97);
- Create a ticketCreate a ticket
- Exclude checks
Call to method __construct
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(54, 5, $this->internship->getPhoneNumber());
- Create a ticketCreate a ticket
- Exclude checks
Call to method setAutoPageBreak
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setAutoPageBreak(true, 0);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(138, 53);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(85, 69);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(40, 91);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(138, 41);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(54, 5, $this->internship->getEmailAddress() . '@appstate.edu');
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(77, 5, $f->getFax());
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(127, 128);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(52, 0, $firstContact->getRelation());
- Create a ticketCreate a ticket
- Exclude checks
Reference to undeclared constant \PHPWS_SOURCE_DIR
Open
$this->pdf->setSourceFile(PHPWS_SOURCE_DIR . 'mod/intern/pdf/Acknowledgment_Updated_202120.pdf');
- Create a ticketCreate a ticket
- Exclude checks
Call to method useTemplate
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->useTemplate($tplidx);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(24, 5, 'X', 0, 0, 'C');
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(42, 5, $this->internship->getBannerId());
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(27, 6, $this->term->getDescription());
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(81, 5, $fullAddress);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(77, 0, $h->getSubName());
- Create a ticketCreate a ticket
- Exclude checks
Reference to undeclared constant \PHPWS_SOURCE_DIR
Open
require_once PHPWS_SOURCE_DIR . 'mod/intern/vendor/autoload.php';
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(155, 84);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(22, 103);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(78, 5, $superLine2);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(28, 120);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(75, 5, $super);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(78, 5, $superLine1);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(127, 128);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(52, 0, $firstContact->getPhone());
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(113, 125);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(113, 149);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(112, 133);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(137, 174);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(125, 166);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(81, 5, $addrFac1);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(77, 5, $host_address);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(77, 5, $addr1);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(59, 273);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(134, 273);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(81, 5, $f->getFullName());
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(113, 149);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(33, 5, $s->getSupervisorPhoneNumber());
- Create a ticketCreate a ticket
- Exclude checks
Call to method addPage
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->addPage();
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(52, 0, $firstContact->getName());
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(31, 127);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(29, 141);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(25, 148);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(77, 5, $f->getUsername() . '@appstate.edu');
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(15, 134);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(139, 117);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(71, 6, $h->getMainName());
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(40, 5, $s->getSupervisorFaxNumber());
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(175, 103);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(30, 5, $this->term->getEndDateFormatted(), 0, 0, 'C');
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(28, 155);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(81, 5, $addrFac2);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(172, 273);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(77, 5, $addr2);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(166, 160);
- Create a ticketCreate a ticket
- Exclude checks
Call to method importPage
from undeclared class \setasign\Fpdi\Fpdi
Open
$tplidx = $this->pdf->importPage(2);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(113, 144);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(78, 5, $super_address);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(113, 155);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(125, 160);
- Create a ticketCreate a ticket
- Exclude checks
Call to method useTemplate
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->useTemplate($tplidx);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(30, 5, $this->term->getStartDateFormatted(), 0, 0, 'C');
- Create a ticketCreate a ticket
- Exclude checks
Call to method setXY
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->setXY(31, 127);
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(77, 5, $f->getPhone());
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(77,0, $this->internship->getRemoteState());
- Create a ticketCreate a ticket
- Exclude checks
Call to method cell
from undeclared class \setasign\Fpdi\Fpdi
Open
$this->pdf->cell(72, 5, $s->getSupervisorEmail());
- Create a ticketCreate a ticket
- Exclude checks
Similar blocks of code found in 3 locations. Consider refactoring. Open
if(strlen($super_address) < 65){
// If it's short enough, just write it
$this->pdf->setXY(113, 149);
$this->pdf->cell(78, 5, $super_address);
}else{
- Read upRead up
- Create a ticketCreate a ticket
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 186.
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
if(strlen($fullAddress) < 51){
// If it's short enough, just write it
$this->pdf->setXY(31, 127);
$this->pdf->cell(81, 5, $fullAddress);
}else{
- Read upRead up
- Create a ticketCreate a ticket
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 186.
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
if(strlen($host_address) < 51){
// If it's short enough, just write it
$this->pdf->setXY(127, 128);
$this->pdf->cell(77, 5, $host_address);
}else{
- Read upRead up
- Create a ticketCreate a ticket
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 186.
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
Avoid variables with short names like $s. Configured minimum length is 3. Open
$s = $this->internship->getSupervisor();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $h. Configured minimum length is 3. Open
$h = $this->internship->getHost();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $f. Configured minimum length is 3. Open
$f = $this->internship->getFaculty();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $d. Configured minimum length is 3. Open
$d = $this->internship->getDepartment();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $i. Configured minimum length is 3. Open
public function __construct(Internship $i, Array $emergencyContacts, Term $term)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The variable $host_address is not named in camelCase. Open
private function generatePdf()
{
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
$h = $this->internship->getHost();
$s = $this->internship->getSupervisor();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $host_address is not named in camelCase. Open
private function generatePdf()
{
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
$h = $this->internship->getHost();
$s = $this->internship->getSupervisor();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $host_address is not named in camelCase. Open
private function generatePdf()
{
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
$h = $this->internship->getHost();
$s = $this->internship->getSupervisor();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $super_address is not named in camelCase. Open
private function generatePdf()
{
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
$h = $this->internship->getHost();
$s = $this->internship->getSupervisor();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $host_address is not named in camelCase. Open
private function generatePdf()
{
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
$h = $this->internship->getHost();
$s = $this->internship->getSupervisor();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $super_address is not named in camelCase. Open
private function generatePdf()
{
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
$h = $this->internship->getHost();
$s = $this->internship->getSupervisor();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $super_address is not named in camelCase. Open
private function generatePdf()
{
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
$h = $this->internship->getHost();
$s = $this->internship->getSupervisor();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $super_address is not named in camelCase. Open
private function generatePdf()
{
$this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
$h = $this->internship->getHost();
$s = $this->internship->getSupervisor();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}