Skip to content

refactor: Fixing some code smells AISS IS3-L5-5 #7591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/Exceptions/UnknownPermissionException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Exceptions;

use Exception;

class UnknownPermissionException extends Exception
{
public function __construct($message = "Unknown permission", $code = 400)
{
parent::__construct($message, $code);
}
}
4 changes: 1 addition & 3 deletions app/Http/Middleware/AuthenticateWithTokenOnBasicAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ private function sanctumUser(Request $request): ?User
protected function sanctum(): RequestGuard
{
/** @var \Illuminate\Auth\RequestGuard */
$guard = $this->auth->guard('sanctum');

return $guard;
return $this->auth->guard('sanctum');
}

/**
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Middleware/SanctumSetUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public function handle(Request $request, Closure $next)
protected function sanctum(): RequestGuard
{
/** @var \Illuminate\Auth\RequestGuard */
$guard = $this->auth->guard('sanctum');

return $guard;
return $this->auth->guard('sanctum');
}
}
3 changes: 2 additions & 1 deletion app/Services/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Services;

use App\Exceptions\NotEnoughPermissionException;
use App\Exceptions\UnknownPermissionException;
use App\Models\Account;
use App\Models\Contact;
use App\Models\Group;
Expand Down Expand Up @@ -112,7 +113,7 @@ public function validateRules(array $data): bool
}

if (($e = $permissions->diff(collect(self::$permissionDependencies)->keys()))->isNotEmpty()) {
throw new \Exception('Unknown permission: '.$e->first());
throw new UnknownPermissionException('Unknown permission: '.$e->first());
}

return true;
Expand Down
12 changes: 2 additions & 10 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ public function definition(): array
*/
public function unverified()
{
return $this->state(function (array $attributes) {
return [
'email_verified_at' => null,
];
});
return $this->state(fn () => ['email_verified_at' => null,]);
}

/**
Expand All @@ -56,10 +52,6 @@ public function unverified()
*/
public function administrator()
{
return $this->state(function (array $attributes) {
return [
'is_account_administrator' => true,
];
});
return $this->state(fn () => ['is_account_administrator' => true]);
}
}
3 changes: 2 additions & 1 deletion resources/js/Components/Label.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<script setup>
defineProps({
value: String,
forId: String,
});
</script>

<template>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
<label :for="forId" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
<span v-if="value">
{{ value }}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export default {
.delete(channel.url.destroy)
.then(() => {
this.flash(this.$t('The email address has been deleted'), 'success');
var id = this.localEmails.findIndex((x) => x.id === channel.id);
let id = this.localEmails.findIndex((x) => x.id === channel.id);
this.localEmails.splice(id, 1);
})
.catch((error) => {
Expand Down
11 changes: 0 additions & 11 deletions resources/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,3 @@ window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/

// import Echo from 'laravel-echo';

// window.Pusher = require('pusher-js');

// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: process.env.MIX_PUSHER_APP_KEY,
// cluster: process.env.MIX_PUSHER_APP_CLUSTER,
// forceTLS: true
// });
Loading