hnhdigital-os/laravel-console-self-update

View on GitHub

Showing 10 of 16 total issues

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

    public function readDownloadPath($tag)
    {
        if (($version_data = $this->readJson($this->getVersionsPath())) === false) {
            return false;
        }
Severity: Minor
Found in src/SelfUpdateTrait.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

Avoid too many return statements within this method.
Open

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

    Missing class import via use statement (line '577', column '23').
    Open

                throw new \Exception('');
    Severity: Minor
    Found in src/SelfUpdateTrait.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Avoid too many return statements within this method.
    Open

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

      Avoid assigning values to variables in if clauses and the like (line '537', column '14').
      Open

          private function processUpdate()
          {
              $current_binary_path = $this->getCurrentBinaryFilePath();
              $temp_binary_path = $this->getTempPath($current_binary_path, $this->getLatestTag());
      
      
      Severity: Minor
      Found in src/SelfUpdateTrait.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

      Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

      Avoid assigning values to variables in if clauses and the like (line '469', column '14').
      Open

          protected function checkVersion()
          {
              if (!$this->use_flysystem) {
                  $this->line('Source: <info>'.$this->getUrl().'</info>');
              }
      Severity: Minor
      Found in src/SelfUpdateTrait.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

      Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

      Avoid assigning values to variables in if clauses and the like (line '707', column '18').
      Open

          private function readUpdatedBinaryHash($path)
          {
              // Top level json encoded file.
              if ($this->getHashSource() === self::CHECKSUM_TOP_LEVEL) {
                  if (($checksums = $this->readJson($this->getHashPath())) === false) {
      Severity: Minor
      Found in src/SelfUpdateTrait.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

      Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

      Avoid assigning values to variables in if clauses and the like (line '485', column '14').
      Open

          public function readLatestTag()
          {
              if (($latest_tag = $this->readFile($this->getLatestTagPath())) === false) {
                  return false;
              }
      Severity: Minor
      Found in src/SelfUpdateTrait.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

      Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

      Avoid assigning values to variables in if clauses and the like (line '505', column '14').
      Open

          private function processUpdate()
          {
              $current_binary_path = $this->getCurrentBinaryFilePath();
              $temp_binary_path = $this->getTempPath($current_binary_path, $this->getLatestTag());
      
      
      Severity: Minor
      Found in src/SelfUpdateTrait.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

      Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

      Avoid assigning values to variables in if clauses and the like (line '600', column '14').
      Open

          public function readDownloadPath($tag)
          {
              if (($version_data = $this->readJson($this->getVersionsPath())) === false) {
                  return false;
              }
      Severity: Minor
      Found in src/SelfUpdateTrait.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

      Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

      Severity
      Category
      Status
      Source
      Language