gboudreau/Greyhole

View on GitHub
includes/CLI/CommandLineHelper.php

Summary

Maintainability
F
3 days
Test Coverage

Function getopt has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getopt($short_options, $long_options) {
        $opts_no_value = array();
        $opts_required_value = array();
        $opts_optional_value = array();

Severity: Minor
Found in includes/CLI/CommandLineHelper.php - About 1 day 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 getopt has 93 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function getopt($short_options, $long_options) {
        $opts_no_value = array();
        $opts_required_value = array();
        $opts_optional_value = array();

Severity: Major
Found in includes/CLI/CommandLineHelper.php - About 3 hrs to fix

    File CommandLineHelper.php has 296 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /*
    Copyright 2009-2020 Guillaume Boudreau
    
    This file is part of Greyhole.
    Severity: Minor
    Found in includes/CLI/CommandLineHelper.php - About 3 hrs to fix

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

          private function getRunner() {
              if (empty($this->actionCmd) && basename(first($GLOBALS['argv'], '')) == 'cpgh') {
                  return new CopyCliRunner($this->options, $this->actionCmd);
              }
      
      
      Severity: Minor
      Found in includes/CLI/CommandLineHelper.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 __construct has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function __construct() {
              $this->cliCommandsDefinitions = array(
                  new CliCommandDefinition('help',             '?',   null,             null,                           "Display this help and exit."),
                  new CliCommandDefinition('daemon',           'D',   null,             DaemonRunner::class,            "Start the daemon."),
                  new CliCommandDefinition('pause',            'P',   null,             PauseCliRunner::class,          "Pause the daemon."),
      Severity: Minor
      Found in includes/CLI/CommandLineHelper.php - About 2 hrs to fix

        Method getRunner has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function getRunner() {
                if (empty($this->actionCmd) && basename(first($GLOBALS['argv'], '')) == 'cpgh') {
                    return new CopyCliRunner($this->options, $this->actionCmd);
                }
        
        
        Severity: Minor
        Found in includes/CLI/CommandLineHelper.php - About 1 hr to fix

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

              private function getActionCommand($command_line_options) {
                  foreach ($this->cliCommandsDefinitions as $def) {
                      $param = $def->paramSpecified($command_line_options);
                      if ($param !== FALSE) {
                          if ($param !== TRUE) {
          Severity: Minor
          Found in includes/CLI/CommandLineHelper.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