File ReportParserGenerate.php
has 2059 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* webtrees: online genealogy
* Copyright (C) 2023 webtrees development team
Function listStartHandler
has a Cognitive Complexity of 221 (exceeds 5 allowed). Consider refactoring. Open
protected function listStartHandler(array $attrs): void
{
$this->process_repeats++;
if ($this->process_repeats > 1) {
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
Method listStartHandler
has 339 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function listStartHandler(array $attrs): void
{
$this->process_repeats++;
if ($this->process_repeats > 1) {
return;
ReportParserGenerate
has 54 functions (exceeds 20 allowed). Consider refactoring. Open
class ReportParserGenerate extends ReportParserBase
{
/** Are we collecting data from <Footnote> elements */
private bool $process_footnote = true;
Function repeatTagStartHandler
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
protected function repeatTagStartHandler(array $attrs): void
{
$this->process_repeats++;
if ($this->process_repeats > 1) {
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 relativesStartHandler
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
protected function relativesStartHandler(array $attrs): void
{
$this->process_repeats++;
if ($this->process_repeats > 1) {
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 getGedcomValue
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
private function getGedcomValue(string $tag, int $level, string $gedrec): string
{
if ($gedrec === '') {
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 gedcomValueStartHandler
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
protected function gedcomValueStartHandler(array $attrs): void
{
$id = '';
$match = [];
if (preg_match('/0 @(.+)@/', $this->gedrec, $match)) {
- 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 addDescendancy
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
private function addDescendancy(&$list, $pid, $parents = false, $generations = -1): void
{
$person = Registry::individualFactory()->make($pid, $this->tree);
if ($person === null) {
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 textBoxStartHandler
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
protected function textBoxStartHandler(array $attrs): void
{
// string Background color code
$bgcolor = '';
if (!empty($attrs['bgcolor'])) {
- 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 docStartHandler
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
protected function docStartHandler(array $attrs): void
{
$this->parser = $this->xml_parser;
// Custom page width
- 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 getPersonNameStartHandler
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
protected function getPersonNameStartHandler(array $attrs): void
{
$id = '';
$match = [];
if (empty($attrs['id'])) {
- 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 addAncestors
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
private function addAncestors(array &$list, string $pid, bool $children = false, int $generations = -1): void
{
$genlist = [$pid];
$list[$pid]->generation = 1;
while (count($genlist) > 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 gedcomStartHandler
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
protected function gedcomStartHandler(array $attrs): void
{
if ($this->process_gedcoms > 0) {
$this->process_gedcoms++;
- 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 factsEndHandler
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
protected function factsEndHandler(): void
{
$this->process_repeats--;
if ($this->process_repeats > 0) {
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
Method textBoxStartHandler
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function textBoxStartHandler(array $attrs): void
{
// string Background color code
$bgcolor = '';
if (!empty($attrs['bgcolor'])) {
Method relativesStartHandler
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function relativesStartHandler(array $attrs): void
{
$this->process_repeats++;
if ($this->process_repeats > 1) {
return;
Function listEndHandler
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
protected function listEndHandler(): void
{
$this->process_repeats--;
if ($this->process_repeats > 0) {
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 cellStartHandler
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
protected function cellStartHandler(array $attrs): void
{
// string The text alignment of the text in this box.
$align = $attrs['align'] ?? '';
// RTL supported left/right alignment
- 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 relativesEndHandler
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
protected function relativesEndHandler(): void
{
$this->process_repeats--;
if ($this->process_repeats > 0) {
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 varStartHandler
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
protected function varStartHandler(array $attrs): void
{
if (empty($attrs['var'])) {
throw new DomainException('REPORT ERROR var: The attribute "var=" is missing or not set in the XML file on line: ' . xml_get_current_line_number($this->parser));
}
- 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 cellStartHandler
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function cellStartHandler(array $attrs): void
{
// string The text alignment of the text in this box.
$align = $attrs['align'] ?? '';
// RTL supported left/right alignment
Method factsEndHandler
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function factsEndHandler(): void
{
$this->process_repeats--;
if ($this->process_repeats > 0) {
return;
Function imageStartHandler
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
protected function imageStartHandler(array $attrs): void
{
// Position the top corner of this box on the page. the default is the current position
$top = (float) ($attrs['top'] ?? ReportBaseElement::CURRENT_POSITION);
- 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 listEndHandler
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function listEndHandler(): void
{
$this->process_repeats--;
if ($this->process_repeats > 0) {
return;
Function lineStartHandler
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
protected function lineStartHandler(array $attrs): void
{
// Start horizontal position, current position (default)
$x1 = ReportBaseElement::CURRENT_POSITION;
if (isset($attrs['x1'])) {
- 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 repeatTagEndHandler
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
protected function repeatTagEndHandler(): void
{
$this->process_repeats--;
if ($this->process_repeats > 0) {
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
Method relativesEndHandler
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function relativesEndHandler(): void
{
$this->process_repeats--;
if ($this->process_repeats > 0) {
return;
Method docStartHandler
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function docStartHandler(array $attrs): void
{
$this->parser = $this->xml_parser;
// Custom page width
Method repeatTagEndHandler
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function repeatTagEndHandler(): void
{
$this->process_repeats--;
if ($this->process_repeats > 0) {
return;
Function factsStartHandler
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
protected function factsStartHandler(array $attrs): void
{
$this->process_repeats++;
if ($this->process_repeats > 1) {
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
Method gedcomValueStartHandler
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function gedcomValueStartHandler(array $attrs): void
{
$id = '';
$match = [];
if (preg_match('/0 @(.+)@/', $this->gedrec, $match)) {
Method getGedcomValue
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getGedcomValue(string $tag, int $level, string $gedrec): string
{
if ($gedrec === '') {
return '';
}
Function ifStartHandler
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected function ifStartHandler(array $attrs): void
{
if ($this->process_ifs > 0) {
$this->process_ifs++;
- 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
Consider simplifying this complex logical expression. Open
if (($this->process_footnote || $name === 'Footnote') && ($this->process_ifs === 0 || $name === 'if') && ($this->process_gedcoms === 0 || $name === 'Gedcom') && ($this->process_repeats === 0 || $name === 'Facts' || $name === 'RepeatTag' || $name === 'List' || $name === 'Relatives')) {
$method = $name . 'EndHandler';
if (method_exists($this, $method)) {
$this->{$method}();
Method repeatTagStartHandler
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function repeatTagStartHandler(array $attrs): void
{
$this->process_repeats++;
if ($this->process_repeats > 1) {
return;
Function setVarStartHandler
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
protected function setVarStartHandler(array $attrs): void
{
if (empty($attrs['name'])) {
throw new DomainException('REPORT ERROR var: The attribute "name" is missing or not set in the XML file');
}
- 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 ifStartHandler
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function ifStartHandler(array $attrs): void
{
if ($this->process_ifs > 0) {
$this->process_ifs++;
Function startElement
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected function startElement($parser, string $name, array $attrs): void
{
$newattrs = [];
foreach ($attrs as $key => $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
Method gedcomStartHandler
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function gedcomStartHandler(array $attrs): void
{
if ($this->process_gedcoms > 0) {
$this->process_gedcoms++;
Method setVarStartHandler
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function setVarStartHandler(array $attrs): void
{
if (empty($attrs['name'])) {
throw new DomainException('REPORT ERROR var: The attribute "name" is missing or not set in the XML file');
}
Method addDescendancy
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function addDescendancy(&$list, $pid, $parents = false, $generations = -1): void
{
$person = Registry::individualFactory()->make($pid, $this->tree);
if ($person === null) {
return;
Method imageStartHandler
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function imageStartHandler(array $attrs): void
{
// Position the top corner of this box on the page. the default is the current position
$top = (float) ($attrs['top'] ?? ReportBaseElement::CURRENT_POSITION);
Method getPersonNameStartHandler
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getPersonNameStartHandler(array $attrs): void
{
$id = '';
$match = [];
if (empty($attrs['id'])) {
Method lineStartHandler
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function lineStartHandler(array $attrs): void
{
// Start horizontal position, current position (default)
$x1 = ReportBaseElement::CURRENT_POSITION;
if (isset($attrs['x1'])) {
Method factsStartHandler
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function factsStartHandler(array $attrs): void
{
$this->process_repeats++;
if ($this->process_repeats > 1) {
return;
Method varStartHandler
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function varStartHandler(array $attrs): void
{
if (empty($attrs['var'])) {
throw new DomainException('REPORT ERROR var: The attribute "var=" is missing or not set in the XML file on line: ' . xml_get_current_line_number($this->parser));
}
Method addAncestors
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function addAncestors(array &$list, string $pid, bool $children = false, int $generations = -1): void
{
$genlist = [$pid];
$list[$pid]->generation = 1;
while (count($genlist) > 0) {
Consider simplifying this complex logical expression. Open
if ($this->process_footnote && ($this->process_ifs === 0 || $name === 'if') && ($this->process_gedcoms === 0 || $name === 'Gedcom') && ($this->process_repeats === 0 || $name === 'Facts' || $name === 'RepeatTag')) {
$method = $name . 'StartHandler';
if (method_exists($this, $method)) {
$this->{$method}($attrs);
Method highlightedImageStartHandler
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function highlightedImageStartHandler(array $attrs): void
{
$id = '';
if (preg_match('/0 @(.+)@/', $this->gedrec, $match)) {
$id = $match[1];
Function endElement
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function endElement($parser, string $name): void
{
if (($this->process_footnote || $name === 'Footnote') && ($this->process_ifs === 0 || $name === 'if') && ($this->process_gedcoms === 0 || $name === 'Gedcom') && ($this->process_repeats === 0 || $name === 'Facts' || $name === 'RepeatTag' || $name === 'List' || $name === 'Relatives')) {
$method = $name . 'EndHandler';
- 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 getSubRecord
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getSubRecord(int $level, string $tag, string $gedrec, int $num = 1): string
{
if ($gedrec === '') {
return '';
}
Avoid deeply nested control flow statements. Open
if (!empty($searchstr)) {
$searchstr .= "[^\n]*(\n[2-9][^\n]*)*\n";
}
Avoid deeply nested control flow statements. Open
if ($t === 'EMAIL' || $t === '_EMAIL') {
$t = '_?EMAIL';
}
Avoid deeply nested control flow statements. Open
switch ($expr) {
case 'CONTAINS':
if ($t === 'PLAC') {
$searchstr .= "[^\n]*[, ]*" . $val;
} else {
Avoid deeply nested control flow statements. Open
if ($tag === 'EMAIL' || $tag === '_EMAIL') {
$tag = '_?EMAIL';
}
Avoid deeply nested control flow statements. Open
if (empty($subrec)) {
$level--;
$subrec = self::getSubRecord($level, "@ $t", $this->gedrec);
if (empty($subrec)) {
return;
Avoid deeply nested control flow statements. Open
if ($match[1] != '') {
$names = explode(' ', $match[1]);
foreach ($names as $name) {
$query->where($attr . '.n_full', 'LIKE', '%' . addcslashes($name, '\\%_') . '%');
}
Function highlightedImageStartHandler
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function highlightedImageStartHandler(array $attrs): void
{
$id = '';
if (preg_match('/0 @(.+)@/', $this->gedrec, $match)) {
$id = $match[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
Avoid too many return
statements within this method. Open
return ltrim($subrec);
Avoid too many return
statements within this method. Open
return '';
Function getSubRecord
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function getSubRecord(int $level, string $tag, string $gedrec, int $num = 1): string
{
if ($gedrec === '') {
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 getCont
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function getCont(int $nlevel, string $nrec): string
{
$text = '';
$subrecords = explode("\n", $nrec);
- 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 footnoteStartHandler
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function footnoteStartHandler(array $attrs): void
{
$id = '';
if (preg_match('/[0-9] (.+) @(.+)@/', $this->gedrec, $match)) {
$id = $match[2];
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($media_file instanceof MediaFile && $media_file->fileExists()) {
$image = imagecreatefromstring($media_file->fileContents());
$attributes = [imagesx($image), imagesy($image)];
if ($width > 0 && $height == 0) {
- 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 242.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($media_file instanceof MediaFile && $media_file->fileExists()) {
$image = imagecreatefromstring($media_file->fileContents());
$attributes = [imagesx($image), imagesy($image)];
if ($width > 0 && $height == 0) {
- 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 242.
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
} elseif (preg_match('/^(?:\w*):PLAC CONTAINS (.+)$/', $value, $match)) {
// Don't unset this filter. This is just initial filtering for performance
$query
->join('placelinks AS ' . $attr . 'a', static function (JoinClause $join) use ($attr): void {
$join
- 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 198.
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
} elseif (preg_match('/^(?:\w*):PLAC CONTAINS (.+)$/', $value, $match)) {
// Don't unset this filter. This is just initial filtering for performance
$query
->join('placelinks AS ' . $attr . 'a', static function (JoinClause $join) use ($attr): void {
$join
- 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 198.
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('/^(\w+):DATE (LTE|GTE) (.+)$/', $value, $match)) {
$query->join('dates AS ' . $attr, static function (JoinClause $join) use ($attr): void {
$join
->on($attr . '.d_gid', '=', 'f_id')
->on($attr . '.d_file', '=', 'f_file');
- 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 174.
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('/^(\w+):DATE (LTE|GTE) (.+)$/', $value, $match)) {
$query->join('dates AS ' . $attr, static function (JoinClause $join) use ($attr): void {
$join
->on($attr . '.d_gid', '=', 'i_id')
->on($attr . '.d_file', '=', 'i_file');
- 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 174.
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
} elseif (preg_match('/^(\w*):(\w+) CONTAINS (.+)$/', $value, $match)) {
// Don't unset this filter. This is just initial filtering for performance
$match[3] = strtr($match[3], ['\\' => '\\\\', '%' => '\\%', '_' => '\\_', ' ' => '%']);
$like = "%\n1 " . $match[1] . "%\n2 " . $match[2] . '%' . $match[3] . '%';
$query->where('f_gedcom', 'LIKE', $like);
- 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 121.
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
} elseif (preg_match('/^(\w*):(\w+) CONTAINS (.+)$/', $value, $match)) {
// Don't unset this filter. This is just initial filtering for performance
$match[3] = strtr($match[3], ['\\' => '\\\\', '%' => '\\%', '_' => '\\_', ' ' => '%']);
$like = "%\n1 " . $match[1] . "%\n2 " . $match[2] . '%' . $match[3] . '%';
$query->where('i_gedcom', 'LIKE', $like);
- 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 121.
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('/^I18N::number\((.+)\)$/', $var, $match)) {
$var = I18N::number((int) $match[1]);
} elseif (preg_match('/^I18N::translate\(\'(.+)\'\)$/', $var, $match)) {
$var = I18N::translate($match[1]);
} elseif (preg_match('/^I18N::translateContext\(\'(.+)\', *\'(.+)\'\)$/', $var, $match)) {
- 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 115.
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('/^I18N::number\((.+)\)$/', $value, $match)) {
$value = I18N::number((int) $match[1]);
} elseif (preg_match('/^I18N::translate\(\'(.+)\'\)$/', $value, $match)) {
$value = I18N::translate($match[1]);
} elseif (preg_match('/^I18N::translateContext\(\'(.+)\', *\'(.+)\'\)$/', $value, $match)) {
- 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 115.
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
} elseif (preg_match('/^(\w+) CONTAINS (.*)$/', $value, $match)) {
// Don't unset this filter. This is just initial filtering for performance
$match[2] = strtr($match[2], ['\\' => '\\\\', '%' => '\\%', '_' => '\\_', ' ' => '%']);
$like = "%\n1 " . $match[1] . '%' . $match[2] . '%';
$query->where('i_gedcom', 'LIKE', $like);
- 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 109.
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
} elseif (preg_match('/^(\w+) CONTAINS (.+)$/', $value, $match)) {
// Don't unset this filter. This is just initial filtering for performance
$match[2] = strtr($match[2], ['\\' => '\\\\', '%' => '\\%', '_' => '\\_', ' ' => '%']);
$like = "%\n1 " . $match[1] . '%' . $match[2] . '%';
$query->where('f_gedcom', 'LIKE', $like);
- 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 109.
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