mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 12:12:18 +00:00
Fix up to level 3
This commit is contained in:
@@ -19,12 +19,12 @@
|
||||
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<ruleset name="pcsg-generated-ruleset"
|
||||
<ruleset name="Firefly III ruleset"
|
||||
xmlns="http://pmd.sf.net/ruleset/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||||
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
|
||||
<description>Bla bla</description>
|
||||
<description>Firefly III ruleset</description>
|
||||
|
||||
<!--
|
||||
Commando vanuit firefly directory:
|
||||
@@ -37,8 +37,7 @@ phpmd database,app,tests html /gdrive-all/development/phpmd/phpmd.xml > public/r
|
||||
</rule>
|
||||
|
||||
<!-- clean code -->
|
||||
<rule ref="rulesets/codesize.xml" />
|
||||
<rule ref="rulesets/design.xml" />
|
||||
<rule ref="rulesets/design.xml/" />
|
||||
<rule ref="rulesets/naming.xml" />
|
||||
<rule ref="rulesets/unusedcode.xml" />
|
||||
|
||||
@@ -51,7 +50,7 @@ phpmd database,app,tests html /gdrive-all/development/phpmd/phpmd.xml > public/r
|
||||
<rule ref="rulesets/codesize.xml/NPathComplexity">
|
||||
<properties>
|
||||
<!-- TODO we want to be at a value of 128. But we start high, and drop the bar slowly. -->
|
||||
<property name="minimum" value="2048"/>
|
||||
<property name="minimum" value="99000"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
|
||||
|
@@ -1,9 +1,11 @@
|
||||
parameters:
|
||||
universalObjectCratesClasses:
|
||||
- Illuminate\Database\Eloquent\Model
|
||||
# TODO: slowly remove these parameters and fix the issues found.
|
||||
reportUnmatchedIgnoredErrors: false
|
||||
checkGenericClassInNonGenericObjectType: false # remove this rule when all other issues are solved.
|
||||
ignoreErrors:
|
||||
# TODO: slowly remove these exceptions and fix the issues found.
|
||||
- '#Dynamic call to static method#' # all the Laravel ORM things depend on this.
|
||||
- '#Control structures using switch should not be used.#' # switch is fine insome cases.
|
||||
- '#with no value type specified in iterable type array#' # remove this rule when all other issues are solved.
|
||||
@@ -53,5 +55,6 @@ parameters:
|
||||
- ../bootstrap/app.php
|
||||
|
||||
# The level 8 is the highest level. original was 5
|
||||
level: 2
|
||||
# TODO: slowly up the level and fix the issues found.
|
||||
level: 3
|
||||
|
||||
|
@@ -30,12 +30,8 @@ use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Throwable;
|
||||
|
||||
@@ -50,10 +46,10 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
* @param Request $request
|
||||
* @param Throwable $e
|
||||
*
|
||||
* @return Application|JsonResponse|\Illuminate\Http\Response|Redirector|RedirectResponse|Response
|
||||
* @return Response
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function render($request, Throwable $e)
|
||||
public function render($request, Throwable $e): Response
|
||||
{
|
||||
$route = $request->route();
|
||||
if (null === $route) {
|
||||
@@ -140,7 +136,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
* @return Response
|
||||
* @throws Throwable
|
||||
*/
|
||||
private function handleAccount(Request $request, Throwable $exception)
|
||||
private function handleAccount(Request $request, Throwable $exception): Response
|
||||
{
|
||||
app('log')->debug('404 page is probably a deleted account. Redirect to overview of account types.');
|
||||
/** @var User $user */
|
||||
|
@@ -31,6 +31,7 @@ use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
@@ -40,6 +41,7 @@ use Illuminate\Validation\ValidationException as LaravelValidationException;
|
||||
use Laravel\Passport\Exceptions\OAuthServerException as LaravelOAuthException;
|
||||
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
@@ -75,10 +77,10 @@ class Handler extends ExceptionHandler
|
||||
* @param Request $request
|
||||
* @param Throwable $e
|
||||
*
|
||||
* @return mixed
|
||||
* @return Response
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function render($request, Throwable $e)
|
||||
public function render($request, Throwable $e): Response
|
||||
{
|
||||
$expectsJson = $request->expectsJson();
|
||||
// if the user requests anything /api/, assume the user wants to see JSON.
|
||||
@@ -246,9 +248,9 @@ class Handler extends ExceptionHandler
|
||||
* @param Request $request
|
||||
* @param LaravelValidationException $exception
|
||||
*
|
||||
* @return Application|RedirectResponse|Redirector
|
||||
* @return JsonResponse| RedirectResponse |\Illuminate\Http\Response
|
||||
*/
|
||||
protected function invalid($request, LaravelValidationException $exception): Application | RedirectResponse | Redirector
|
||||
protected function invalid($request, LaravelValidationException $exception): JsonResponse| RedirectResponse |\Illuminate\Http\Response
|
||||
{
|
||||
// protect against open redirect when submitting invalid forms.
|
||||
$previous = app('steam')->getSafePreviousUrl();
|
||||
|
@@ -72,7 +72,6 @@ class CurrencyExchangeRate extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/** @var array Convert these fields to other data types */
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
|
@@ -86,11 +86,6 @@ class PiggyBank extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
|
@@ -34,11 +34,6 @@ use Laravel\Passport\Passport;
|
||||
*/
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies
|
||||
= [
|
||||
// 'FireflyIII\Model' => 'FireflyIII\Policies\ModelPolicy',
|
||||
|
@@ -91,11 +91,6 @@ use Laravel\Passport\Events\AccessTokenCreated;
|
||||
*/
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event listener mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $listen
|
||||
= [
|
||||
// is a User related event.
|
||||
|
@@ -31,19 +31,7 @@ use Illuminate\Support\Facades\Route;
|
||||
*/
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/';
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = '';
|
||||
|
||||
/**
|
||||
|
@@ -193,9 +193,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user group's currencies.
|
||||
*
|
||||
* @return Collection
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function get(): Collection
|
||||
{
|
||||
|
@@ -40,10 +40,8 @@ use Psr\Container\NotFoundExceptionInterface;
|
||||
class RemoteUserGuard implements Guard
|
||||
{
|
||||
protected Application $application;
|
||||
/** @var UserProvider */
|
||||
protected $provider;
|
||||
/** @var User|null */
|
||||
protected $user;
|
||||
protected UserProvider $provider;
|
||||
protected User|null $user;
|
||||
|
||||
/**
|
||||
* Create a new authentication guard.
|
||||
@@ -159,10 +157,10 @@ class RemoteUserGuard implements Guard
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function id(): ?User
|
||||
public function id(): int|string|null
|
||||
{
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
return $this->user;
|
||||
return $this->user?->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -40,7 +40,7 @@ use Twig\TwigFunction;
|
||||
class General extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFilters(): array
|
||||
{
|
||||
|
@@ -33,7 +33,7 @@ use Twig\TwigFunction;
|
||||
class Rule extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFunctions(): array
|
||||
{
|
||||
|
@@ -38,8 +38,7 @@ use Twig\TwigFunction;
|
||||
class TransactionGroupTwig extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFunctions(): array
|
||||
{
|
||||
|
@@ -33,7 +33,7 @@ use Twig\TwigFunction;
|
||||
class Translation extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFilters(): array
|
||||
{
|
||||
|
@@ -33,7 +33,6 @@ use League\Fractal\Resource\Item;
|
||||
*/
|
||||
class BudgetLimitTransformer extends AbstractTransformer
|
||||
{
|
||||
/** @var string[] */
|
||||
protected array $availableIncludes
|
||||
= [
|
||||
'budget',
|
||||
|
@@ -32,7 +32,6 @@ use League\Fractal\Resource\Item;
|
||||
*/
|
||||
class BudgetLimitTransformer extends AbstractTransformer
|
||||
{
|
||||
/** @var string[] */
|
||||
protected array $availableIncludes
|
||||
= [
|
||||
'budget',
|
||||
|
20
app/User.php
20
app/User.php
@@ -176,34 +176,14 @@ class User extends Authenticatable
|
||||
use HasApiTokens;
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'blocked' => 'boolean',
|
||||
];
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['email', 'password', 'blocked', 'blocked_code'];
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['password', 'remember_token'];
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'users';
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user