Fix various phpmd issues.

This commit is contained in:
James Cole 2023-11-26 12:50:54 +01:00
parent 846c60fb85
commit 72ead65d9c
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
9 changed files with 44 additions and 22 deletions

View File

@ -43,8 +43,8 @@
</rule> </rule>
<rule ref="rulesets/design.xml/CouplingBetweenObjects"> <rule ref="rulesets/design.xml/CouplingBetweenObjects">
<properties> <properties>
<!-- TODO we want to be at minimum 13. But we start high, and drop the bar slowly. --> <!-- TODO we want to be at maximum 13. But we start high, and drop the bar slowly. -->
<property name="minimum" value="256"/> <property name="maximum" value="256"/>
</properties> </properties>
</rule> </rule>
@ -67,7 +67,7 @@
<rule ref="rulesets/codesize.xml/NPathComplexity"> <rule ref="rulesets/codesize.xml/NPathComplexity">
<properties> <properties>
<!-- TODO we want to be at a value of 128. But we start high, and drop the bar slowly. --> <!-- TODO we want to be at a value of 128. But we start high, and drop the bar slowly. -->
<property name="minimum" value="2267200"/> <property name="minimum" value="24062500"/>
</properties> </properties>
</rule> </rule>
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"> <rule ref="rulesets/codesize.xml/ExcessiveMethodLength">

View File

@ -62,7 +62,11 @@ class ExportController extends Controller
* @param ExportRequest $request * @param ExportRequest $request
* *
* @return LaravelResponse * @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException * @throws FireflyException
* @throws NotFoundExceptionInterface
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function accounts(ExportRequest $request): LaravelResponse public function accounts(ExportRequest $request): LaravelResponse
{ {
@ -108,7 +112,10 @@ class ExportController extends Controller
* @param ExportRequest $request * @param ExportRequest $request
* *
* @return LaravelResponse * @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException * @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function bills(ExportRequest $request): LaravelResponse public function bills(ExportRequest $request): LaravelResponse
{ {
@ -124,7 +131,10 @@ class ExportController extends Controller
* @param ExportRequest $request * @param ExportRequest $request
* *
* @return LaravelResponse * @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException * @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function budgets(ExportRequest $request): LaravelResponse public function budgets(ExportRequest $request): LaravelResponse
{ {
@ -140,7 +150,10 @@ class ExportController extends Controller
* @param ExportRequest $request * @param ExportRequest $request
* *
* @return LaravelResponse * @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException * @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function categories(ExportRequest $request): LaravelResponse public function categories(ExportRequest $request): LaravelResponse
{ {
@ -156,7 +169,10 @@ class ExportController extends Controller
* @param ExportRequest $request * @param ExportRequest $request
* *
* @return LaravelResponse * @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException * @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function piggyBanks(ExportRequest $request): LaravelResponse public function piggyBanks(ExportRequest $request): LaravelResponse
{ {
@ -172,7 +188,10 @@ class ExportController extends Controller
* @param ExportRequest $request * @param ExportRequest $request
* *
* @return LaravelResponse * @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException * @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function recurring(ExportRequest $request): LaravelResponse public function recurring(ExportRequest $request): LaravelResponse
{ {
@ -188,7 +207,10 @@ class ExportController extends Controller
* @param ExportRequest $request * @param ExportRequest $request
* *
* @return LaravelResponse * @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException * @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function rules(ExportRequest $request): LaravelResponse public function rules(ExportRequest $request): LaravelResponse
{ {
@ -204,7 +226,10 @@ class ExportController extends Controller
* @param ExportRequest $request * @param ExportRequest $request
* *
* @return LaravelResponse * @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException * @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function tags(ExportRequest $request): LaravelResponse public function tags(ExportRequest $request): LaravelResponse
{ {
@ -220,7 +245,9 @@ class ExportController extends Controller
* @param ExportRequest $request * @param ExportRequest $request
* *
* @return LaravelResponse * @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException * @throws FireflyException
* @throws NotFoundExceptionInterface
*/ */
public function transactions(ExportRequest $request): LaravelResponse public function transactions(ExportRequest $request): LaravelResponse
{ {

View File

@ -75,13 +75,11 @@ class ShowController extends Controller
* *
* Display a listing of the budget limits for this budget. * Display a listing of the budget limits for this budget.
* *
* @param Request $request * @param Budget $budget
* @param Budget $budget
* *
* @return JsonResponse * @return JsonResponse
* @throws FireflyException
*/ */
public function index(Request $request, Budget $budget): JsonResponse public function index(Budget $budget): JsonResponse
{ {
$manager = $this->getManager(); $manager = $this->getManager();
$manager->parseIncludes('budget'); $manager->parseIncludes('budget');
@ -111,7 +109,7 @@ class ShowController extends Controller
* @param SameDateRequest $request * @param SameDateRequest $request
* *
* @return JsonResponse * @return JsonResponse
* @throws FireflyException * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function indexAll(SameDateRequest $request): JsonResponse public function indexAll(SameDateRequest $request): JsonResponse
{ {
@ -138,14 +136,13 @@ class ShowController extends Controller
* This endpoint is documented at: * This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/getBudgetLimit * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/getBudgetLimit
* *
* @param Request $request
* @param Budget $budget * @param Budget $budget
* @param BudgetLimit $budgetLimit * @param BudgetLimit $budgetLimit
* *
* @return JsonResponse * @return JsonResponse
* @throws FireflyException * @throws FireflyException
*/ */
public function show(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse public function show(Budget $budget, BudgetLimit $budgetLimit): JsonResponse
{ {
if ($budget->id !== $budgetLimit->budget_id) { if ($budget->id !== $budgetLimit->budget_id) {
throw new FireflyException('20028: The budget limit does not belong to the budget.'); throw new FireflyException('20028: The budget limit does not belong to the budget.');

View File

@ -69,12 +69,9 @@ class ShowController extends Controller
* *
* Display a listing of the resource. * Display a listing of the resource.
* *
* @param Request $request
*
* @return JsonResponse * @return JsonResponse
* @throws FireflyException
*/ */
public function index(Request $request): JsonResponse public function index(): JsonResponse
{ {
$manager = $this->getManager(); $manager = $this->getManager();

View File

@ -42,13 +42,12 @@ class CronController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/about/getCron * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/about/getCron
* *
* @param CronRequest $request * @param CronRequest $request
* @param string $token
* *
* @return JsonResponse * @return JsonResponse
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function cron(CronRequest $request, string $token): JsonResponse public function cron(CronRequest $request): JsonResponse
{ {
$config = $request->getAll(); $config = $request->getAll();

View File

@ -123,12 +123,12 @@ class AccountController extends Controller
usort( usort(
$allItems, $allItems,
static function (array $a, array $b): int { static function (array $left, array $right): int {
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE]; $order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
$pos_a = (int)array_search($a['type'], $order, true); $posLeft = (int)array_search($left['type'], $order, true);
$pos_b = (int)array_search($b['type'], $order, true); $posRight = (int)array_search($right['type'], $order, true);
return $pos_a - $pos_b; return $posLeft - $posRight;
} }
); );
return response()->json($allItems); return response()->json($allItems);

View File

@ -84,6 +84,7 @@ class AccountController extends Controller
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
* @throws FireflyException * @throws FireflyException
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function dashboard(DateRequest $request): JsonResponse public function dashboard(DateRequest $request): JsonResponse
{ {

View File

@ -54,7 +54,7 @@ class CLIToken implements BinderInterface
foreach ($users as $user) { foreach ($users as $user) {
$accessToken = app('preferences')->getForUser($user, 'access_token'); $accessToken = app('preferences')->getForUser($user, 'access_token');
if (null !== $accessToken && $accessToken->data === $value) { if (null !== $accessToken && $accessToken->data === $value) {
app('log')->info(sprintf('Recognized user #%d (%s) from his acccess token.', $user->id, $user->email)); app('log')->info(sprintf('Recognized user #%d (%s) from his access token.', $user->id, $user->email));
return $value; return $value;
} }

View File

@ -520,7 +520,8 @@ class User extends Authenticatable
*/ */
public function routeNotificationFor($driver, $notification = null) public function routeNotificationFor($driver, $notification = null)
{ {
if (method_exists($this, $method = 'routeNotificationFor' . Str::studly($driver))) { $method = 'routeNotificationFor' . Str::studly($driver);
if (method_exists($this, $method)) {
return $this->{$method}($notification); // @phpstan-ignore-line return $this->{$method}($notification); // @phpstan-ignore-line
} }
$email = $this->email; $email = $this->email;