Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — development (#51)
by José
03:59
created

Comment   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 74
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 0
cbo 3
dl 74
loc 74
ccs 0
cts 10
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A commentator() 4 4 1
A campaign() 4 4 1
A boot() 10 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace DoeSangue\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
use DoeSangue\Models\User;
8
use DoeSangue\Models\Campaign;
9
use Webpatser\Uuid\Uuid;
10
11 View Code Duplication
class Comment extends Model
1 ignored issue
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
14
    use SoftDeletes;
15
16
    /**
17
     * The table associated with the model.
18
     *
19
     * @var string
20
     */
21
    protected $table = 'comments';
22
23
    /**
24
     * Indicates if the IDs are auto-incrementing.
25
     *
26
     * @var bool
27
     */
28
    public $incrementing = false;
29
30
    /**
31
     * The attributes that are mass assignable.
32
     *
33
     * @var array
34
     */
35
    protected $filliable = [
36
      'comment_id',
37
      'id',
38
      'comment',
39
      'campaign_id',
40
      'user_id'
41
    ];
42
43
    protected $primaryKey = 'comment_id';
44
45
    protected $dates = [
46
      'created_at',
47
      'updated_at'
48
    ];
49
50
    protected $hidden = [
51
      'created_at',
52
      'updated_at',
53
      'user_id',
54
      'campaign_id'
55
    ];
56
57
    // protected $casts = [ 'commentator', 'campaign' ];
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
58
59
    public function commentator()
60
    {
61
        return $this->belongsTo(User::class, 'user_id');
62
    }
63
64
    public function campaign()
65
    {
66
        return $this->belongsTo(Campaign::class);
67
    }
68
69
      /**
70
       * Generate automaticaly the Comment id(uuid).
71
       *
72
       * @return void
73
       */
74
    public static function boot()
75
    {
76
        parent::boot();
77
        self::creating(
78
            function ($model) {
79
                // Generate a version 4 Uuid.
80
                $model->id = (string) Uuid::generate(4)->string;
81
            }
82
        );
83
    }
84
}
85