vairogs/vairogs

View on GitHub

Showing 12 of 85 total issues

Function makeOneDimension has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function makeOneDimension(array $array, string $base = '', string $separator = '.', bool $onlyLast = false, int $depth = 0, int $maxDepth = PHP_INT_MAX, array $result = [], bool $allowList = false): array
    {
        if ($depth <= $maxDepth) {
            foreach ($array as $key => $value) {
                $key = ltrim(string: $base . '.' . $key, characters: '.');
Severity: Minor
Found in src/Vairogs/Component/Functions/Iteration.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 makeOneDimension has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function makeOneDimension(array $array, string $base = '', string $separator = '.', bool $onlyLast = false, int $depth = 0, int $maxDepth = PHP_INT_MAX, array $result = [], bool $allowList = false): array
Severity: Major
Found in src/Vairogs/Component/Functions/Iteration.php - About 1 hr to fix

    Function willBeAvailable has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function willBeAvailable(string $package, string $class, array $parentPackages, string $rootPackageCheck = 'vairogs/vairogs'): bool
        {
            if (!class_exists(class: InstalledVersions::class)) {
                throw new LogicException(message: sprintf('Calling "%s" when dependencies have been installed with Composer 1 is not supported. Consider upgrading to Composer 2.', __METHOD__));
            }
    Severity: Minor
    Found in src/Vairogs/Component/Functions/Composer.php - About 55 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

    Method distanceBetweenPoints has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function distanceBetweenPoints(float $latitude1, float $longitude1, float $latitude2, float $longitude2, bool $km = true, int $precision = 4): float
    Severity: Minor
    Found in src/Vairogs/Component/Functions/Util.php - About 45 mins to fix

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

          public function bubbleSort(array &$array): void
          {
              $count = count(value: $array);
              for ($foo = 0; $foo < $count; $foo++) {
                  for ($bar = 0; $bar < $count - 1; $bar++) {
      Severity: Minor
      Found in src/Vairogs/Component/Functions/Sort.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 merge has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private function merge(array $left, array $right): array
          {
              $result = [];
              $i = $j = 0;
      
      
      Severity: Minor
      Found in src/Vairogs/Component/Functions/Sort.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 compare has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private function compare(string $first, string $second): int
          {
              for ($i = 0, $len = mb_strlen(string: $first); $i < $len; $i++) {
                  if (($charFirst = mb_substr(string: $first, start: $i, length: 1)) === ($charSecond = mb_substr(string: $second, start: $i, length: 1))) {
                      continue;
      Severity: Minor
      Found in src/Vairogs/Component/Functions/SortLatvian.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

      Avoid too many return statements within this method.
      Open

              return false;
      Severity: Major
      Found in src/Vairogs/Component/Functions/Composer.php - About 30 mins to fix

        Function unpack has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function unpack(array $oneDimension): array
            {
                $multiDimension = [];
        
                foreach ($oneDimension as $key => $value) {
        Severity: Minor
        Found in src/Vairogs/Component/Functions/Iteration.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

        Function isInstalled has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function isInstalled(array $packages, bool $incDevReq = false): bool
            {
                foreach ($packages as $packageName) {
                    if (false !== phpversion(extension: $packageName)) {
                        continue;
        Severity: Minor
        Found in src/Vairogs/Component/Functions/Composer.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

        Function validatePersonCode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function validatePersonCode(string $personCode): bool
            {
                $personCode = (new Text())->keepNumeric(text: $personCode);
                $personCode = str_replace(search: '-', replace: '', subject: $personCode);
        
        
        Severity: Minor
        Found in src/Vairogs/Component/Functions/Identification.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

        Function getFilteredMethods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getFilteredMethods(string $class, ?string $filterClass = null): array
            {
                try {
                    $methods = (new ReflectionClass(objectOrClass: $class))->getMethods(filter: ReflectionMethod::IS_PUBLIC);
                } catch (Exception) {
        Severity: Minor
        Found in src/Vairogs/Component/Functions/Reflection.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