biurad/flange

View on GitHub
src/Commands/ServerCommand.php

Summary

Maintainability
D
2 days
Test Coverage

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

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);

        if (!$this->debug) {
Severity: Minor
Found in src/Commands/ServerCommand.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 runBlockingServer has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private function runBlockingServer(SymfonyStyle $io, InputInterface $input, OutputInterface $output): int
    {
        $callback = null;
        $disableOutput = false;

Severity: Minor
Found in src/Commands/ServerCommand.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

File ServerCommand.php has 281 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

/*
 * This file is part of Biurad opensource projects.
 *
Severity: Minor
Found in src/Commands/ServerCommand.php - About 2 hrs to fix

    Method execute has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function execute(InputInterface $input, OutputInterface $output): int
        {
            $io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);
    
            if (!$this->debug) {
    Severity: Major
    Found in src/Commands/ServerCommand.php - About 2 hrs to fix

      Method runBlockingServer has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function runBlockingServer(SymfonyStyle $io, InputInterface $input, OutputInterface $output): int
          {
              $callback = null;
              $disableOutput = false;
      
      
      Severity: Minor
      Found in src/Commands/ServerCommand.php - About 1 hr to fix

        Method configure has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function configure(): void
            {
                $this
                    ->setDefinition([
                        new InputArgument('addressport', InputArgument::OPTIONAL, 'The address to listen to (can be address:port, address, or port)'),
        Severity: Minor
        Found in src/Commands/ServerCommand.php - About 1 hr to fix

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

              public function start(string $pidFile)
              {
                  $pid = pcntl_fork();
          
                  if ($pid < 0) {
          Severity: Minor
          Found in src/Commands/ServerCommand.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 self::SUCCESS;
          Severity: Major
          Found in src/Commands/ServerCommand.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return $this->runBlockingServer($io, $input, $output);
            Severity: Major
            Found in src/Commands/ServerCommand.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return 1;
              Severity: Major
              Found in src/Commands/ServerCommand.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return 1;
                Severity: Major
                Found in src/Commands/ServerCommand.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return 1;
                  Severity: Major
                  Found in src/Commands/ServerCommand.php - About 30 mins to fix

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

                        private function findServerAddress(?string $address): string
                        {
                            if (null === $address) {
                                $this->hostname = '127.0.0.1';
                                $this->port = $this->findBestPort();
                    Severity: Minor
                    Found in src/Commands/ServerCommand.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

                    There are no issues that match your filters.

                    Category
                    Status