phpmyadmin/phpmyadmin

View on GitHub
src/Git.php

Summary

Maintainability
F
4 days
Test Coverage

Function unPackGz has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

    private function unPackGz(string $gitFolder, string $hash): array|false|null
    {
        $commit = false;

        $gitFileName = $gitFolder . '/objects/'
Severity: Minor
Found in src/Git.php - About 7 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

File Git.php has 426 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace PhpMyAdmin;
Severity: Minor
Found in src/Git.php - About 6 hrs to fix

    Function checkGitRevision has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        public function checkGitRevision(): array|null
        {
            // find out if there is a .git folder
            $gitFolder = '';
            if (! $this->isGitRevision($gitFolder)) {
    Severity: Minor
    Found in src/Git.php - About 3 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

    Method checkGitRevision has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function checkGitRevision(): array|null
        {
            // find out if there is a .git folder
            $gitFolder = '';
            if (! $this->isGitRevision($gitFolder)) {
    Severity: Major
    Found in src/Git.php - About 3 hrs to fix

      Method unPackGz has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function unPackGz(string $gitFolder, string $hash): array|false|null
          {
              $commit = false;
      
              $gitFileName = $gitFolder . '/objects/'
      Severity: Major
      Found in src/Git.php - About 2 hrs to fix

        Function getHashFromHeadRef has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            private function getHashFromHeadRef(string $gitFolder, string $refHead): array
            {
                // are we on any branch?
                if (! str_contains($refHead, '/')) {
                    return [trim($refHead), false];
        Severity: Minor
        Found in src/Git.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

        Method getHashFromHeadRef has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function getHashFromHeadRef(string $gitFolder, string $refHead): array
            {
                // are we on any branch?
                if (! str_contains($refHead, '/')) {
                    return [trim($refHead), false];
        Severity: Minor
        Found in src/Git.php - About 1 hr to fix

          Method getPackOffset has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function getPackOffset(string $packFile, string $hash): int|null
              {
                  // load index
                  $indexData = @file_get_contents($packFile);
                  if ($indexData === false) {
          Severity: Minor
          Found in src/Git.php - About 1 hr to fix

            Method isGitRevision has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function isGitRevision(string|null &$gitLocation = null): bool
                {
                    if (! $this->showGitRevision) {
                        return false;
                    }
            Severity: Minor
            Found in src/Git.php - About 1 hr to fix

              Function isGitRevision has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function isGitRevision(string|null &$gitLocation = null): bool
                  {
                      if (! $this->showGitRevision) {
                          return false;
                      }
              Severity: Minor
              Found in src/Git.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 readPackFile has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function readPackFile(string $packFile, int $packOffset): string|null
                  {
                      // open pack file
                      $packFileRes = fopen($packFile, 'rb');
                      if ($packFileRes === false) {
              Severity: Minor
              Found in src/Git.php - About 1 hr to fix

                Function getPackOffset has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function getPackOffset(string $packFile, string $hash): int|null
                    {
                        // load index
                        $indexData = @file_get_contents($packFile);
                        if ($indexData === false) {
                Severity: Minor
                Found in src/Git.php - About 45 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 readPackFile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function readPackFile(string $packFile, int $packOffset): string|null
                    {
                        // open pack file
                        $packFileRes = fopen($packFile, 'rb');
                        if ($packFileRes === false) {
                Severity: Minor
                Found in src/Git.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 null;
                Severity: Major
                Found in src/Git.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return true;
                  Severity: Major
                  Found in src/Git.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return null;
                    Severity: Major
                    Found in src/Git.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return [null, null];
                      Severity: Major
                      Found in src/Git.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return [$hash, $branch];
                        Severity: Major
                        Found in src/Git.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return false;
                          Severity: Major
                          Found in src/Git.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return false;
                            Severity: Major
                            Found in src/Git.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                      return [
                                          'hash' => $hash,
                                          'branch' => $branch,
                                          'message' => $message,
                                          'author' => $author,
                              Severity: Major
                              Found in src/Git.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                        return $packOffsets[1];
                                Severity: Major
                                Found in src/Git.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                          return $commit;
                                  Severity: Major
                                  Found in src/Git.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return null;
                                    Severity: Major
                                    Found in src/Git.php - About 30 mins to fix

                                      There are no issues that match your filters.

                                      Category
                                      Status