studioespresso/craft-seo-fields

View on GitHub
src/services/migrate/Ether.php

Summary

Maintainability
A
1 hr
Test Coverage

Method migrate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function migrate($oldHandle = 'seo', $newHandle = 'newSeo', $siteId = null, $titleSeperator = null)
    {
        $this->titleSeperator = $titleSeperator;
        $query = Entry::find();
        $sites = [];
Severity: Minor
Found in src/services/migrate/Ether.php - About 1 hr to fix

    Function migrate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function migrate($oldHandle = 'seo', $newHandle = 'newSeo', $siteId = null, $titleSeperator = null)
        {
            $this->titleSeperator = $titleSeperator;
            $query = Entry::find();
            $sites = [];
    Severity: Minor
    Found in src/services/migrate/Ether.php - About 35 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

    The method migrate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $sites = Craft::$app->getSites()->getAllSites();
            }
    Severity: Minor
    Found in src/services/migrate/Ether.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Avoid using static access to class '\yii\helpers\Console' in method 'migrate'.
    Open

                Console::startProgress(0, $total);
    Severity: Minor
    Found in src/services/migrate/Ether.php by phpmd

    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 '\yii\helpers\Console' in method 'migrate'.
    Open

                    Console::updateProgress($done, $total);
    Severity: Minor
    Found in src/services/migrate/Ether.php by phpmd

    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

    The method getMarkup uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                return !empty($string) ? $string : null;
            }
    Severity: Minor
    Found in src/services/migrate/Ether.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Avoid using static access to class '\yii\helpers\Console' in method 'migrate'.
    Open

                Console::endProgress();
    Severity: Minor
    Found in src/services/migrate/Ether.php by phpmd

    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\elements\Entry' in method 'migrate'.
    Open

            $query = Entry::find();
    Severity: Minor
    Found in src/services/migrate/Ether.php by phpmd

    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

    The method getTitle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $oldTitle = $this->getMarkup($data->getTitle());
            }
    Severity: Minor
    Found in src/services/migrate/Ether.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Reference to instance property title from undeclared class \craft\elements\Entry
    Open

                    echo "Error updating '$entry->title'";
    Severity: Minor
    Found in src/services/migrate/Ether.php by phan

    Reference to static property app from undeclared class \Craft
    Open

                $site = Craft::$app->getSites()->getSiteById($siteId);
    Severity: Critical
    Found in src/services/migrate/Ether.php by phan

    Parameter $data has undeclared type \ether\seo\models\data\SeoData
    Open

        private function getTitle(SeoData $data)
    Severity: Minor
    Found in src/services/migrate/Ether.php by phan

    Parameter $entry has undeclared type \craft\elements\Entry
    Open

        private function migrateContent(Entry $entry, $field, $newHandle)
    Severity: Minor
    Found in src/services/migrate/Ether.php by phan

    Call to method find from undeclared class \craft\elements\Entry
    Open

            $query = Entry::find();
    Severity: Critical
    Found in src/services/migrate/Ether.php by phan

    Reference to instance property titleRaw from undeclared class \ether\seo\models\data\SeoData
    Open

                $oldTitle = $data->titleRaw[1];
    Severity: Minor
    Found in src/services/migrate/Ether.php by phan

    Call to method getTitle from undeclared class \ether\seo\models\data\SeoData
    Open

                $oldTitle = $this->getMarkup($data->getTitle());
    Severity: Critical
    Found in src/services/migrate/Ether.php by phan

    Call to method __toString from undeclared class \Twig\Markup
    Open

                return !empty($string->__toString()) ? $string->__toString() : null;
    Severity: Critical
    Found in src/services/migrate/Ether.php by phan

    Reference to static property app from undeclared class \Craft
    Open

                if (!Craft::$app->getElements()->saveElement($entry)) {
    Severity: Critical
    Found in src/services/migrate/Ether.php by phan

    Checking instanceof against undeclared class \Twig\Markup
    Open

            if ($string instanceof Markup or (is_object($string) && get_class($string) == 'Twig\Markup')) {
    Severity: Critical
    Found in src/services/migrate/Ether.php by phan

    Call to method updateProgress from undeclared class \yii\helpers\Console
    Open

                    Console::updateProgress($done, $total);
    Severity: Critical
    Found in src/services/migrate/Ether.php by phan

    Call to method setFieldValue from undeclared class \craft\elements\Entry
    Open

                $entry->setFieldValue($newHandle, $newField);
    Severity: Critical
    Found in src/services/migrate/Ether.php by phan

    Possibly zero references to use statement for classlike/namespace SocialData (\ether\seo\models\data\SocialData)
    Open

    use ether\seo\models\data\SocialData;
    Severity: Minor
    Found in src/services/migrate/Ether.php by phan

    Call to method __construct from undeclared class \craft\errors\SiteNotFoundException
    Open

                    throw new SiteNotFoundException("Site with id '$siteId' not found.");
    Severity: Critical
    Found in src/services/migrate/Ether.php by phan

    Reference to static property app from undeclared class \Craft
    Open

                $sites = Craft::$app->getSites()->getAllSites();
    Severity: Critical
    Found in src/services/migrate/Ether.php by phan

    Call to method startProgress from undeclared class \yii\helpers\Console
    Open

                Console::startProgress(0, $total);
    Severity: Critical
    Found in src/services/migrate/Ether.php by phan

    Call to method endProgress from undeclared class \yii\helpers\Console
    Open

                Console::endProgress();
    Severity: Critical
    Found in src/services/migrate/Ether.php by phan

    Class extends undeclared class \craft\base\Component
    Open

    class Ether extends Component
    Severity: Critical
    Found in src/services/migrate/Ether.php by phan

    Reference to instance property titleRaw from undeclared class \ether\seo\models\data\SeoData
    Open

            if (count($data->titleRaw)) {
    Severity: Minor
    Found in src/services/migrate/Ether.php by phan

    There are no issues that match your filters.

    Category
    Status