AJenbo/agcms

View on GitHub
application/inc/Http/Controllers/Admin/SiteTreeController.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

Method inventory has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function inventory(Request $request): Response
    {
        app(DbService::class)->addLoadedTable('bind', 'kat', 'krav', 'maerke', 'sider');
        $response = $this->cachedResponse();
        if ($response->isNotModified($request)) {
Severity: Minor
Found in application/inc/Http/Controllers/Admin/SiteTreeController.php - About 1 hr to fix

    Avoid unused parameters such as '$request'.
    Open

        public function lable(Request $request, int $id): JsonResponse

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    Define a constant instead of duplicating this literal "intval" 3 times.
    Open

            $openCategories = array_map('intval', $openCategories);

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "openkat" 3 times.
    Open

            $openCategories = explode('<', strval($request->cookies->get('openkat', '')));

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

        public function lable(Request $request, int $id): JsonResponse

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    There are no issues that match your filters.

    Category
    Status