Showing 47 of 47 total issues
Function run
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public function run($start, $dest, $k = 3)
{
if (empty($this->graph->vertices[$start])) {
throw new InvalidArgumentException("Vertex $start does not exist.");
}
- 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 run
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function run()
{
foreach (array_keys($this->graph->vertices) as $vertex1) {
foreach (array_keys($this->graph->vertices) as $vertex2) {
$this->dist[$vertex1][$vertex2] = INF;
- 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 run
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run($start, $dest, $k = 3)
{
if (empty($this->graph->vertices[$start])) {
throw new InvalidArgumentException("Vertex $start does not exist.");
}
Method getGraphML
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getGraphML()
{
$directionality = $this->graph->directed ? 'directed' : 'undirected';
$export = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>'
.'<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">'
Function run
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function run($root)
{
foreach (array_keys($this->graph->vertices) as $vertex) {
$this->dist[$vertex] = INF;
$this->parent[$vertex] = null;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function fromGraphML
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function fromGraphML($file)
{
if (!file_exists($file)) {
throw new InvalidArgumentException('File '.$file.' does not exist.');
}
- 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 excessively long variable names like $originalDestinationVertex. Keep variable name length under 20. Open
$originalDestinationVertex = $destinationVertex;
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Method fromGraphML
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fromGraphML($file)
{
if (!file_exists($file)) {
throw new InvalidArgumentException('File '.$file.' does not exist.');
}
Function run
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function run($start)
{
$this->start = $start;
if (empty($this->graph->vertices[$start])) {
throw new InvalidArgumentException("Vertex $start does not exist.");
- 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 run
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function run($start)
{
$this->start = $start;
if (empty($this->graph->vertices[$start])) {
throw new InvalidArgumentException("Vertex $start does not exist.");
- 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 run
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run($start)
{
$this->start = $start;
if (empty($this->graph->vertices[$start])) {
throw new InvalidArgumentException("Vertex $start does not exist.");
Method run
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run($start)
{
$this->start = $start;
if (empty($this->graph->vertices[$start])) {
throw new InvalidArgumentException("Vertex $start does not exist.");
Avoid using undefined variables such as '$discovered' which will lead to PHP notices. Open
unset($discovered[$key]);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$discovered' which will lead to PHP notices. Open
if (!in_array($child, $discovered)) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$discovered' which will lead to PHP notices. Open
if (($key = array_search($source, $discovered)) !== false) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$discovered' which will lead to PHP notices. Open
$discovered[] = $source;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Function enumerate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function enumerate($source, $dest)
{
array_unshift($this->path, $source);
$discovered[] = $source;
- 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 run
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function run($root)
{
foreach (array_keys($this->graph->vertices) as $vertex) {
$this->dist[$vertex] = INF;
$this->parent[$vertex] = null;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method run
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run()
{
foreach (array_keys($this->graph->vertices) as $vertex1) {
foreach (array_keys($this->graph->vertices) as $vertex2) {
$this->dist[$vertex1][$vertex2] = INF;
Method run
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run($root)
{
foreach (array_keys($this->graph->vertices) as $vertex) {
$this->dist[$vertex] = INF;
$this->parent[$vertex] = null;