From 5eb1f55b82a954a5c23c5a74c1e82f89bfade3a2 Mon Sep 17 00:00:00 2001
From: Attila Kerekes <439392+keriati@users.noreply.github.com>
Date: Sun, 11 Dec 2022 10:58:58 +0000
Subject: [PATCH] chore: Add php code sniffer github check (#1066)
---
.github/workflows/ci.yml | 3 +++
app/Helper.php | 3 ++-
app/Http/Controllers/ItemRestController.php | 3 +--
app/Http/Middleware/VerifyCsrfToken.php | 1 -
app/Item.php | 2 ++
app/Setting.php | 2 ++
app/User.php | 2 ++
config/hashing.php | 2 +-
config/view.php | 2 +-
database/factories/UserFactory.php | 2 +-
database/seeders/SettingsSeeder.php | 21 +++++++++++++++++----
database/seeders/UsersSeeder.php | 6 ++----
phpcs.xml | 3 ++-
13 files changed, 36 insertions(+), 16 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6d972432..ce68fe55 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -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()
diff --git a/app/Helper.php b/app/Helper.php
index 66a7e26d..99c807bd 100644
--- a/app/Helper.php
+++ b/app/Helper.php
@@ -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') {
diff --git a/app/Http/Controllers/ItemRestController.php b/app/Http/Controllers/ItemRestController.php
index b1a93317..d147d8a8 100644
--- a/app/Http/Controllers/ItemRestController.php
+++ b/app/Http/Controllers/ItemRestController.php
@@ -41,11 +41,10 @@ class ItemRestController extends Controller
/**
* Show the form for creating a new resource.
*
- * @return Response
+ * @return void
*/
public function create()
{
-
}
/**
diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php
index 9de5efd1..ae1893a9 100644
--- a/app/Http/Middleware/VerifyCsrfToken.php
+++ b/app/Http/Middleware/VerifyCsrfToken.php
@@ -18,5 +18,4 @@ class VerifyCsrfToken extends Middleware
'test_config',
//'get_stats'
];
-
}
diff --git a/app/Item.php b/app/Item.php
index 87c9dfde..39f297a5 100644
--- a/app/Item.php
+++ b/app/Item.php
@@ -12,6 +12,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use stdClass;
use Symfony\Component\ClassLoader\ClassMapGenerator;
+// @codingStandardsIgnoreStart
/**
* App\Item
*
@@ -68,6 +69,7 @@ use Symfony\Component\ClassLoader\ClassMapGenerator;
* @method static \Illuminate\Database\Query\Builder|Item withoutTrashed()
* @mixin \Eloquent
*/
+// @codingStandardsIgnoreEnd
class Item extends Model
{
use SoftDeletes;
diff --git a/app/Setting.php b/app/Setting.php
index 4afbd38b..be1adbb4 100644
--- a/app/Setting.php
+++ b/app/Setting.php
@@ -218,6 +218,7 @@ class Setting extends Model
return self::_fetch($key, $user);
}
+ // @codingStandardsIgnoreStart
/**
* @param string $key
*
@@ -225,6 +226,7 @@ class Setting extends Model
*/
public static function _fetch($key, $user = null)
{
+ // @codingStandardsIgnoreEnd
//$cachekey = ($user === null) ? $key : $key.'-'.$user->id;
//if (Setting::cached($cachekey)) {
// return Setting::$cache[$cachekey];
diff --git a/app/User.php b/app/User.php
index 1fb5e3c5..75322bad 100644
--- a/app/User.php
+++ b/app/User.php
@@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
+// @codingStandardsIgnoreStart
/**
* App\User
*
@@ -42,6 +43,7 @@ use Illuminate\Notifications\Notifiable;
* @method static \Illuminate\Database\Eloquent\Builder|User whereUsername($value)
* @mixin \Eloquent
*/
+// @codingStandardsIgnoreEnd
class User extends Authenticatable
{
use Notifiable;
diff --git a/config/hashing.php b/config/hashing.php
index bc5da3a6..84257708 100644
--- a/config/hashing.php
+++ b/config/hashing.php
@@ -49,4 +49,4 @@ return [
'time' => 2,
],
-];
\ No newline at end of file
+];
diff --git a/config/view.php b/config/view.php
index 916e61b7..22b8a18d 100644
--- a/config/view.php
+++ b/config/view.php
@@ -33,4 +33,4 @@ return [
realpath(storage_path('framework/views'))
),
-];
\ No newline at end of file
+];
diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php
index 33a7c5e3..311fb96b 100644
--- a/database/factories/UserFactory.php
+++ b/database/factories/UserFactory.php
@@ -44,4 +44,4 @@ class UserFactory extends Factory
];
});
}
-}
\ No newline at end of file
+}
diff --git a/database/seeders/SettingsSeeder.php b/database/seeders/SettingsSeeder.php
index f9e1046d..ddaf7e03 100644
--- a/database/seeders/SettingsSeeder.php
+++ b/database/seeders/SettingsSeeder.php
@@ -27,7 +27,11 @@ class SettingsSeeder extends Seeder
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)";
}
@@ -201,7 +205,12 @@ class SettingsSeeder extends Seeder
if ($support = Setting::find(8)) {
$support->label = 'app.settings.support';
- $support->value = 'Discord | Github | Blog';
+ $support->value =
+ 'Discord'.
+ ' | '.
+ 'Github'.
+ ' | '.
+ 'Blog';
$support->save();
} else {
$setting = new Setting;
@@ -210,7 +219,11 @@ class SettingsSeeder extends Seeder
$setting->key = 'support';
$setting->type = 'text';
$setting->label = 'app.settings.support';
- $setting->value = 'Discord | Github | Blog';
+ $setting->value = 'Discord'.
+ ' | '.
+ 'Github'.
+ ' | '.
+ 'Blog';
$setting->system = true;
$setting->save();
}
@@ -275,7 +288,7 @@ class SettingsSeeder extends Seeder
$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]);
diff --git a/database/seeders/UsersSeeder.php b/database/seeders/UsersSeeder.php
index a2b7f4ef..198258b2 100644
--- a/database/seeders/UsersSeeder.php
+++ b/database/seeders/UsersSeeder.php
@@ -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 = 'admin@test.com';
@@ -24,13 +24,11 @@ class UsersSeeder extends Seeder
$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();
}
}
}
diff --git a/phpcs.xml b/phpcs.xml
index a9c5d689..f305bc5f 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -9,9 +9,10 @@
database
resources
routes
- tests
bootstrap/cache/*
+ app/SupportedApps/*
+ resources/lang/*
bootstrap/autoload.php
*/migrations/*
*/seeds/*