bnomei/kirby-nitro

View on GitHub

Showing 6 of 6 total issues

Function modelIndex has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function modelIndex(): int
    {
        $count = 0;
        foreach (site()->index(true) as $page) {
            /** @var NitroPage $page */
Severity: Minor
Found in classes/Nitro.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 patchDirClass has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function patchDirClass(): bool
    {
        $patch = $this->cacheDir().'/dir-inventory.'.App::versionHash().'.patch';
        if (file_exists($patch)) {
            return false;
Severity: Minor
Found in classes/Nitro/DirInventory.php - About 1 hr to fix

    Function atomic has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private function atomic(): bool
        {
            if (! $this->options['atomic']) {
                return false;
            }
    Severity: Minor
    Found in classes/Nitro/SingleFileCache.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

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

        public function patchFilesClass(): bool
        {
            if (option('bnomei.nitro.patch-files-class') !== true) {
                return false;
            }
    Severity: Minor
    Found in classes/Nitro.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

    Function write has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function write(bool $lock = true): bool
        {
            // if is atomic but has no file, don't write
            // this might happen if other request force unlocked the cache
            if ($this->options['atomic'] && ! F::exists($this->file().'.lock')) {
    Severity: Minor
    Found in classes/Nitro/SingleFileCache.php - About 25 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

    Function patchDirClass has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function patchDirClass(): bool
        {
            $patch = $this->cacheDir().'/dir-inventory.'.App::versionHash().'.patch';
            if (file_exists($patch)) {
                return false;
    Severity: Minor
    Found in classes/Nitro/DirInventory.php - About 25 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

    Severity
    Category
    Status
    Source
    Language