Passed
Pull Request — master (#414)
by John
12:18
created
app/Models/Eloquent/UserBanned.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 {
10 10
     use SoftDeletes;
11 11
 
12
-    protected $fillable = ['user_id', 'abuse_id', 'reason', 'removed_at'];
12
+    protected $fillable=['user_id', 'abuse_id', 'reason', 'removed_at'];
13 13
 
14 14
     public function abuse() {
15 15
         return $this->belongsTo('\App\Models\Eloquent\Abuse');
Please login to merge, or discard this patch.
app/Models/AnnouncementModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 
18 18
     public function fetch()
19 19
     {
20
-        $list=DB::table($this->table)->orderBy('created_at','desc')->get()->all();
20
+        $list=DB::table($this->table)->orderBy('created_at', 'desc')->get()->all();
21 21
         if (empty($list)) {
22 22
             return [];
23 23
         }
Please login to merge, or discard this patch.
app/Models/Latex/LatexModel.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@
 block discarded – undo
9 9
 {
10 10
     public static function info($ltxsource, $type="png")
11 11
     {
12
-        if(!in_array($type,['png','svg'])) return [];
12
+        if (!in_array($type, ['png', 'svg'])) return [];
13 13
         $url=route("latex.$type", ['ltxsource' => $ltxsource]);
14
-        $image = new Imagick();
14
+        $image=new Imagick();
15 15
         $image->readImageBlob(Storage::get('latex-svg/'.urlencode($ltxsource).'.svg'));
16
-        $width = $image->getImageWidth();
17
-        $height = $image->getImageHeight();
18
-        return [$url,$width/5,$height/5];
16
+        $width=$image->getImageWidth();
17
+        $height=$image->getImageHeight();
18
+        return [$url, $width / 5, $height / 5];
19 19
     }
20 20
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@
 block discarded – undo
9 9
 {
10 10
     public static function info($ltxsource, $type="png")
11 11
     {
12
-        if(!in_array($type,['png','svg'])) return [];
12
+        if(!in_array($type,['png','svg'])) {
13
+            return [];
14
+        }
13 15
         $url=route("latex.$type", ['ltxsource' => $ltxsource]);
14 16
         $image = new Imagick();
15 17
         $image->readImageBlob(Storage::get('latex-svg/'.urlencode($ltxsource).'.svg'));
Please login to merge, or discard this patch.
app/Console/Commands/Babel/Crawl.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      *
15 15
      * @var string
16 16
      */
17
-    protected $signature = 'babel:crawl
17
+    protected $signature='babel:crawl
18 18
         {extension : The package name of the extension}
19 19
         {--action=crawl_problem : The action of the Crawler}
20 20
         {--con=all : The target problemset of the Crawler}
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @var string
28 28
      */
29
-    protected $description = 'Crawl problems for a given Babel Extension to NOJ';
29
+    protected $description='Crawl problems for a given Babel Extension to NOJ';
30 30
 
31 31
     /**
32 32
      * Create a new command instance.
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function handle()
47 47
     {
48
-        $extension = $this->argument('extension');
49
-        $action = $this->option('action');
50
-        $con = $this->option('con');
51
-        [$from, $to] = sscanf($this->option('range'),"%d:%d");
52
-        $cached = $this->option('cached');
48
+        $extension=$this->argument('extension');
49
+        $action=$this->option('action');
50
+        $con=$this->option('con');
51
+        [$from, $to]=sscanf($this->option('range'), "%d:%d");
52
+        $cached=$this->option('cached');
53 53
         $babel=new Babel();
54 54
         $babel->crawl([
55 55
             "name" => $extension,
Please login to merge, or discard this patch.
app/Console/Commands/Babel/BabelCommand.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@  discard block
 block discarded – undo
13 13
      *
14 14
      * @var string
15 15
      */
16
-    protected $signature = 'babel';
16
+    protected $signature='babel';
17 17
 
18 18
     /**
19 19
      * The console command description.
20 20
      *
21 21
      * @var string
22 22
      */
23
-    protected $description = 'List all babel commands';
23
+    protected $description='List all babel commands';
24 24
 
25 25
     /**
26 26
      * @var string
27 27
      */
28
-    public static $logo = <<<LOGO
28
+    public static $logo=<<<LOGO
29 29
 
30 30
 ███╗   ██╗ ██████╗      ██╗    ██████╗  █████╗ ██████╗ ███████╗██╗
31 31
 ████╗  ██║██╔═══██╗     ██║    ██╔══██╗██╔══██╗██╔══██╗██╔════╝██║
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     public function handle()
43 43
     {
44 44
         $this->line(static::$logo);
45
-        $this->line(sprintf('NOJ <comment>version</comment> <info>%s</info>',version()));
45
+        $this->line(sprintf('NOJ <comment>version</comment> <info>%s</info>', version()));
46 46
 
47 47
         $this->comment('');
48 48
         $this->comment('Available commands:');
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     protected function listBabelCommands()
59 59
     {
60
-        $commands = collect(Artisan::all())->mapWithKeys(function ($command, $key) {
60
+        $commands=collect(Artisan::all())->mapWithKeys(function($command, $key) {
61 61
             if (Str::startsWith($key, 'babel:')) {
62 62
                 return [$key => $command];
63 63
             }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             return [];
66 66
         })->toArray();
67 67
 
68
-        $width = $this->getColumnWidth($commands);
68
+        $width=$this->getColumnWidth($commands);
69 69
 
70 70
         /** @var Command $command */
71 71
         foreach ($commands as $command) {
@@ -80,16 +80,16 @@  discard block
 block discarded – undo
80 80
      */
81 81
     private function getColumnWidth(array $commands)
82 82
     {
83
-        $widths = [];
83
+        $widths=[];
84 84
 
85 85
         foreach ($commands as $command) {
86
-            $widths[] = static::strlen($command->getName());
86
+            $widths[]=static::strlen($command->getName());
87 87
             foreach ($command->getAliases() as $alias) {
88
-                $widths[] = static::strlen($alias);
88
+                $widths[]=static::strlen($alias);
89 89
             }
90 90
         }
91 91
 
92
-        return $widths ? max($widths) + 2 : 0;
92
+        return $widths ? max($widths)+2 : 0;
93 93
     }
94 94
 
95 95
     /**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      */
102 102
     public static function strlen($string)
103 103
     {
104
-        if (false === $encoding = mb_detect_encoding($string, null, true)) {
104
+        if (false===$encoding=mb_detect_encoding($string, null, true)) {
105 105
             return strlen($string);
106 106
         }
107 107
 
Please login to merge, or discard this patch.
app/Console/Commands/Manage/BanUser.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
      *
14 14
      * @var string
15 15
      */
16
-    protected $signature = 'manage:ban {--uid=: the user you want to ban} {--time=: Unban time, Supports time that can be resolved by the strtotime method} {--reason=: reason}';
16
+    protected $signature='manage:ban {--uid=: the user you want to ban} {--time=: Unban time, Supports time that can be resolved by the strtotime method} {--reason=: reason}';
17 17
 
18 18
     /**
19 19
      * The console command description.
20 20
      *
21 21
      * @var string
22 22
      */
23
-    protected $description = 'Ban a user';
23
+    protected $description='Ban a user';
24 24
 
25 25
     /**
26 26
      * Create a new command instance.
@@ -39,23 +39,23 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function handle()
41 41
     {
42
-        $uid=(int)$this->option('uid');
42
+        $uid=(int) $this->option('uid');
43 43
         $reason=$this->option('reason');
44 44
         $time=$this->option('time');
45
-        $user = User::find($uid);
46
-        if(empty($user)) {
45
+        $user=User::find($uid);
46
+        if (empty($user)) {
47 47
             $this->line("\n  <bg=red;fg=white> Exception </> : <fg=yellow>User Not Found</>\n");
48 48
             return;
49 49
         }
50
-        try{
51
-            $ban_time = date('Y-m-d H:i:s',strtotime($time));
50
+        try {
51
+            $ban_time=date('Y-m-d H:i:s', strtotime($time));
52 52
             UserBanned::create([
53 53
                 'user_id'    => $user->id,
54 54
                 'reason'     => $reason,
55 55
                 'removed_at' => $ban_time
56 56
             ]);
57 57
             $this->line("The user <fg=yellow>{$user->name}</> will be banned until <fg=yellow>{$ban_time}</>");
58
-        }catch(Throwable $e){
58
+        } catch (Throwable $e) {
59 59
             $this->line("\n  <bg=red;fg=white> Exception </> : <fg=yellow>Wrong Time.</>\n");
60 60
             return;
61 61
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
                 'removed_at' => $ban_time
56 56
             ]);
57 57
             $this->line("The user <fg=yellow>{$user->name}</> will be banned until <fg=yellow>{$ban_time}</>");
58
-        }catch(Throwable $e){
58
+        } catch(Throwable $e){
59 59
             $this->line("\n  <bg=red;fg=white> Exception </> : <fg=yellow>Wrong Time.</>\n");
60 60
             return;
61 61
         }
Please login to merge, or discard this patch.
app/Console/Commands/Manage/CreateAdminCommand.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,25 +11,25 @@
 block discarded – undo
11 11
      *
12 12
      * @var string
13 13
      */
14
-    protected $signature = 'manage:create-admin';
14
+    protected $signature='manage:create-admin';
15 15
 
16 16
     /**
17 17
      * The console command description.
18 18
      *
19 19
      * @var string
20 20
      */
21
-    protected $description = 'Create a admin user';
21
+    protected $description='Create a admin user';
22 22
 
23 23
     /**
24 24
      * Execute the console command.
25 25
      */
26 26
     public function handle()
27 27
     {
28
-        $userModel = config('admin.database.users_model');
29
-        $username = $this->ask('Please enter a username to login');
30
-        $password = bcrypt($this->secret('Please enter a password to login'));
31
-        $name = $this->ask('Please enter a name to display');
32
-        $user = new $userModel(compact('username', 'password', 'name'));
28
+        $userModel=config('admin.database.users_model');
29
+        $username=$this->ask('Please enter a username to login');
30
+        $password=bcrypt($this->secret('Please enter a password to login'));
31
+        $name=$this->ask('Please enter a name to display');
32
+        $user=new $userModel(compact('username', 'password', 'name'));
33 33
         $user->save();
34 34
         $this->info("Admin User [$name] created successfully.");
35 35
     }
Please login to merge, or discard this patch.
app/Jobs/GeneratePDF.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 {
16 16
     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Trackable;
17 17
 
18
-    public $tries = 5;
18
+    public $tries=5;
19 19
     protected $cid;
20 20
     protected $config;
21 21
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             'cover'=>false,
34 34
             'advice'=>false,
35 35
         ];
36
-        $this->config=array_merge($default,$config);
36
+        $this->config=array_merge($default, $config);
37 37
     }
38 38
 
39 39
     /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         $cid=$this->cid;
47 47
         $config=$this->config;
48 48
 
49
-        if (!is_dir(storage_path("app/contest/pdf/"))){
49
+        if (!is_dir(storage_path("app/contest/pdf/"))) {
50 50
             mkdir(storage_path("app/contest/pdf/"), 0777, true);
51 51
         }
52 52
 
Please login to merge, or discard this patch.
app/Jobs/AntiCheat.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 {
22 22
     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Trackable;
23 23
 
24
-    public $tries = 1;
24
+    public $tries=1;
25 25
     public $progressVal=40;
26 26
     public $stepVal=0;
27 27
     protected $cid;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $cid=$this->cid;
55 55
         $contest=EloquentContestModel::find($cid);
56 56
 
57
-        if(!$contest->isJudgingComplete()) throw new Exception('Judging Incompleted');
57
+        if (!$contest->isJudgingComplete()) throw new Exception('Judging Incompleted');
58 58
 
59 59
         $acceptedSubmissions=$contest->submissions->whereIn('verdict', [
60 60
             'Accepted',
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
         $this->setProgressNow(20);
68 68
         $totMOSS=0;
69 69
 
70
-        foreach($acceptedSubmissions as $submission){
70
+        foreach ($acceptedSubmissions as $submission) {
71 71
             $lang=$submission->compiler->lang;
72
-            if(Arr::has($this->supportLang, $lang)){
72
+            if (Arr::has($this->supportLang, $lang)) {
73 73
                 $prob=$probIndex[$submission->pid];
74 74
                 $lang=$this->supportLang[$lang];
75 75
                 $ext=$lang;
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
         }
81 81
 
82 82
         $this->setProgressNow(40);
83
-        $this->stepVal=50/$totMOSS*3;
83
+        $this->stepVal=50 / $totMOSS * 3;
84 84
         $this->progressVal=40;
85 85
 
86
-        foreach($probLangs as $prob=>$langs){
87
-            foreach($langs as $lang=>$availableVal){
86
+        foreach ($probLangs as $prob=>$langs) {
87
+            foreach ($langs as $lang=>$availableVal) {
88 88
                 $this->detectPlagiarism([
89 89
                     'lang'=>$lang,
90 90
                     'cid'=>$cid,
@@ -98,19 +98,19 @@  discard block
 block discarded – undo
98 98
         $this->setProgressNow(100);
99 99
     }
100 100
 
101
-    private function incProgress(){
101
+    private function incProgress() {
102 102
         $this->progressVal+=$this->stepVal;
103 103
         $this->setProgressNow(intval($this->progressVal));
104 104
     }
105 105
 
106 106
     private function detectPlagiarism($config)
107 107
     {
108
-        $userid = config('moss.userid');
108
+        $userid=config('moss.userid');
109 109
         $lang=$config['lang'];
110 110
         $cid=$config['cid'];
111 111
         $prob=$config['prob'];
112 112
         $comment=$config['comment'];
113
-        $moss = new MOSS($userid);
113
+        $moss=new MOSS($userid);
114 114
         $moss->setLanguage($lang);
115 115
         $moss->addByWildcard(storage_path("app/contest/anticheat/$cid/raw/$prob/$lang/*"));
116 116
         $moss->setCommentString($comment);
@@ -118,25 +118,25 @@  discard block
 block discarded – undo
118 118
         $this->incProgress();
119 119
         $moss->saveTo(storage_path("app/contest/anticheat/$cid/report/$prob/$lang"), $id);
120 120
         $this->incProgress();
121
-        $this->afterWork($cid,$prob,$lang);
121
+        $this->afterWork($cid, $prob, $lang);
122 122
         $this->incProgress();
123 123
     }
124 124
 
125
-    private function afterWork($cid,$prob,$lang)
125
+    private function afterWork($cid, $prob, $lang)
126 126
     {
127 127
         $rawPath="contest/anticheat/$cid/raw/$prob/$lang";
128 128
         $reportPath="contest/anticheat/$cid/report/$prob/$lang";
129 129
         $generalPage=HtmlDomParser::str_get_html(Storage::disk('local')->get("$reportPath/index.html"), true, true, DEFAULT_TARGET_CHARSET, false);
130 130
         $table=$generalPage->find('table', 0);
131
-        if(is_null($table)) return;
132
-        foreach($table->find('tr') as $tr){
133
-            if(Str::contains($tr->outertext, '<th>')) continue;
131
+        if (is_null($table)) return;
132
+        foreach ($table->find('tr') as $tr) {
133
+            if (Str::contains($tr->outertext, '<th>')) continue;
134 134
             $firstUID=null;
135
-            foreach($tr->find('a') as $a){
136
-                $a->innertext=explode("$rawPath/",$a->plaintext)[1];
137
-                $a->innertext=str_replace(".$lang (",' (',$a->plaintext);
138
-                [$uid,$sid,$percent]=sscanf($a->innertext,"[%d][%d] (%d");
139
-                if($firstUID==$uid){
135
+            foreach ($tr->find('a') as $a) {
136
+                $a->innertext=explode("$rawPath/", $a->plaintext)[1];
137
+                $a->innertext=str_replace(".$lang (", ' (', $a->plaintext);
138
+                [$uid, $sid, $percent]=sscanf($a->innertext, "[%d][%d] (%d");
139
+                if ($firstUID==$uid) {
140 140
                     $tr->outertext='';
141 141
                     break;
142 142
                 }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                 $a->innertext="$sid. [$prob][$username][$percent%]";
146 146
             }
147 147
         }
148
-        Storage::disk('local')->put("$reportPath/index.html",$table->outertext);
148
+        Storage::disk('local')->put("$reportPath/index.html", $table->outertext);
149 149
     }
150 150
 
151 151
     private function finalizeReport($probLangs)
@@ -153,13 +153,13 @@  discard block
 block discarded – undo
153 153
         $cid=$this->cid;
154 154
         $generalPage="<table><tr><th>File 1</th><th>File 2</th><th>Lines Matched</th></tr>";
155 155
         $index=0;
156
-        foreach($probLangs as $prob=>$langs){
157
-            foreach($langs as $lang=>$availableVal){
156
+        foreach ($probLangs as $prob=>$langs) {
157
+            foreach ($langs as $lang=>$availableVal) {
158 158
                 $probPage=HtmlDomParser::str_get_html(Storage::disk('local')->get("contest/anticheat/$cid/report/$prob/$lang/index.html"), true, true, DEFAULT_TARGET_CHARSET, false);
159 159
                 $table=$probPage->find('table', 0);
160
-                if(is_null($table)) continue;
161
-                foreach($table->find('tr') as $tr){
162
-                    if(Str::contains($tr->outertext, '<th>')) continue;
160
+                if (is_null($table)) continue;
161
+                foreach ($table->find('tr') as $tr) {
162
+                    if (Str::contains($tr->outertext, '<th>')) continue;
163 163
                     $submissionA=$tr->children(0)->children(0);
164 164
                     $submissionB=$tr->children(1)->children(0);
165 165
                     $linesMatch=$tr->children(2);
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 54
         $cid=$this->cid;
55 55
         $contest=EloquentContestModel::find($cid);
56 56
 
57
-        if(!$contest->isJudgingComplete()) throw new Exception('Judging Incompleted');
57
+        if(!$contest->isJudgingComplete()) {
58
+            throw new Exception('Judging Incompleted');
59
+        }
58 60
 
59 61
         $acceptedSubmissions=$contest->submissions->whereIn('verdict', [
60 62
             'Accepted',
@@ -128,9 +130,13 @@  discard block
 block discarded – undo
128 130
         $reportPath="contest/anticheat/$cid/report/$prob/$lang";
129 131
         $generalPage=HtmlDomParser::str_get_html(Storage::disk('local')->get("$reportPath/index.html"), true, true, DEFAULT_TARGET_CHARSET, false);
130 132
         $table=$generalPage->find('table', 0);
131
-        if(is_null($table)) return;
133
+        if(is_null($table)) {
134
+            return;
135
+        }
132 136
         foreach($table->find('tr') as $tr){
133
-            if(Str::contains($tr->outertext, '<th>')) continue;
137
+            if(Str::contains($tr->outertext, '<th>')) {
138
+                continue;
139
+            }
134 140
             $firstUID=null;
135 141
             foreach($tr->find('a') as $a){
136 142
                 $a->innertext=explode("$rawPath/",$a->plaintext)[1];
@@ -157,9 +163,13 @@  discard block
 block discarded – undo
157 163
             foreach($langs as $lang=>$availableVal){
158 164
                 $probPage=HtmlDomParser::str_get_html(Storage::disk('local')->get("contest/anticheat/$cid/report/$prob/$lang/index.html"), true, true, DEFAULT_TARGET_CHARSET, false);
159 165
                 $table=$probPage->find('table', 0);
160
-                if(is_null($table)) continue;
166
+                if(is_null($table)) {
167
+                    continue;
168
+                }
161 169
                 foreach($table->find('tr') as $tr){
162
-                    if(Str::contains($tr->outertext, '<th>')) continue;
170
+                    if(Str::contains($tr->outertext, '<th>')) {
171
+                        continue;
172
+                    }
163 173
                     $submissionA=$tr->children(0)->children(0);
164 174
                     $submissionB=$tr->children(1)->children(0);
165 175
                     $linesMatch=$tr->children(2);
Please login to merge, or discard this patch.