Skip to content

Commit

Permalink
chore: Add php code sniffer github check (linuxserver#1066)
Browse files Browse the repository at this point in the history
  • Loading branch information
keriati authored Dec 11, 2022
1 parent d910f8e commit 5eb1f55
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
env:
APP_ENV: testing

- name: Php code sniffer
run: ./vendor/bin/phpcs

- name: Upload artifacts
uses: actions/upload-artifact@master
if: failure()
Expand Down
3 changes: 2 additions & 1 deletion app/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ function format_bytes($bytes, bool $is_drive_size = true, string $beforeunit = '
{
$btype = ($is_drive_size === true) ? 1000 : 1024;
$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') {
return round($bytes, 3).$beforeunit.$labels[$x].$afterunit;
} elseif ($labels[$x] == 'GB') {
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/ItemRestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ public function index()
/**
* Show the form for creating a new resource.
*
* @return Response
* @return void
*/
public function create()
{

}

/**
Expand Down
1 change: 0 additions & 1 deletion app/Http/Middleware/VerifyCsrfToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ class VerifyCsrfToken extends Middleware
'test_config',
//'get_stats'
];

}
2 changes: 2 additions & 0 deletions app/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use stdClass;
use Symfony\Component\ClassLoader\ClassMapGenerator;

// @codingStandardsIgnoreStart
/**
* App\Item
*
Expand Down Expand Up @@ -68,6 +69,7 @@
* @method static \Illuminate\Database\Query\Builder|Item withoutTrashed()
* @mixin \Eloquent
*/
// @codingStandardsIgnoreEnd
class Item extends Model
{
use SoftDeletes;
Expand Down
2 changes: 2 additions & 0 deletions app/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,15 @@ public static function fetch(string $key)
return self::_fetch($key, $user);
}

// @codingStandardsIgnoreStart
/**
* @param string $key
*
* @return mixed
*/
public static function _fetch($key, $user = null)
{
// @codingStandardsIgnoreEnd
//$cachekey = ($user === null) ? $key : $key.'-'.$user->id;
//if (Setting::cached($cachekey)) {
// return Setting::$cache[$cachekey];
Expand Down
2 changes: 2 additions & 0 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

// @codingStandardsIgnoreStart
/**
* App\User
*
Expand Down Expand Up @@ -42,6 +43,7 @@
* @method static \Illuminate\Database\Eloquent\Builder|User whereUsername($value)
* @mixin \Eloquent
*/
// @codingStandardsIgnoreEnd
class User extends Authenticatable
{
use Notifiable;
Expand Down
2 changes: 1 addition & 1 deletion config/hashing.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
'time' => 2,
],

];
];
2 changes: 1 addition & 1 deletion config/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
realpath(storage_path('framework/views'))
),

];
];
2 changes: 1 addition & 1 deletion database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ public function unverified()
];
});
}
}
}
21 changes: 17 additions & 4 deletions database/seeders/SettingsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public static function getSupportedLanguageMap()

foreach ($languageDirectories as $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'));
$result[$language] = "$resultNative ($resultEn)";
}
Expand Down Expand Up @@ -201,7 +205,12 @@ public function run()

if ($support = Setting::find(8)) {
$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();
} else {
$setting = new Setting;
Expand All @@ -210,7 +219,11 @@ public function run()
$setting->key = 'support';
$setting->type = 'text';
$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->save();
}
Expand Down Expand Up @@ -275,7 +288,7 @@ public function run()
$home_tag->save();
$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.");

DB::update('update items set id = 0 where id = ?', [$home_tag_id]);
Expand Down
6 changes: 2 additions & 4 deletions database/seeders/UsersSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UsersSeeder extends Seeder
public function run()
{
// Groups
if (! $user = User::find(1)) {
if (!User::find(1)) {
$user = new User;
$user->username = 'admin';
$user->email = '[email protected]';
Expand All @@ -24,13 +24,11 @@ public function run()

$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.");

DB::update('update users set id = 1 where id = ?', [$user_id]);
}
} else {
//$user->save();
}
}
}
3 changes: 2 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
<file>database</file>
<file>resources</file>
<file>routes</file>
<file>tests</file>

<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>*/migrations/*</exclude-pattern>
<exclude-pattern>*/seeds/*</exclude-pattern>
Expand Down

0 comments on commit 5eb1f55

Please sign in to comment.