VSVverkeerskunde/gvq-api

View on GitHub
src/Statistics/Models/RankedCompanyParticipant.php

Summary

Maintainability
A
30 mins
Test Coverage

Avoid too many return statements within this method.
Open

        return ($n1->toNative() > $n2->toNative()) ? 1 : -1;
Severity: Major
Found in src/Statistics/Models/RankedCompanyParticipant.php - About 30 mins to fix

    Reduce the number of returns of this function 5, down to the maximum allowed 3.
    Open

        private function compareNaturalNumber(NaturalNumber $n1 = null, NaturalNumber $n2 = null): int

    Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

    Noncompliant Code Example

    With the default threshold of 3:

    function myFunction(){ // Noncompliant as there are 4 return statements
      if (condition1) {
        return true;
      } else {
        if (condition2) {
          return false;
        } else {
          return true;
        }
      }
      return false;
    }
    

    Reduce the number of returns of this function 4, down to the maximum allowed 3.
    Open

        private function compareDistance(NaturalNumber $d1 = null, NaturalNumber $d2 = null): int

    Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

    Noncompliant Code Example

    With the default threshold of 3:

    function myFunction(){ // Noncompliant as there are 4 return statements
      if (condition1) {
        return true;
      } else {
        if (condition2) {
          return false;
        } else {
          return true;
        }
      }
      return false;
    }
    

    Avoid variables with short names like $n2. Configured minimum length is 3.
    Open

        private function compareNaturalNumber(NaturalNumber $n1 = null, NaturalNumber $n2 = null): int

    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 $d1. Configured minimum length is 3.
    Open

        private function compareDistance(NaturalNumber $d1 = null, NaturalNumber $d2 = null): int

    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 $b. Configured minimum length is 3.
    Open

        private function distance(NaturalNumber $a, NaturalNumber $b = null): ?NaturalNumber {

    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 $n1. Configured minimum length is 3.
    Open

        private function compareNaturalNumber(NaturalNumber $n1 = null, NaturalNumber $n2 = null): int

    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 $d2. Configured minimum length is 3.
    Open

        private function compareDistance(NaturalNumber $d1 = null, NaturalNumber $d2 = null): int

    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 $a. Configured minimum length is 3.
    Open

        private function distance(NaturalNumber $a, NaturalNumber $b = null): ?NaturalNumber {

    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 closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
    Open

        {

    The closing parenthesis of a multi-line function declaration must be on a new line
    Open

            NaturalNumber $answer2)

    Function closing brace must go on the next line following the body; found 1 blank lines before brace
    Open

        }

    The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
    Open

        {

    The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
    Open

        {

    Expected 0 spaces between brackets of function declaration; 4 found
    Open

        public function getAnswer1(

    Expected 0 spaces between brackets of function declaration; 4 found
    Open

        public function getAnswer2(

    Opening brace should be on a new line
    Open

        private function distance(NaturalNumber $a, NaturalNumber $b = null): ?NaturalNumber {

    There are no issues that match your filters.

    Category
    Status