bnomei/kirby3-janitor

View on GitHub

Showing 9 of 13 total issues

Method run has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function run(CLI $cli): void
    {
        $time = time();
        $kirby = $cli->kirby();

Severity: Major
Found in commands/render.php - About 2 hrs to fix

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

        private function getPageIDs(CLI $cli): array
        {
            $query = $cli->arg('query');
            $page = ! empty($cli->arg('page')) ? page($cli->arg('page')) : null;
            $ids = [];
    Severity: Minor
    Found in commands/render.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 run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function run(CLI $cli): void
        {
            $time = time();
            $kirby = $cli->kirby();
    
    
    Severity: Minor
    Found in commands/render.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 cleanUp has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function cleanUp(CLI $cli, Kirby\Cms\Pages $collection, ?array $ignore = null, ?string $lang = null): int
        {
            $updated = 0;
            foreach ($collection as $item) {
                // get all fields in the content file
    Severity: Minor
    Found in commands/cleancontent.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 cleanUp has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function cleanUp(CLI $cli, Kirby\Cms\Pages $collection, ?array $ignore = null, ?string $lang = null): int
        {
            $updated = 0;
            foreach ($collection as $item) {
                // get all fields in the content file
    Severity: Minor
    Found in commands/cleancontent.php - About 1 hr to fix

      Method getPageIDs has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function getPageIDs(CLI $cli): array
          {
              $query = $cli->arg('query');
              $page = ! empty($cli->arg('page')) ? page($cli->arg('page')) : null;
              $ids = [];
      Severity: Minor
      Found in commands/render.php - About 1 hr to fix

        Function resolveModel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function resolveModel(string $uuid): mixed
            {
                if (Str::startsWith($uuid, 'page://')) {
                    return kirby()->page($uuid);
                } elseif (Str::startsWith($uuid, 'file://')) {
        Severity: Minor
        Found in classes/Janitor.php - About 45 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

        Avoid too many return statements within this method.
        Open

                        return $model;
        Severity: Major
        Found in classes/Janitor.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return null;
          Severity: Major
          Found in classes/Janitor.php - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language