chore: Add php code sniffer github check (#1066)

This commit is contained in:
Attila Kerekes 2022-12-11 10:58:58 +00:00 committed by GitHub
parent d910f8e4f7
commit 5eb1f55b82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 36 additions and 16 deletions

View file

@ -45,6 +45,9 @@ jobs:
env: env:
APP_ENV: testing APP_ENV: testing
- name: Php code sniffer
run: ./vendor/bin/phpcs
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
if: failure() if: failure()

View file

@ -13,7 +13,8 @@ function format_bytes($bytes, bool $is_drive_size = true, string $beforeunit = '
{ {
$btype = ($is_drive_size === true) ? 1000 : 1024; $btype = ($is_drive_size === true) ? 1000 : 1024;
$labels = ['B', 'KB', 'MB', 'GB', 'TB']; $labels = ['B', 'KB', 'MB', 'GB', 'TB'];
for ($x = 0; $bytes >= $btype && $x < (count($labels) - 1); $bytes /= $btype, $x++); // use 1000 rather than 1024 to simulate HD size not real size // use 1000 rather than 1024 to simulate HD size not real size
for ($x = 0; $bytes >= $btype && $x < (count($labels) - 1); $bytes /= $btype, $x++);
if ($labels[$x] == 'TB') { if ($labels[$x] == 'TB') {
return round($bytes, 3).$beforeunit.$labels[$x].$afterunit; return round($bytes, 3).$beforeunit.$labels[$x].$afterunit;
} elseif ($labels[$x] == 'GB') { } elseif ($labels[$x] == 'GB') {

View file

@ -41,11 +41,10 @@ class ItemRestController extends Controller
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* *
* @return Response * @return void
*/ */
public function create() public function create()
{ {
} }
/** /**

View file

@ -18,5 +18,4 @@ class VerifyCsrfToken extends Middleware
'test_config', 'test_config',
//'get_stats' //'get_stats'
]; ];
} }

View file

@ -12,6 +12,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use stdClass; use stdClass;
use Symfony\Component\ClassLoader\ClassMapGenerator; use Symfony\Component\ClassLoader\ClassMapGenerator;
// @codingStandardsIgnoreStart
/** /**
* App\Item * App\Item
* *
@ -68,6 +69,7 @@ use Symfony\Component\ClassLoader\ClassMapGenerator;
* @method static \Illuminate\Database\Query\Builder|Item withoutTrashed() * @method static \Illuminate\Database\Query\Builder|Item withoutTrashed()
* @mixin \Eloquent * @mixin \Eloquent
*/ */
// @codingStandardsIgnoreEnd
class Item extends Model class Item extends Model
{ {
use SoftDeletes; use SoftDeletes;

View file

@ -218,6 +218,7 @@ class Setting extends Model
return self::_fetch($key, $user); return self::_fetch($key, $user);
} }
// @codingStandardsIgnoreStart
/** /**
* @param string $key * @param string $key
* *
@ -225,6 +226,7 @@ class Setting extends Model
*/ */
public static function _fetch($key, $user = null) public static function _fetch($key, $user = null)
{ {
// @codingStandardsIgnoreEnd
//$cachekey = ($user === null) ? $key : $key.'-'.$user->id; //$cachekey = ($user === null) ? $key : $key.'-'.$user->id;
//if (Setting::cached($cachekey)) { //if (Setting::cached($cachekey)) {
// return Setting::$cache[$cachekey]; // return Setting::$cache[$cachekey];

View file

@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
// @codingStandardsIgnoreStart
/** /**
* App\User * App\User
* *
@ -42,6 +43,7 @@ use Illuminate\Notifications\Notifiable;
* @method static \Illuminate\Database\Eloquent\Builder|User whereUsername($value) * @method static \Illuminate\Database\Eloquent\Builder|User whereUsername($value)
* @mixin \Eloquent * @mixin \Eloquent
*/ */
// @codingStandardsIgnoreEnd
class User extends Authenticatable class User extends Authenticatable
{ {
use Notifiable; use Notifiable;

View file

@ -49,4 +49,4 @@ return [
'time' => 2, 'time' => 2,
], ],
]; ];

View file

@ -33,4 +33,4 @@ return [
realpath(storage_path('framework/views')) realpath(storage_path('framework/views'))
), ),
]; ];

View file

@ -44,4 +44,4 @@ class UserFactory extends Factory
]; ];
}); });
} }
} }

View file

@ -27,7 +27,11 @@ class SettingsSeeder extends Seeder
foreach ($languageDirectories as $languageDirectory) { foreach ($languageDirectories as $languageDirectory) {
$language = self::getLanguageFromDirectory($languageDirectory); $language = self::getLanguageFromDirectory($languageDirectory);
$resultNative = mb_convert_case(Locale::getDisplayLanguage($language.'-', $language), MB_CASE_TITLE, 'UTF-8'); $resultNative = mb_convert_case(
Locale::getDisplayLanguage($language.'-', $language),
MB_CASE_TITLE,
'UTF-8'
);
$resultEn = ucfirst(Locale::getDisplayLanguage($language, 'en')); $resultEn = ucfirst(Locale::getDisplayLanguage($language, 'en'));
$result[$language] = "$resultNative ($resultEn)"; $result[$language] = "$resultNative ($resultEn)";
} }
@ -201,7 +205,12 @@ class SettingsSeeder extends Seeder
if ($support = Setting::find(8)) { if ($support = Setting::find(8)) {
$support->label = 'app.settings.support'; $support->label = 'app.settings.support';
$support->value = '<a rel="noopener" target="_blank" href="https://discord.gg/CCjHKn4">Discord</a> | <a rel="noopener" target="_blank" href="https://github.com/linuxserver/Heimdall">Github</a> | <a rel="noopener" target="_blank" href="https://blog.heimdall.site/">Blog</a>'; $support->value =
'<a rel="noopener" target="_blank" href="https://discord.gg/CCjHKn4">Discord</a>'.
' | '.
'<a rel="noopener" target="_blank" href="https://github.com/linuxserver/Heimdall">Github</a>'.
' | '.
'<a rel="noopener" target="_blank" href="https://blog.heimdall.site/">Blog</a>';
$support->save(); $support->save();
} else { } else {
$setting = new Setting; $setting = new Setting;
@ -210,7 +219,11 @@ class SettingsSeeder extends Seeder
$setting->key = 'support'; $setting->key = 'support';
$setting->type = 'text'; $setting->type = 'text';
$setting->label = 'app.settings.support'; $setting->label = 'app.settings.support';
$setting->value = '<a rel="noopener" target="_blank" href="https://discord.gg/CCjHKn4">Discord</a> | <a rel="noopener" target="_blank" href="https://github.com/linuxserver/Heimdall">Github</a> | <a rel="noopener" target="_blank" href="https://blog.heimdall.site/">Blog</a>'; $setting->value = '<a rel="noopener" target="_blank" href="https://discord.gg/CCjHKn4">Discord</a>'.
' | '.
'<a rel="noopener" target="_blank" href="https://github.com/linuxserver/Heimdall">Github</a>'.
' | '.
'<a rel="noopener" target="_blank" href="https://blog.heimdall.site/">Blog</a>';
$setting->system = true; $setting->system = true;
$setting->save(); $setting->save();
} }
@ -275,7 +288,7 @@ class SettingsSeeder extends Seeder
$home_tag->save(); $home_tag->save();
$home_tag_id = $home_tag->id; $home_tag_id = $home_tag->id;
if($home_tag_id != 0) { if ($home_tag_id != 0) {
Log::info("Home Tag returned with id $home_tag_id from db! Changing to 0."); Log::info("Home Tag returned with id $home_tag_id from db! Changing to 0.");
DB::update('update items set id = 0 where id = ?', [$home_tag_id]); DB::update('update items set id = 0 where id = ?', [$home_tag_id]);

View file

@ -15,7 +15,7 @@ class UsersSeeder extends Seeder
public function run() public function run()
{ {
// Groups // Groups
if (! $user = User::find(1)) { if (!User::find(1)) {
$user = new User; $user = new User;
$user->username = 'admin'; $user->username = 'admin';
$user->email = 'admin@test.com'; $user->email = 'admin@test.com';
@ -24,13 +24,11 @@ class UsersSeeder extends Seeder
$user_id = $user->id; $user_id = $user->id;
if($user_id != 1) { if ($user_id != 1) {
Log::info("First User returned with id $user_id from db! Changing to 1."); Log::info("First User returned with id $user_id from db! Changing to 1.");
DB::update('update users set id = 1 where id = ?', [$user_id]); DB::update('update users set id = 1 where id = ?', [$user_id]);
} }
} else {
//$user->save();
} }
} }
} }

View file

@ -9,9 +9,10 @@
<file>database</file> <file>database</file>
<file>resources</file> <file>resources</file>
<file>routes</file> <file>routes</file>
<file>tests</file>
<exclude-pattern>bootstrap/cache/*</exclude-pattern> <exclude-pattern>bootstrap/cache/*</exclude-pattern>
<exclude-pattern>app/SupportedApps/*</exclude-pattern>
<exclude-pattern>resources/lang/*</exclude-pattern>
<exclude-pattern>bootstrap/autoload.php</exclude-pattern> <exclude-pattern>bootstrap/autoload.php</exclude-pattern>
<exclude-pattern>*/migrations/*</exclude-pattern> <exclude-pattern>*/migrations/*</exclude-pattern>
<exclude-pattern>*/seeds/*</exclude-pattern> <exclude-pattern>*/seeds/*</exclude-pattern>