Apply fixes from StyleCI (#93)

[ci skip] [skip ci]
This commit is contained in:
Pig Fang 2019-08-15 23:27:29 +08:00 committed by GitHub
parent e67df90978
commit 372c7768d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 44 additions and 22 deletions

View File

@ -34,6 +34,7 @@ class Handler extends ExceptionHandler
})
->map(function ($trace) {
$trace['file'] = str_replace(base_path().DIRECTORY_SEPARATOR, '', $trace['file']);
return $trace;
})
->filter(function ($trace) {

View File

@ -7,8 +7,8 @@ use Option;
use Notification;
use Carbon\Carbon;
use App\Models\User;
use App\Notifications;
use App\Models\Player;
use App\Notifications;
use App\Models\Texture;
use Illuminate\Support\Str;
use App\Services\OptionForm;
@ -99,6 +99,7 @@ class AdminController extends Controller
Notification::send($users, $notification);
session(['sentResult' => trans('admin.notifications.send.success')]);
return redirect('/admin');
}

View File

@ -63,6 +63,7 @@ class MarketController extends Controller
$pluginsHaveUpdate = collect($this->getAllAvailablePlugins())
->filter(function ($item) use ($manager) {
$plugin = $manager->get($item['name']);
return $plugin && Comparator::greaterThan($item['version'], $plugin->version);
});

View File

@ -114,6 +114,7 @@ class ReportController extends Controller
self::returnScore($report);
$report->status = Report::RESOLVED;
$report->save();
return json(trans('general.texture-deleted'), 0, ['status' => Report::RESOLVED]);
}
break;
@ -138,13 +139,16 @@ class ReportController extends Controller
return json(trans('general.op-success'), 0, ['status' => Report::RESOLVED]);
}
static function returnScore($report) {
public static function returnScore($report)
{
if ($report->status == Report::PENDING && ($score = option('reporter_score_modification', 0)) < 0) {
$report->informer->score -= $score;
$report->informer->save();
}
}
static function giveAward($report) {
public static function giveAward($report)
{
if ($report->status == Report::PENDING) {
$report->informer->score += option('reporter_reward_score', 0);
$report->informer->save();

View File

@ -149,8 +149,8 @@ class SetupController extends Controller
'--force' => true,
'--path' => [
'database/migrations',
'vendor/laravel/passport/database/migrations'
]
'vendor/laravel/passport/database/migrations',
],
]);
Log::info('[SetupWizard] Tables migrated.');

View File

@ -96,6 +96,7 @@ class UpdateController extends Controller
$php = Arr::get($this->info, 'php');
if (Comparator::lessThan(PHP_VERSION, $php)) {
$this->error = trans('admin.update.errors.php', ['version' => $php]);
return false;
}

View File

@ -10,6 +10,7 @@ class LockUpdatePage
public function handle($request, Closure $next)
{
abort_if($request->user()->permission < User::SUPER_ADMIN, 503);
return $next($request);
}
}

View File

@ -26,6 +26,7 @@ trait HasPassword
public function getEncryptedPwdFromEvent($raw)
{
$responses = event(new EncryptUserPassword($raw, $this));
return Arr::get($responses, 0);
}
@ -39,6 +40,7 @@ trait HasPassword
{
$responses = event(new EncryptUserPassword($password, $this));
$this->password = Arr::get($responses, 0, app('cipher')->hash($password, config('secure.salt')));
return $this->save();
}
}

View File

@ -65,6 +65,7 @@ class User extends Authenticatable implements JWTSubject
if (Arr::has(static::$mappings, $item['column'])) {
$item['column'] = static::$mappings[$item['column']];
}
return $item;
};
$mapColumn = function ($column) {
@ -86,6 +87,7 @@ class User extends Authenticatable implements JWTSubject
}
$builder->setQuery($query);
return $builder;
});
}

View File

@ -2,10 +2,6 @@
namespace App\Providers;
use Event;
use App\Events;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use App\Services\PluginManager;
use Illuminate\Support\ServiceProvider;

View File

@ -2,8 +2,6 @@
namespace App\Services;
use Storage;
use Exception;
use App\Events;
use Composer\Semver\Semver;
use Illuminate\Support\Arr;
@ -118,6 +116,7 @@ class PluginManager
});
$this->plugins = $plugins;
return $plugins;
}
@ -313,11 +312,13 @@ class PluginManager
->mapWithKeys(function ($constraint, $name) {
if ($name == 'blessing-skin-server') {
$version = config('app.version');
return (! Semver::satisfies($version, $constraint))
? [$name => compact('version', 'constraint')]
: [];
} elseif ($name == 'php') {
$version = PHP_VERSION;
return (! Semver::satisfies($version, $constraint))
? [$name => compact('version', 'constraint')]
: [];
@ -325,6 +326,7 @@ class PluginManager
return [$name => ['version' => null, 'constraint' => $constraint]];
} else {
$version = $this->enabled->get($name)['version'];
return (! Semver::satisfies($version, $constraint))
? [$name => compact('version', 'constraint')]
: [];

View File

@ -3,7 +3,6 @@
declare(strict_types=1);
use Carbon\Carbon;
use App\Models\User;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
@ -13,8 +12,9 @@ if (! function_exists('webpack_assets')) {
if (env('WEBPACK_ENV', 'production') == 'development') {
// @codeCoverageIgnoreStart
$host = parse_url(url('/'), PHP_URL_HOST);
return "http://$host:8080/$relativeUri";
// @codeCoverageIgnoreEnd
// @codeCoverageIgnoreEnd
} else {
$path = app('webpack')->$relativeUri;
$cdn = option('cdn_address');
@ -125,7 +125,7 @@ if (! function_exists('bs_menu')) {
$menu[$type] = array_map(function ($item) {
if (Arr::get($item, 'id') === 'plugin-configs') {
$pluginConfigs = app('plugins')->getEnabledPlugins()
$pluginConfigs = app('plugins')->getEnabledPlugins()
->filter(function ($plugin) {
return $plugin->hasConfigView();
})

View File

@ -4,7 +4,6 @@ namespace Tests;
use Cache;
use Redis;
use App\Models\User;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseTransactions;

View File

@ -4,8 +4,8 @@ namespace Tests;
use Notification;
use App\Models\User;
use App\Notifications;
use App\Models\Player;
use App\Notifications;
use App\Models\Texture;
use Illuminate\Support\Str;
use Illuminate\Foundation\Testing\WithoutMiddleware;
@ -53,6 +53,7 @@ class AdminControllerTest extends TestCase
Notifications\SiteMessage::class,
function ($notification) {
$this->assertEquals('all users', $notification->title);
return true;
}
);
@ -70,6 +71,7 @@ class AdminControllerTest extends TestCase
function ($notification) {
$this->assertEquals('normal only', $notification->title);
$this->assertEquals('hi', $notification->content);
return true;
}
);
@ -88,6 +90,7 @@ class AdminControllerTest extends TestCase
Notifications\SiteMessage::class,
function ($notification) {
$this->assertEquals('uid', $notification->title);
return true;
}
);
@ -106,6 +109,7 @@ class AdminControllerTest extends TestCase
Notifications\SiteMessage::class,
function ($notification) {
$this->assertEquals('email', $notification->title);
return true;
}
);

View File

@ -3,7 +3,6 @@
namespace Tests;
use Schema;
use Artisan;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;

View File

@ -92,6 +92,7 @@ class PluginControllerTest extends TestCase
$mock->shouldReceive('getUnsatisfied')
->withArgs(function ($plugin) {
$this->assertEquals('fake2', $plugin->name);
return true;
})
->once()
@ -110,6 +111,7 @@ class PluginControllerTest extends TestCase
$mock->shouldReceive('getUnsatisfied')
->withArgs(function ($plugin) {
$this->assertEquals('fake3', $plugin->name);
return true;
})
->once()
@ -208,11 +210,12 @@ class PluginControllerTest extends TestCase
->andReturn(collect([new Plugin('', [
'name' => 'a',
'version' => '0.0.0',
'title' => ''
'title' => '',
])]));
$mock->shouldReceive('getUnsatisfied')
->withArgs(function ($plugin) {
$this->assertEquals('a', $plugin->name);
return true;
})
->once()

View File

@ -11,6 +11,7 @@ class FilterTest extends TestCase
->withArgs(function ($hook, $callback) {
$this->assertEquals('my.hook', $hook);
$this->assertEquals('Filtered text', $callback('text'));
return true;
})
->once();

View File

@ -101,6 +101,7 @@ class HookTest extends TestCase
{
$response = $next($request);
$response->header('X-Middleware-Test', 'value');
return $response;
}
}));

View File

@ -19,6 +19,7 @@ class PluginManagerTest extends TestCase
$property->setValue($manager, false);
$manager->boot();
return $manager;
}
@ -148,6 +149,7 @@ class PluginManagerTest extends TestCase
$manager = $this->rebootPluginManager(app('plugins'));
Event::assertDispatched(\App\Events\PluginVersionChanged::class, function ($event) {
$this->assertEquals('0.1.0', $event->plugin->version);
return true;
});
@ -390,6 +392,7 @@ class PluginManagerTest extends TestCase
$manager->enable('fake');
Event::assertDispatched(Events\PluginWasEnabled::class, function ($event) {
$this->assertEquals('fake', $event->plugin->name);
return true;
});
$this->assertTrue($manager->getEnabledPlugins()->has('fake'));
@ -414,6 +417,7 @@ class PluginManagerTest extends TestCase
$manager->disable('fake');
Event::assertDispatched(Events\PluginWasDisabled::class, function ($event) {
$this->assertEquals('fake', $event->plugin->name);
return true;
});
$this->assertFalse($manager->getEnabledPlugins()->has('fake'));
@ -439,10 +443,12 @@ class PluginManagerTest extends TestCase
$manager->delete('fake');
Event::assertDispatched(Events\PluginWasDisabled::class, function ($event) {
$this->assertEquals('fake', $event->plugin->name);
return true;
});
Event::assertDispatched(Events\PluginWasDeleted::class, function ($event) {
$this->assertEquals('fake', $event->plugin->name);
return true;
});
$this->assertFalse($manager->getEnabledPlugins()->has('fake'));

View File

@ -3,7 +3,6 @@
namespace Tests;
use File;
use App\Services\Webpack;
class WebpackTest extends TestCase
{

View File

@ -2,7 +2,6 @@
namespace Tests;
use DB;
use Mockery;
use Exception;
use CreateAllTables;
@ -180,8 +179,8 @@ class SetupControllerTest extends TestCase
'--force' => true,
'--path' => [
'database/migrations',
'vendor/laravel/passport/database/migrations'
]
'vendor/laravel/passport/database/migrations',
],
])
->once()
->andReturnUsing(function () {