bnomei/autoloader-for-kirby

View on GitHub

Showing 6 of 6 total issues

Function registry has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

    private function registry(string $type): array
    {
        // only register once
        if (array_key_exists($type, $this->registry)) {
            return $this->registry[$type];
Severity: Minor
Found in classes/Autoloader.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 registry has 125 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function registry(string $type): array
    {
        // only register once
        if (array_key_exists($type, $this->registry)) {
            return $this->registry[$type];
Severity: Major
Found in classes/Autoloader.php - About 5 hrs to fix

    File Autoloader.php has 369 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    declare(strict_types=1);
    
    namespace Bnomei;
    Severity: Minor
    Found in classes/Autoloader.php - About 4 hrs to fix

      Method __construct has 102 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __construct(array $options = [])
          {
              $this->options = array_merge_recursive([
                  // we can not read the kirby options since we are loading
                  // while kirby is booting, but once spyc is removed we can
      Severity: Major
      Found in classes/Autoloader.php - About 4 hrs to fix

        Consider simplifying this complex logical expression.
        Open

                    if ($options['key'] === 'classname') {
                        $this->registry[$type][$key] = $class;
                    } elseif ($options['key'] === 'route') {
                        // Author: @tobimori
                        $pattern = strtolower($file->getRelativePathname());
        Severity: Critical
        Found in classes/Autoloader.php - About 1 hr to fix

          Avoid too many return statements within this method.
          Open

                  return $this->registry[$type];
          Severity: Major
          Found in classes/Autoloader.php - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language