studioespresso/craft-seo-fields

View on GitHub
src/controllers/NotFoundController.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid unused local variables such as '$handled'.
Open

        $handled = "all";

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

Return type of actionClearAll() is undeclared type \yii\web\Response
Open

    public function actionClearAll()
Severity: Minor
Found in src/controllers/NotFoundController.php by phan

Reference to static property app from undeclared class \Craft
Open

        if (Craft::$app->getRequest()->getParam('redirect')) {
Severity: Critical
Found in src/controllers/NotFoundController.php by phan

Call to undeclared method \studioespresso\seofields\controllers\NotFoundController::asJson
Open

            return $this->asJson(['success' => true]);
Severity: Critical
Found in src/controllers/NotFoundController.php by phan

Call to undeclared method \studioespresso\seofields\controllers\NotFoundController::renderTemplate
Open

        return $this->renderTemplate('seo-fields/_notfound/_index');
Severity: Critical
Found in src/controllers/NotFoundController.php by phan

Reference to static property app from undeclared class \Craft
Open

            if (Craft::$app->getRequest()->getParam('redirect') === "handled") {
Severity: Critical
Found in src/controllers/NotFoundController.php by phan

Reference to undeclared property \studioespresso\seofields\controllers\NotFoundController->request (Did you mean $_REQUEST)
Open

        $id = $this->request->getBodyParam('id');
Severity: Minor
Found in src/controllers/NotFoundController.php by phan

Call to method getInstance from undeclared class \studioespresso\seofields\SeoFields
Open

        SeoFields::getInstance()->notFoundService->deleteAll();
Severity: Critical
Found in src/controllers/NotFoundController.php by phan

Reference to static property app from undeclared class \Craft
Open

            Craft::$app->getSession()->setNotice(Craft::t('seo-fields', '404 removed'));
Severity: Critical
Found in src/controllers/NotFoundController.php by phan

Call to method cpUrl from undeclared class \craft\helpers\UrlHelper
Open

        return $this->redirect(UrlHelper::cpUrl('seo-fields/not-found'));
Severity: Critical
Found in src/controllers/NotFoundController.php by phan

Class extends undeclared class \craft\web\Controller
Open

class NotFoundController extends Controller
Severity: Critical
Found in src/controllers/NotFoundController.php by phan

Return type of actionIndex() is undeclared type \yii\web\Response
Open

    public function actionIndex($siteHandle = null)
Severity: Minor
Found in src/controllers/NotFoundController.php by phan

Saw an @param annotation for id, but the param list of function actionDelete() is empty
Open

     * @param $id

Call to method getInstance from undeclared class \studioespresso\seofields\SeoFields
Open

        if (SeoFields::getInstance()->notFoundService->deletetById($id)) {
Severity: Critical
Found in src/controllers/NotFoundController.php by phan

Reference to static property app from undeclared class \Craft
Open

            $site = Craft::$app->getSites()->getSiteByHandle($siteHandle);
Severity: Critical
Found in src/controllers/NotFoundController.php by phan

Reference to static property app from undeclared class \Craft
Open

            } elseif (Craft::$app->getRequest()->getParam('redirect') === "not-handled") {
Severity: Critical
Found in src/controllers/NotFoundController.php by phan

Reference to static property app from undeclared class \Craft
Open

            Craft::$app->getSites()->setCurrentSite($site);
Severity: Critical
Found in src/controllers/NotFoundController.php by phan

Call to undeclared method \studioespresso\seofields\controllers\NotFoundController::redirect
Open

        return $this->redirect(UrlHelper::cpUrl('seo-fields/not-found'));
Severity: Critical
Found in src/controllers/NotFoundController.php by phan

@throws type of actionDelete has undeclared type \craft\errors\MissingComponentException
Open

    public function actionDelete()
Severity: Minor
Found in src/controllers/NotFoundController.php by phan

Call to method t from undeclared class \Craft
Open

            Craft::$app->getSession()->setNotice(Craft::t('seo-fields', '404 removed'));
Severity: Critical
Found in src/controllers/NotFoundController.php by phan

Avoid using static access to class '\Craft' in method 'actionDelete'.
Open

            Craft::$app->getSession()->setNotice(Craft::t('seo-fields', '404 removed'));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\craft\helpers\UrlHelper' in method 'actionClearAll'.
Open

        return $this->redirect(UrlHelper::cpUrl('seo-fields/not-found'));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

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

        if (Craft::$app->getRequest()->getParam('redirect')) {

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

        $id = $this->request->getBodyParam('id');

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