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.');
- Read upRead up
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.');
File Storybook.php
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Bnomei;
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');
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);
- Read upRead up
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);
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');
- Read upRead up
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"