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

Passed
Branch master (114f68)
by Mark
09:17
created

FebruaryUpdateOne::up()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 85
Code Lines 53

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 53
nc 1
nop 0
dl 0
loc 85
rs 8.6875
c 1
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
use App\Model\Plugin;
4
use App\Model\Setting;
5
use App\Model\ArticleCategory;
6
use Illuminate\Support\Facades\Schema;
7
use Illuminate\Support\Facades\Artisan;
8
use Illuminate\Database\Schema\Blueprint;
9
use Illuminate\Database\Migrations\Migration;
10
11
class FebruaryUpdateOne extends Migration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
12
{
13
    /**
14
     * Run the migrations.
15
     *
16
     * @return void
17
     */
18
    public function up()
19
    {
20
        $plugin = new Plugin;
21
22
        $plugin->setAttribute('name', 'articles');
23
        $plugin->setAttribute('version', '1.0');
24
        $plugin->setAttribute('icon', 'fa-book');
25
        $plugin->setAttribute('enabled', false);
26
        $plugin->setAttribute('is_frontend', true);
27
        $plugin->setAttribute('is_backend', true);
28
        $plugin->setAttribute('required', false);
29
        $plugin->save();
30
31
        /** @var \App\Classes\Repositories\PluginRepository $pluginRepository */
32
        $pluginRepository = app(\App\Classes\Repositories\PluginRepository::class);
33
34
        $pluginRepository->whereName('menus')->setAttribute('required', true)->save();
0 ignored issues
show
Bug introduced by
The method setAttribute() does not exist on stdClass. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
        $pluginRepository->whereName('menus')->/** @scrutinizer ignore-call */ setAttribute('required', true)->save();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method save() does not exist on stdClass. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
        $pluginRepository->whereName('menus')->setAttribute('required', true)->/** @scrutinizer ignore-call */ save();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
        $pluginRepository->whereName('pages')->setAttribute('required', true)->save();
36
37
        Schema::table('plugins', function (Blueprint $table) {
38
            $table->dropColumn('version');
39
            $table->dropColumn('icon');
40
        });
41
42
        Schema::create('articles', function (Blueprint $table) {
43
            $table->increments('id');
44
            $table->string('slug');
45
            $table->string('title');
46
            $table->longText('content');
47
            $table->string('featured_img')->nullable();
48
            $table->integer('views')->default(0);
49
            $table->integer('sitemap')->default(1);
50
            $table->unsignedInteger('category_id')->nullable();
51
            $table->integer('editor_id');
52
            $table->integer('creator_id');
53
            $table->boolean('status')->default(1);
54
            $table->softDeletes();
55
            $table->timestamps();
56
        });
57
58
        Schema::create('article_categories', function (Blueprint $table) {
59
            $table->increments('id');
60
            $table->string('title');
61
            $table->boolean('status')->default(1);
62
            $table->integer('editor_id');
63
            $table->integer('creator_id');
64
            $table->softDeletes();
65
            $table->timestamps();
66
        });
67
68
        /**
69
         * Store a General category.
70
         */
71
        $category = new ArticleCategory;
72
        $category->setAttribute('title', 'General');
73
        $category->setAttribute('editor_id', 1);
74
        $category->setAttribute('creator_id', 1);
75
        $category->touch();
76
        $category->save();
77
78
        /**
79
         * Store youtube url.
80
         */
81
        $setting = new Setting;
82
        $setting->setAttribute('key', 'youtube_url');
83
        $setting->save();
84
85
        /**
86
         * Store facebook url.
87
         */
88
        $setting = new Setting;
89
        $setting->setAttribute('key', 'facebook_url');
90
        $setting->save();
91
92
        /**
93
         * Store twitter url.
94
         */
95
        $setting = new Setting;
96
        $setting->setAttribute('key', 'twitter_url');
97
        $setting->save();
98
99
        /*
100
         * INDEX ALL NEW MATERIAL FOR SEARCHING.
101
         */
102
        Artisan::call('scout:mysql-index');
103
    }
104
105
    /**
106
     * Reverse the migrations.
107
     *
108
     * @return void
109
     */
110
    public function down()
111
    {
112
        //
113
    }
114
}
115