knot-php/command

View on GitHub

Showing 20 of 20 total issues

Method dispatch has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function dispatch(string $path, array $vars, string $route_name) : void
    {
        global $argv;

        $logger = $this->getLogger();
Severity: Major
Found in src/App/Dispatcher/CommandDispatcher.php - About 3 hrs to fix

    Method install has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function install(ApplicationInterface $app)
        {
            try{
                $c = $app->di();
    
    
    Severity: Minor
    Found in src/App/Module/CommandDiModule.php - About 1 hr to fix

      Method executeCommand has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function executeCommand(DiContainerInterface $di, string $command_id, int $skip_args) : int
          {
              $this->command_db->load();
              $this->alias_db->load();
      
      
      Severity: Minor
      Found in src/Service/CommandExecService.php - About 1 hr to fix

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

            public function load() : bool
            {
                $this->command_db = [];
        
                if (!file_exists($this->command_db_file)){
        Severity: Minor
        Found in src/Service/CommandDbFileService.php - About 1 hr to fix

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

              private static function validateCommandDescriptor(array $descriptor, string $descriptor_file)
              {
                  $command_id          = $descriptor['command_id'] ?? '';
                  $class_root          = $descriptor['class_root'] ?? '';             // i.e: /root/to/my/command
                  $class_name          = $descriptor['class_name'] ?? '';             // i.e: MyPackage.MyCommand
          Severity: Minor
          Found in src/Service/CommandDescriptorService.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 dispatch has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function dispatch(string $path, array $vars, string $route_name) : void
              {
                  global $argv;
          
                  $logger = $this->getLogger();
          Severity: Minor
          Found in src/App/Dispatcher/CommandDispatcher.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 execute has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function execute(array $args, ConsoleIOInterface $io): int
              {
                  $io->output('cmd: ' . self::getCommandId())->eol();
          
                  $app_class= $args['app_class'] ?? '';
          Severity: Minor
          Found in src/Command/Acme/ModuleDependencyExplainComand.php - About 1 hr to fix

            Method installCommand has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function installCommand(CommandDescriptorService $desc_s, CommandDbFileService $command_db, AliasDbFileService $alias_db, string $command_id)
                {
                    try{
                        $this->io->output(self::CONSOLE_SEPARATOR)->eol();
            
            
            Severity: Minor
            Found in src/App/Responder/CommandCommandResponder.php - About 1 hr to fix

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

                  public function executeCommand(DiContainerInterface $di, string $command_id, int $skip_args) : int
                  {
                      $this->command_db->load();
                      $this->alias_db->load();
              
              
              Severity: Minor
              Found in src/Service/CommandExecService.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 showCommandHelp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function showCommandHelp(CommandDescriptor $desc, bool $show_separatpr)
                  {
                      $command_help = $desc->getCommandHelp();
              
                      if (is_array($command_help)){
              Severity: Minor
              Found in src/App/Responder/CommandCommandResponder.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 __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      FileSystemInterface $fs,
                      ApplicationInterface $app,
                      CommandDbFileService $command_db,
                      AliasDbFileService $alias_db,
                      ConsoleIOInterface $io)
              Severity: Minor
              Found in src/Service/CommandExecService.php - About 35 mins to fix

                Avoid too many return statements within this method.
                Open

                                return new CommandAutoloadService($fs, $db_file);
                Severity: Major
                Found in src/App/Module/CommandDiModule.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return new SystemService();
                  Severity: Major
                  Found in src/App/Module/CommandDiModule.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return new CommandDbFileService($fs);
                    Severity: Major
                    Found in src/App/Module/CommandDiModule.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return new CommandDescriptorService($fs);
                      Severity: Major
                      Found in src/App/Module/CommandDiModule.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return new CommandExecService($fs, $app, $command_db, $alias_db, $io);
                        Severity: Major
                        Found in src/App/Module/CommandDiModule.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return new AliasDbFileService($fs);
                          Severity: Major
                          Found in src/App/Module/CommandDiModule.php - About 30 mins to fix

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

                                private function getArgs(array $ordered_args, array $named_args, int $skip_args) : array
                                {
                                    $request = $this->app->request();
                                    $seq_params = array_filter($request->getServerParams(), function($value, $key){
                                        return is_int($key);
                            Severity: Minor
                            Found in src/Service/CommandExecService.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

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

                                public function installCommand(CommandDescriptorService $desc_s, CommandDbFileService $command_db, AliasDbFileService $alias_db, string $command_id)
                                {
                                    try{
                                        $this->io->output(self::CONSOLE_SEPARATOR)->eol();
                            
                            
                            Severity: Minor
                            Found in src/App/Responder/CommandCommandResponder.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

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

                                public function helpCommand(CommandDescriptorService $desc_s, string $command_id)
                                {
                                    try{
                                        $this->io->output(str_pad('ID', 25) . 'COMMAND LINE')->eol();
                            
                            
                            Severity: Minor
                            Found in src/App/Responder/CommandCommandResponder.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

                            Severity
                            Category
                            Status
                            Source
                            Language