gboudreau/Greyhole

View on GitHub
web-app/functions.inc.php

Summary

Maintainability
F
3 days
Test Coverage

Function get_config_html has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
Open

function get_config_html($config, $current_value = NULL, $fixed_width_label = TRUE) {
    $config = (object) $config;
    $html = '';
    if ($config->type == 'group') {
        $html .= "<div class='input_group mt-4'>";
Severity: Minor
Found in web-app/functions.inc.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 get_config_html has 161 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function get_config_html($config, $current_value = NULL, $fixed_width_label = TRUE) {
    $config = (object) $config;
    $html = '';
    if ($config->type == 'group') {
        $html .= "<div class='input_group mt-4'>";
Severity: Major
Found in web-app/functions.inc.php - About 6 hrs to fix

    File functions.inc.php has 374 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /*
    Copyright 2020 Guillaume Boudreau
    
    This file is part of Greyhole.
    Severity: Minor
    Found in web-app/functions.inc.php - About 5 hrs to fix

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

      function get_new_share_defaults($all_samba_shares) {
          // Default path for new share: find the most-used path in existing shares
          $prefixes = [];
          $prefix_shares = [];
          $options = [];
      Severity: Minor
      Found in web-app/functions.inc.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 get_new_share_defaults has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function get_new_share_defaults($all_samba_shares) {
          // Default path for new share: find the most-used path in existing shares
          $prefixes = [];
          $prefix_shares = [];
          $options = [];
      Severity: Minor
      Found in web-app/functions.inc.php - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status