fisharebest/algorithm

View on GitHub

Showing 6 of 6 total issues

Function calculate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function calculate(array $a, array $b, $compare = null)
    {
        if ($compare === null) {
            $compare = function ($x, $y) {
                return $x === $y;
Severity: Minor
Found in src/MyersDiff.php - About 2 hrs to fix

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 processNextNodeInQueue has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    protected function processNextNodeInQueue(array $exclude)
    {
        // Process the closest vertex
        $closest = array_search(min($this->queue), $this->queue);
        if (!empty($this->graph[$closest]) && !in_array($closest, $exclude)) {
Severity: Minor
Found in src/Dijkstra.php - About 1 hr to fix

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 calculate has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function calculate(array $a, array $b, $compare = null)
    {
        if ($compare === null) {
            $compare = function ($x, $y) {
                return $x === $y;
Severity: Minor
Found in src/MyersDiff.php - About 1 hr to fix

    Function formatSolution has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        private function formatSolution(array $snakes, array $a, array $b)
        {
            $solution = array();
            $x = 0;
            $y = 0;
    Severity: Minor
    Found in src/MyersDiff.php - About 35 mins to fix

    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 extractSnakes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        private function extractSnakes(array $v_save, $x, $y)
        {
            $snakes = array();
            for ($d = count($v_save) - 1; $x >= 0 && $y >= 0; $d--) {
                array_unshift($snakes, array($x, $y));
    Severity: Minor
    Found in src/MyersDiff.php - About 35 mins to fix

    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 extractPaths has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function extractPaths($target)
        {
            $paths = array(array($target));
    
            for ($key = 0; isset($paths[$key]); ++$key) {
    Severity: Minor
    Found in src/Dijkstra.php - About 25 mins to fix

    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

    Severity
    Category
    Status
    Source
    Language