gboudreau/Greyhole

View on GitHub
includes/SambaSpool.php

Summary

Maintainability
F
3 days
Test Coverage

Function parse_samba_spool has a Cognitive Complexity of 111 (exceeds 5 allowed). Consider refactoring.
Open

    public static function parse_samba_spool() {
        Log::setAction(ACTION_READ_SAMBA_POOL);

        $db_spool = DBSpool::getInstance();

Severity: Minor
Found in includes/SambaSpool.php - About 2 days 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 parse_samba_spool has 197 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function parse_samba_spool() {
        Log::setAction(ACTION_READ_SAMBA_POOL);

        $db_spool = DBSpool::getInstance();

Severity: Major
Found in includes/SambaSpool.php - About 7 hrs to fix

    Function create_mem_spool has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function create_mem_spool() {
            $mounted_already = exec('mount | grep /var/spool/greyhole/mem | wc -l');
            if (!$mounted_already && file_exists('/var/spool/greyhole/mem')) {
                // In Docker, mount doesn't list mounts... need to check using df instead:
                exec("cat /proc/1/sched | grep supervisord", $output, $result);
    Severity: Minor
    Found in includes/SambaSpool.php - About 55 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 1;
    Severity: Major
    Found in includes/SambaSpool.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return 0;
      Severity: Major
      Found in includes/SambaSpool.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                                return -1;
        Severity: Major
        Found in includes/SambaSpool.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                              return $is_file1_write ? 1 : -1; // open before write
          Severity: Major
          Found in includes/SambaSpool.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                                return -1;
            Severity: Major
            Found in includes/SambaSpool.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                  return 0;
              Severity: Major
              Found in includes/SambaSpool.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return $is_file1_write ? -1 : 1; // close after write
                Severity: Major
                Found in includes/SambaSpool.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                      return 1;
                  Severity: Major
                  Found in includes/SambaSpool.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                        return 1;
                    Severity: Major
                    Found in includes/SambaSpool.php - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status