deployphp/deployer

View on GitHub
src/functions.php

Summary

Maintainability
D
2 days
Test Coverage

File functions.php has 540 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

/* (c) Anton Medvedev <anton@medv.io>
Severity: Major
Found in src/functions.php - About 1 day to fix

    Method run has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function run(string $command, ?array $options = [], ?int $timeout = null, ?int $idle_timeout = null, ?string $secret = null, ?array $env = null, ?bool $real_time_output = false, ?bool $no_throw = false): string
    {
        $namedArguments = [];
        foreach (['timeout', 'idle_timeout', 'secret', 'env', 'real_time_output', 'no_throw'] as $arg) {
            if ($$arg !== null) {
    Severity: Major
    Found in src/functions.php - About 2 hrs to fix

      Function run has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      function run(string $command, ?array $options = [], ?int $timeout = null, ?int $idle_timeout = null, ?string $secret = null, ?array $env = null, ?bool $real_time_output = false, ?bool $no_throw = false): string
      {
          $namedArguments = [];
          foreach (['timeout', 'idle_timeout', 'secret', 'env', 'real_time_output', 'no_throw'] as $arg) {
              if ($$arg !== null) {
      Severity: Minor
      Found in src/functions.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

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

      function task(string $name, $body = null): Task
      {
          $deployer = Deployer::get();
      
          if (empty($body)) {
      Severity: Minor
      Found in src/functions.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 task has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function task(string $name, $body = null): Task
      {
          $deployer = Deployer::get();
      
          if (empty($body)) {
      Severity: Minor
      Found in src/functions.php - About 1 hr to fix

        Function on has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function on($hosts, callable $callback): void
        {
            if (!is_array($hosts) && !($hosts instanceof \Traversable)) {
                $hosts = [$hosts];
            }
        Severity: Minor
        Found in src/functions.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 askChoice has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function askChoice(string $message, array $availableChoices, $default = null, bool $multiselect = false)
        {
            if (defined('DEPLOYER_NO_ASK')) {
                throw new WillAskUser($message);
            }
        Severity: Minor
        Found in src/functions.php - About 1 hr to fix

          Method run has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function run(string $command, ?array $options = [], ?int $timeout = null, ?int $idle_timeout = null, ?string $secret = null, ?array $env = null, ?bool $real_time_output = false, ?bool $no_throw = false): string
          Severity: Major
          Found in src/functions.php - About 1 hr to fix

            Method runLocally has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function runLocally(string $command, ?array $options = [], ?int $timeout = null, ?int $idle_timeout = null, ?string $secret = null, ?array $env = null, ?string $shell = null): string
            Severity: Major
            Found in src/functions.php - About 50 mins to fix

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

              function fetch(string $url, string $method = 'get', array $headers = [], ?string $body = null, ?array &$info = null, bool $nothrow = false): string
              Severity: Minor
              Found in src/functions.php - About 45 mins to fix

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

                function askChoice(string $message, array $availableChoices, $default = null, bool $multiselect = false)
                {
                    if (defined('DEPLOYER_NO_ASK')) {
                        throw new WillAskUser($message);
                    }
                Severity: Minor
                Found in src/functions.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

                Method option has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function option(string $name, $shortcut = null, ?int $mode = null, string $description = '', $default = null): void
                Severity: Minor
                Found in src/functions.php - About 35 mins to fix

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

                  function host(string ...$hostname)
                  {
                      $deployer = Deployer::get();
                      if (count($hostname) === 1 && $deployer->hosts->has($hostname[0])) {
                          return $deployer->hosts->get($hostname[0]);
                  Severity: Minor
                  Found in src/functions.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

                  There are no issues that match your filters.

                  Category
                  Status