deployphp/deployer

View on GitHub

Showing 189 of 189 total issues

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

function colorize_host(string $alias): string
{
    if (defined('NO_ANSI')) {
        return $alias;
    }
Severity: Major
Found in src/Support/helpers.php - About 3 hrs to fix

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

        public function __construct(Application $console)
        {
            parent::__construct();
    
            /******************************
    Severity: Major
    Found in src/Deployer.php - About 3 hrs to fix

      Function compareIdentifiers has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function compareIdentifiers(array $left, array $right)
          {
              if ($left && empty($right)) {
                  return self::LESS_THAN;
              } elseif (empty($left) && $right) {
      Severity: Minor
      Found in src/Component/PharUpdate/Version/Comparator.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

      Function parse has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public function parse(string $source): void
          {
              $comment = '';
              $params = '';
      
      
      Severity: Minor
      Found in src/Documentation/ApiGen.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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      task('provision:mariadb', function () {
          run('apt-get install -y mariadb-server', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]);
          run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'0.0.0.0' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]);
          run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'%' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]);
          run("mysql --user=\"root\" -e \"GRANT ALL PRIVILEGES ON *.* TO '{{db_user}}'@'0.0.0.0' WITH GRANT OPTION;\"");
      Severity: Major
      Found in recipe/provision/databases.php and 1 other location - About 2 hrs to fix
      recipe/provision/databases.php on lines 40..48

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 139.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      task('provision:mysql', function () {
          run('apt-get install -y mysql-server', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]);
          run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'0.0.0.0' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]);
          run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'%' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]);
          run("mysql --user=\"root\" -e \"GRANT ALL PRIVILEGES ON *.* TO '{{db_user}}'@'0.0.0.0' WITH GRANT OPTION;\"");
      Severity: Major
      Found in recipe/provision/databases.php and 1 other location - About 2 hrs to fix
      recipe/provision/databases.php on lines 51..59

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 139.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

          public function run(array $tasks, array $hosts, ?Planner $plan = null): int
          {
              $globalLimit = (int) $this->input->getOption('limit') ?: count($hosts);
      
              foreach ($tasks as $task) {
      Severity: Major
      Found in src/Executor/Master.php - About 2 hrs to fix

        Function collect has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function collect(InputInterface $input, OutputInterface $output): array
            {
                $arguments = [];
                foreach ($input->getOptions() as $name => $value) {
                    if (!$input->getOption($name)) {
        Severity: Minor
        Found in src/Ssh/IOArguments.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 runTask has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function runTask(Task $task, array $hosts): int
            {
                if (getenv('DEPLOYER_LOCAL_WORKER') === 'true') {
                    // This allows to code coverage all recipe,
                    // as well as speedup tests by not spawning
        Severity: Major
        Found in src/Executor/Master.php - About 2 hrs to fix

          Function createTreeFromTaskName has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              private function createTreeFromTaskName(string $taskName, string $postfix = '', bool $isLast = false)
              {
                  $task = $this->deployer->tasks->get($taskName);
          
                  if (!$task->isEnabled()) {
          Severity: Minor
          Found in src/Command/TreeCommand.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

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          task('yammer:notify:success', function () {
              $params = [
                  'is_rich_text' => 'true',
                  'message_type' => 'announcement',
                  'group_id' => get('yammer_group_id'),
          Severity: Major
          Found in contrib/yammer.php and 2 other locations - About 2 hrs to fix
          contrib/yammer.php on lines 68..84
          contrib/yammer.php on lines 106..122

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 132.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          task('yammer:notify', function () {
              $params = [
                  'is_rich_text' => 'true',
                  'message_type' => 'announcement',
                  'group_id' => get('yammer_group_id'),
          Severity: Major
          Found in contrib/yammer.php and 2 other locations - About 2 hrs to fix
          contrib/yammer.php on lines 87..103
          contrib/yammer.php on lines 106..122

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 132.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          task('yammer:notify:failure', function () {
              $params = [
                  'is_rich_text' => 'true',
                  'message_type' => 'announcement',
                  'group_id' => get('yammer_group_id'),
          Severity: Major
          Found in contrib/yammer.php and 2 other locations - About 2 hrs to fix
          contrib/yammer.php on lines 68..84
          contrib/yammer.php on lines 87..103

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 132.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

              public function getTasks(string $name, ?string $startFrom = null, array &$skipped = []): array
              {
                  $tasks = [];
                  $this->visitedTasks = [];
                  $allTasks = $this->doGetTasks($name);
          Severity: Minor
          Found in src/Task/ScriptManager.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

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

              public static function handValue(array $hand): int
              {
                  $aces = 0;
                  $value = 0;
                  foreach ($hand as [$rank]) {
          Severity: Minor
          Found in src/Command/BlackjackCommand.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

          Function colorize_host has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          function colorize_host(string $alias): string
          {
              if (defined('NO_ANSI')) {
                  return $alias;
              }
          Severity: Minor
          Found in src/Support/helpers.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

          Function doGetTasks has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public function doGetTasks(string $name): array
              {
                  if (array_key_exists($name, $this->visitedTasks)) {
                      if ($this->visitedTasks[$name] >= 100) {
                          throw new Exception("Looks like a circular dependency with \"$name\" task.");
          Severity: Minor
          Found in src/Task/ScriptManager.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 run has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function run(Host $host, string $command, array $config = []): string
              {
                  $defaults = [
                      'timeout' => $host->get('default_timeout', 300),
                      'idle_timeout' => null,
          Severity: Major
          Found in src/Ssh/SshClient.php - About 2 hrs to fix

            File Deployer.php has 258 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            declare(strict_types=1);
            
            /* (c) Anton Medvedev <anton@medv.io>
            Severity: Minor
            Found in src/Deployer.php - About 2 hrs to fix

              Method handValue has 54 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function handValue(array $hand): int
                  {
                      $aces = 0;
                      $value = 0;
                      foreach ($hand as [$rank]) {
              Severity: Major
              Found in src/Command/BlackjackCommand.php - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language