abhi1693/yii2-user

View on GitHub

Showing 14 of 14 total issues

Similar blocks of code found in 6 locations. Consider refactoring.
Open

            if (!empty($model->githubClientId) && !empty($model->githubClientSecret)) {
                Yii::$app->config->set(Enum::GITHUB_AUTH, GitHub::className());
                Yii::$app->config->set(Enum::GITHUB_CLIENT_ID, $model->githubClientId);
                Yii::$app->config->set(Enum::GITHUB_CLIENT_SECRET, $model->githubClientSecret);

Severity: Major
Found in controllers/SettingsController.php and 5 other locations - About 6 hrs to fix
controllers/SettingsController.php on lines 111..122
controllers/SettingsController.php on lines 124..135
controllers/SettingsController.php on lines 137..148
controllers/SettingsController.php on lines 164..175
controllers/SettingsController.php on lines 177..188

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 223.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

            if (!empty($model->twitterConsumerKey) && !empty($model->twitterConsumerSecret)) {
                Yii::$app->config->set(Enum::TWITTER_AUTH, Twitter::className());
                Yii::$app->config->set(Enum::TWITTER_CONSUMER_KEY, $model->twitterConsumerKey);
                Yii::$app->config->set(Enum::TWITTER_CONSUMER_SECRET, $model->twitterConsumerSecret);

Severity: Major
Found in controllers/SettingsController.php and 5 other locations - About 6 hrs to fix
controllers/SettingsController.php on lines 111..122
controllers/SettingsController.php on lines 124..135
controllers/SettingsController.php on lines 137..148
controllers/SettingsController.php on lines 150..161
controllers/SettingsController.php on lines 164..175

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 223.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

            if (!empty($model->googleClientId) && !empty($model->googleClientSecret)) {
                Yii::$app->config->set(Enum::GOOGLE_AUTH, GoogleOAuth::className());
                Yii::$app->config->set(Enum::GOOGLE_CLIENT_ID, $model->googleClientId);
                Yii::$app->config->set(Enum::GOOGLE_CLIENT_SECRET, $model->googleClientSecret);

Severity: Major
Found in controllers/SettingsController.php and 5 other locations - About 6 hrs to fix
controllers/SettingsController.php on lines 124..135
controllers/SettingsController.php on lines 137..148
controllers/SettingsController.php on lines 150..161
controllers/SettingsController.php on lines 164..175
controllers/SettingsController.php on lines 177..188

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 223.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

            if (!empty($model->liveClientId) && !empty($model->liveClientSecret)) {
                Yii::$app->config->set(Enum::LIVE_AUTH, Live::className());
                Yii::$app->config->set(Enum::LIVE_CLIENT_ID, $model->liveClientId);
                Yii::$app->config->set(Enum::LIVE_CLIENT_SECRET, $model->liveClientSecret);

Severity: Major
Found in controllers/SettingsController.php and 5 other locations - About 6 hrs to fix
controllers/SettingsController.php on lines 111..122
controllers/SettingsController.php on lines 124..135
controllers/SettingsController.php on lines 137..148
controllers/SettingsController.php on lines 150..161
controllers/SettingsController.php on lines 177..188

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 223.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

            if (!empty($model->facebookClientId) && !empty($model->facebookClientSecret)) {
                Yii::$app->config->set(Enum::FACEBOOK_AUTH, Facebook::className());
                Yii::$app->config->set(Enum::FACEBOOK_CLIENT_ID, $model->facebookClientId);
                Yii::$app->config->set(Enum::FACEBOOK_CLIENT_SECRET, $model->facebookClientSecret);

Severity: Major
Found in controllers/SettingsController.php and 5 other locations - About 6 hrs to fix
controllers/SettingsController.php on lines 111..122
controllers/SettingsController.php on lines 137..148
controllers/SettingsController.php on lines 150..161
controllers/SettingsController.php on lines 164..175
controllers/SettingsController.php on lines 177..188

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 223.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

            if (!empty($model->linkedInClientId) && !empty($model->linkedInClientSecret)) {
                Yii::$app->config->set(Enum::LINKED_IN_AUTH, LinkedIn::className());
                Yii::$app->config->set(Enum::LINKED_IN_CLIENT_ID, $model->linkedInClientId);
                Yii::$app->config->set(Enum::LINKED_IN_CLIENT_SECRET, $model->linkedInClientSecret);

Severity: Major
Found in controllers/SettingsController.php and 5 other locations - About 6 hrs to fix
controllers/SettingsController.php on lines 111..122
controllers/SettingsController.php on lines 124..135
controllers/SettingsController.php on lines 150..161
controllers/SettingsController.php on lines 164..175
controllers/SettingsController.php on lines 177..188

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 223.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method actionAuthClient has 98 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function actionAuthClient()
    {
        $model = new SettingsForm();
        $model->googleClientId = Yii::$app->config->get(Enum::GOOGLE_CLIENT_ID);
        $model->googleClientSecret = Yii::$app->config->get(Enum::GOOGLE_CLIENT_SECRET);
Severity: Major
Found in controllers/SettingsController.php - About 3 hrs to fix

Function actionAuthClient has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function actionAuthClient()
    {
        $model = new SettingsForm();
        $model->googleClientId = Yii::$app->config->get(Enum::GOOGLE_CLIENT_ID);
        $model->googleClientSecret = Yii::$app->config->get(Enum::GOOGLE_CLIENT_SECRET);
Severity: Minor
Found in controllers/SettingsController.php - About 2 hrs 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

User has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class User extends ActiveRecord
{
    /** User Status - Blocked/Inactive */
    const STATUS_BLOCKED = 0;
    /** User Status - Active */
Severity: Minor
Found in models/User.php - About 2 hrs to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
Severity: Minor
Found in controllers/RegistrationController.php and 1 other location - About 55 mins to fix
controllers/RecoveryController.php on lines 21..41

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 99.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
Severity: Minor
Found in controllers/RecoveryController.php and 1 other location - About 55 mins to fix
controllers/RegistrationController.php on lines 28..48

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 99.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function actionBlock has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function actionBlock($id)
    {
        if ($id == Yii::$app->user->getId()) {
            Yii::$app->getSession()->setFlash('error', Yii::t('user', 'You can not block your own account'));
        } else {
Severity: Minor
Found in controllers/AdminController.php - About 55 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

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

    public function actionReset($id, $code)
    {
        $model = User::findOne([
            'id'                   => $id,
            'password_reset_token' => $code,
Severity: Minor
Found in controllers/RecoveryController.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

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

        public function actionUploadAvatar()
        {
            if (isset($_FILES['avatar'])) {
                $avatar = $_FILES['avatar'];
                $path = '../vendor/abhi1693/yii2-user/uploads/profile_image/';
Severity: Minor
Found in controllers/AccountController.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

Severity
Category
Status
Source
Language