rhopress/yii2-rhopress

View on GitHub

Showing 158 of 158 total issues

Expected 1 blank line at end of file; 2 found
Open

 */
Severity: Minor
Found in views/user/new.php by phpcodesniffer

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

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

    public static function getArticle($id, $throwExceptionIfNull = true)
    {
        if (is_numeric($id)) {
            $article = Article::find()->id($id)->one();
            if ($article) {
Severity: Minor
Found in controllers/ArticleController.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

Blank line found at start of control structure
Open

        if (!$comment->save()) {

The method getComment has a boolean flag argument $throwExceptionIfNull, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function getComment($id, $cid, $throwExceptionIfNull = true)
Severity: Minor
Found in controllers/CommentController.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

The method title has a boolean flag argument $like, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function title($title, $like = false)
Severity: Minor
Found in models/ArticleQuery.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

Missing class import via use statement (line '100', column '27').
Open

                throw new \yii\base\NotSupportedException('Not recognized account type.');
Severity: Minor
Found in models/LoginForm.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '91', column '23').
Open

            throw new \yii\web\ForbiddenHttpException('Delete Denied.');
Severity: Minor
Found in controllers/ArticleController.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '130', column '23').
Open

            throw new \yii\web\NotFoundHttpException(static::t('Article Not Found.'));
Severity: Minor
Found in controllers/ArticleController.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

The method name has a boolean flag argument $like, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function name($name, $like = false)
Severity: Minor
Found in models/ArticleQuery.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

The method getArticle has a boolean flag argument $throwExceptionIfNull, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function getArticle($id, $throwExceptionIfNull = true)
Severity: Minor
Found in controllers/ArticleController.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

Missing class import via use statement (line '94', column '23').
Open

            throw new \yii\web\BadRequestHttpException('Article Delete Failed.');
Severity: Minor
Found in controllers/ArticleController.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '78', column '23').
Open

            throw new \yii\web\ForbiddenHttpException('Delete Denied.');
Severity: Minor
Found in controllers/CommentController.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '106', column '31').
Open

        $emailValidator = new \yii\validators\EmailValidator();
Severity: Minor
Found in models/LoginForm.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '113', column '23').
Open

            throw new \yii\web\NotFoundHttpException(static::t('Comment Not Found.'));
Severity: Minor
Found in controllers/CommentController.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Avoid using static access to class 'rhopress\models\CommentQuery' in method 'init'.
Open

        $this->queryClass = CommentQuery::className();
Severity: Minor
Found in models/Comment.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 'rhopress\models\Yii' in method 'attributeLabels'.
Open

            'update_time' => Yii::t('app', 'Update Time'),
Severity: Minor
Found in models/Email.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' in method 'attributeLabels'.
Open

            'username' => Yii::t('app', 'Username'),
Severity: Minor
Found in models/LoginForm.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 'rhopress\models\User' in method 'getUser'.
Open

        return $this->hasOne(User::className(), [$user->guidAttribute => $this->createdByAttribute]);
Severity: Minor
Found in models/Post.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 'rhopress\models\Yii' in method 'attributeLabels'.
Open

            'individual_sign' => Yii::t('app', 'Individual Sign'),
Severity: Minor
Found in models/Profile.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

Severity
Category
Status
Source
Language