bnomei/kirby3-storybook

View on GitHub
classes/Storybook.php

Summary

Maintainability
C
1 day
Test Coverage

Function generateStorybookFiles has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function generateStorybookFiles(string $root, string $key, string $filepath): bool
    {
        $outputFolder = $this->option('storybook_folder');
        if (empty($outputFolder) || !Dir::exists($outputFolder)) {
            throw new \Exception('Storybook folder was not found.');
Severity: Minor
Found in classes/Storybook.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 generateStorybookFiles has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function generateStorybookFiles(string $root, string $key, string $filepath): bool
    {
        $outputFolder = $this->option('storybook_folder');
        if (empty($outputFolder) || !Dir::exists($outputFolder)) {
            throw new \Exception('Storybook folder was not found.');
Severity: Major
Found in classes/Storybook.php - About 2 hrs to fix

    File Storybook.php has 253 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      Method findPHPFiles has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function findPHPFiles(string $extension): array
          {
              $inRoot = [];
              $finder = new Finder();
              $finder->files()->in(kirby()->root($extension))->name('*.php');
      Severity: Minor
      Found in classes/Storybook.php - About 1 hr to fix

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

            public function loadData(array $data, string $filepath): array
            {
                // if filepath is not a path but just the name try to find the file
                if (!F::exists($filepath)) {
                    $filepath = $this->snippetFileFromName($filepath);
        Severity: Minor
        Found in classes/Storybook.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 loadData has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function loadData(array $data, string $filepath): array
            {
                // if filepath is not a path but just the name try to find the file
                if (!F::exists($filepath)) {
                    $filepath = $this->snippetFileFromName($filepath);
        Severity: Minor
        Found in classes/Storybook.php - About 1 hr to fix

          Function findPHPFiles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              private function findPHPFiles(string $extension): array
              {
                  $inRoot = [];
                  $finder = new Finder();
                  $finder->files()->in(kirby()->root($extension))->name('*.php');
          Severity: Minor
          Found in classes/Storybook.php - About 35 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