Various code cleanup.

This commit is contained in:
James Cole
2023-12-22 20:12:38 +01:00
parent 067d160c13
commit 581e5d7330
69 changed files with 361 additions and 317 deletions

View File

@@ -44,8 +44,7 @@ EXIT_CODE=$?
cd $SCRIPT_DIR/.. cd $SCRIPT_DIR/..
echo "Exit code is $EXIT_CODE, but we ignore this for the time being." echo "Exit code is $EXIT_CODE."
# for the time being, exit 0 # for the time being, exit 0
#exit $EXIT_CODE exit $EXIT_CODE
exit 0

View File

@@ -37,14 +37,14 @@
<rule ref="rulesets/design.xml/NumberOfChildren"> <rule ref="rulesets/design.xml/NumberOfChildren">
<properties> <properties>
<!-- TODO we want to be at minimum 15. But we start high, and drop the bar slowly. --> <!-- This is now at 32, which excludes the controllers but should prevent more monoliths. -->
<property name="minimum" value="256"/> <property name="minimum" value="32"/>
</properties> </properties>
</rule> </rule>
<rule ref="rulesets/design.xml/CouplingBetweenObjects"> <rule ref="rulesets/design.xml/CouplingBetweenObjects">
<properties> <properties>
<!-- TODO we want to be at maximum 13. But we start high, and drop the bar slowly. --> <!-- Leaving this at 28 excuses most current code but it can't get worse than that. -->
<property name="maximum" value="256"/> <property name="maximum" value="28"/>
</properties> </properties>
</rule> </rule>
@@ -58,14 +58,15 @@
<!-- code size --> <!-- code size -->
<rule ref="rulesets/codesize.xml/CyclomaticComplexity"> <rule ref="rulesets/codesize.xml/CyclomaticComplexity">
<properties> <properties>
<!-- TODO we want to be at report level 5. But we start high, and drop the bar slowly. --> <!-- Leave at 20. This means methods will be pretty complex before the system starts complaining. -->
<property name="reportLevel" value="500"/> <property name="reportLevel" value="20"/>
</properties> </properties>
</rule> </rule>
<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. --> <!-- 2000 results in some pretty complex methods, but it's OK. -->
<property name="minimum" value="24062500"/> <!-- They should not be much more complex than that though -->
<property name="minimum" value="2000"/>
</properties> </properties>
</rule> </rule>
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"> <rule ref="rulesets/codesize.xml/ExcessiveMethodLength">

View File

@@ -40,6 +40,9 @@ use Symfony\Component\HttpFoundation\ParameterBag;
/** /**
* Class Controller. * Class Controller.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.NumberOfChildren)
*/ */
abstract class Controller extends BaseController abstract class Controller extends BaseController
{ {

View File

@@ -71,7 +71,7 @@ class ShowController extends Controller
* Display a listing of the resource. * Display a listing of the resource.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function index(): JsonResponse public function index(): JsonResponse
{ {
$pageSize = $this->parameters->get('limit'); $pageSize = $this->parameters->get('limit');
@@ -101,7 +101,7 @@ class ShowController extends Controller
* Show a currency. * Show a currency.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function show(TransactionCurrency $currency): JsonResponse public function show(TransactionCurrency $currency): JsonResponse
{ {
/** @var User $user */ /** @var User $user */
@@ -129,7 +129,7 @@ class ShowController extends Controller
* Show a currency. * Show a currency.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function showDefault(): JsonResponse public function showDefault(): JsonResponse
{ {
/** @var User $user */ /** @var User $user */

View File

@@ -68,7 +68,7 @@ class StoreController extends Controller
* Store new currency. * Store new currency.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function store(StoreRequest $request): JsonResponse public function store(StoreRequest $request): JsonResponse
{ {
$currency = $this->repository->store($request->getAll()); $currency = $this->repository->store($request->getAll());

View File

@@ -69,7 +69,7 @@ class UpdateController extends Controller
* Disable a currency. * Disable a currency.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function disable(TransactionCurrency $currency): JsonResponse public function disable(TransactionCurrency $currency): JsonResponse
{ {
// must be unused. // must be unused.
@@ -133,7 +133,7 @@ class UpdateController extends Controller
* Enable a currency. * Enable a currency.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function enable(TransactionCurrency $currency): JsonResponse public function enable(TransactionCurrency $currency): JsonResponse
{ {
$this->repository->enable($currency); $this->repository->enable($currency);
@@ -160,7 +160,7 @@ class UpdateController extends Controller
* Update a currency. * Update a currency.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function update(UpdateRequest $request, TransactionCurrency $currency): JsonResponse public function update(UpdateRequest $request, TransactionCurrency $currency): JsonResponse
{ {
$data = $request->getAll(); $data = $request->getAll();

View File

@@ -45,6 +45,9 @@ use Symfony\Component\HttpFoundation\ParameterBag;
/** /**
* Class Controller * Class Controller
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.NumberOfChildren)
*/ */
class Controller extends BaseController class Controller extends BaseController
{ {
@@ -104,6 +107,8 @@ class Controller extends BaseController
/** /**
* TODO duplicate from V1 controller * TODO duplicate from V1 controller
* Method to grab all parameters from the URL. * Method to grab all parameters from the URL.
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/ */
private function getParameters(): ParameterBag private function getParameters(): ParameterBag
{ {

View File

@@ -45,6 +45,8 @@ class GracefulNotFoundHandler extends ExceptionHandler
* @param Request $request * @param Request $request
* *
* @throws \Throwable * @throws \Throwable
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
public function render($request, \Throwable $e): Response public function render($request, \Throwable $e): Response
{ {

View File

@@ -65,11 +65,15 @@ class Handler extends ExceptionHandler
]; ];
/** /**
* Render an exception into an HTTP response. * Render an exception into an HTTP response. It's complex but lucky for us, we never use it because
* Firefly III never crashes.
* *
* @param Request $request * @param Request $request
* *
* @throws \Throwable * @throws \Throwable
*
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
public function render($request, \Throwable $e): Response public function render($request, \Throwable $e): Response
{ {

View File

@@ -68,7 +68,7 @@ class AccountFactory
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function findOrCreate(string $accountName, string $accountType): Account public function findOrCreate(string $accountName, string $accountType): Account
{ {
app('log')->debug(sprintf('findOrCreate("%s", "%s")', $accountName, $accountType)); app('log')->debug(sprintf('findOrCreate("%s", "%s")', $accountName, $accountType));
@@ -100,7 +100,7 @@ class AccountFactory
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function create(array $data): Account public function create(array $data): Account
{ {
app('log')->debug('Now in AccountFactory::create()'); app('log')->debug('Now in AccountFactory::create()');
@@ -171,7 +171,7 @@ class AccountFactory
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
private function createAccount(AccountType $type, array $data): Account private function createAccount(AccountType $type, array $data): Account
{ {
$this->accountRepository->resetAccountOrder(); $this->accountRepository->resetAccountOrder();
@@ -239,7 +239,7 @@ class AccountFactory
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
private function cleanMetaDataArray(Account $account, array $data): array private function cleanMetaDataArray(Account $account, array $data): array
{ {
$currencyId = array_key_exists('currency_id', $data) ? (int)$data['currency_id'] : 0; $currencyId = array_key_exists('currency_id', $data) ? (int)$data['currency_id'] : 0;

View File

@@ -43,7 +43,7 @@ class BillFactory
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function create(array $data): ?Bill public function create(array $data): ?Bill
{ {
app('log')->debug(sprintf('Now in %s', __METHOD__), $data); app('log')->debug(sprintf('Now in %s', __METHOD__), $data);

View File

@@ -52,7 +52,9 @@ class RecurrenceFactory
/** /**
* @throws FireflyException * @throws FireflyException
* */ *
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function create(array $data): Recurrence public function create(array $data): Recurrence
{ {
try { try {

View File

@@ -49,7 +49,7 @@ class TransactionGroupFactory
* *
* @throws DuplicateTransactionException * @throws DuplicateTransactionException
* @throws FireflyException * @throws FireflyException
* */ */
public function create(array $data): TransactionGroup public function create(array $data): TransactionGroup
{ {
app('log')->debug('Now in TransactionGroupFactory::create()'); app('log')->debug('Now in TransactionGroupFactory::create()');

View File

@@ -91,7 +91,7 @@ class TransactionJournalFactory
* *
* @throws DuplicateTransactionException * @throws DuplicateTransactionException
* @throws FireflyException * @throws FireflyException
* */ */
public function create(array $data): Collection public function create(array $data): Collection
{ {
app('log')->debug('Now in TransactionJournalFactory::create()'); app('log')->debug('Now in TransactionJournalFactory::create()');
@@ -344,7 +344,7 @@ class TransactionJournalFactory
* If this transaction already exists, throw an error. * If this transaction already exists, throw an error.
* *
* @throws DuplicateTransactionException * @throws DuplicateTransactionException
* */ */
private function errorIfDuplicate(string $hash): void private function errorIfDuplicate(string $hash): void
{ {
app('log')->debug(sprintf('In errorIfDuplicate(%s)', $hash)); app('log')->debug(sprintf('In errorIfDuplicate(%s)', $hash));
@@ -442,7 +442,7 @@ class TransactionJournalFactory
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
private function getCurrencyByAccount(string $type, ?TransactionCurrency $currency, Account $source, Account $destination): TransactionCurrency private function getCurrencyByAccount(string $type, ?TransactionCurrency $currency, Account $source, Account $destination): TransactionCurrency
{ {
app('log')->debug('Now in getCurrencyByAccount()'); app('log')->debug('Now in getCurrencyByAccount()');
@@ -455,7 +455,7 @@ class TransactionJournalFactory
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
private function getCurrency(?TransactionCurrency $currency, Account $account): TransactionCurrency private function getCurrency(?TransactionCurrency $currency, Account $account): TransactionCurrency
{ {
app('log')->debug('Now in getCurrency()'); app('log')->debug('Now in getCurrency()');
@@ -489,7 +489,7 @@ class TransactionJournalFactory
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
private function getForeignByAccount(string $type, ?TransactionCurrency $foreignCurrency, Account $destination): ?TransactionCurrency private function getForeignByAccount(string $type, ?TransactionCurrency $foreignCurrency, Account $destination): ?TransactionCurrency
{ {
if (TransactionType::TRANSFER === $type) { if (TransactionType::TRANSFER === $type) {

View File

@@ -45,7 +45,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
* Generates the report. * Generates the report.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function generate(): string public function generate(): string
{ {
$auditData = []; $auditData = [];
@@ -110,7 +110,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
* Get the audit report. * Get the audit report.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function getAuditReport(Account $account, Carbon $date): array public function getAuditReport(Account $account, Carbon $date): array
{ {
/** @var AccountRepositoryInterface $accountRepository */ /** @var AccountRepositoryInterface $accountRepository */

View File

@@ -115,7 +115,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
private function runWebhook(Webhook $webhook): void private function runWebhook(Webhook $webhook): void
{ {
app('log')->debug(sprintf('Now in runWebhook(#%d)', $webhook->id)); app('log')->debug(sprintf('Now in runWebhook(#%d)', $webhook->id));
@@ -128,7 +128,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
private function generateMessage(Webhook $webhook, Model $model): void private function generateMessage(Webhook $webhook, Model $model): void
{ {
$class = get_class($model); $class = get_class($model);

View File

@@ -67,7 +67,9 @@ class EditController extends Controller
} }
/** /**
* Edit account overview. * Edit account overview. It's complex, but it just has a lot of if/then/else.
*
* @SuppressWarnings(PHPMD.NPathComplexity)
* *
* @return Factory|Redirector|RedirectResponse|View * @return Factory|Redirector|RedirectResponse|View
*/ */

View File

@@ -146,7 +146,7 @@ class ReconcileController extends Controller
* @return Redirector|RedirectResponse * @return Redirector|RedirectResponse
* *
* @throws DuplicateTransactionException * @throws DuplicateTransactionException
* */ */
public function submit(ReconciliationStoreRequest $request, Account $account, Carbon $start, Carbon $end) public function submit(ReconciliationStoreRequest $request, Account $account, Carbon $start, Carbon $end)
{ {
if (!$this->isEditableAccount($account)) { if (!$this->isEditableAccount($account)) {
@@ -188,7 +188,7 @@ class ReconcileController extends Controller
* Creates a reconciliation group. * Creates a reconciliation group.
* *
* @throws DuplicateTransactionException * @throws DuplicateTransactionException
* */ */
private function createReconciliation(Account $account, Carbon $start, Carbon $end, string $difference): string private function createReconciliation(Account $account, Carbon $start, Carbon $end, string $difference): string
{ {
if (!$this->isEditableAccount($account)) { if (!$this->isEditableAccount($account)) {

View File

@@ -76,8 +76,7 @@ class AccountController extends Controller
* Shows the balances for all the user's expense accounts (on the front page). * Shows the balances for all the user's expense accounts (on the front page).
* *
* This chart is (multi) currency aware. * This chart is (multi) currency aware.
* */
* */
public function expenseAccounts(): JsonResponse public function expenseAccounts(): JsonResponse
{ {
/** @var Carbon $start */ /** @var Carbon $start */
@@ -380,7 +379,7 @@ class AccountController extends Controller
* Shows overview of account during a single period. * Shows overview of account during a single period.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function period(Account $account, Carbon $start, Carbon $end): JsonResponse public function period(Account $account, Carbon $start, Carbon $end): JsonResponse
{ {
$chartData = []; $chartData = [];
@@ -416,7 +415,7 @@ class AccountController extends Controller
* TODO this chart is not multi currency aware. * TODO this chart is not multi currency aware.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function report(Collection $accounts, Carbon $start, Carbon $end): JsonResponse public function report(Collection $accounts, Carbon $start, Carbon $end): JsonResponse
{ {
return response()->json($this->accountBalanceChart($accounts, $start, $end)); return response()->json($this->accountBalanceChart($accounts, $start, $end));
@@ -426,8 +425,7 @@ class AccountController extends Controller
* Shows the balances for all the user's revenue accounts. * Shows the balances for all the user's revenue accounts.
* *
* This chart is multi-currency aware. * This chart is multi-currency aware.
* */
* */
public function revenueAccounts(): JsonResponse public function revenueAccounts(): JsonResponse
{ {
/** @var Carbon $start */ /** @var Carbon $start */
@@ -517,7 +515,7 @@ class AccountController extends Controller
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
private function periodByCurrency(Carbon $start, Carbon $end, Account $account, TransactionCurrency $currency): array private function periodByCurrency(Carbon $start, Carbon $end, Account $account, TransactionCurrency $currency): array
{ {
app('log')->debug(sprintf('Now in periodByCurrency("%s", "%s", %s, "%s")', $start->format('Y-m-d'), $end->format('Y-m-d'), $account->id, $currency->code)); app('log')->debug(sprintf('Now in periodByCurrency("%s", "%s", %s, "%s")', $start->format('Y-m-d'), $end->format('Y-m-d'), $account->id, $currency->code));

View File

@@ -32,6 +32,9 @@ use Illuminate\Routing\Controller as BaseController;
/** /**
* Class Controller. * Class Controller.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.NumberOfChildren)
*/ */
abstract class Controller extends BaseController abstract class Controller extends BaseController
{ {

View File

@@ -65,7 +65,7 @@ class ReconcileController extends Controller
* Overview of reconciliation. * Overview of reconciliation.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function overview(Request $request, Account $account = null, Carbon $start = null, Carbon $end = null): JsonResponse public function overview(Request $request, Account $account = null, Carbon $start = null, Carbon $end = null): JsonResponse
{ {
$startBalance = $request->get('startBalance'); $startBalance = $request->get('startBalance');
@@ -165,7 +165,7 @@ class ReconcileController extends Controller
* @return JsonResponse * @return JsonResponse
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function transactions(Account $account, Carbon $start = null, Carbon $end = null) public function transactions(Account $account, Carbon $start = null, Carbon $end = null)
{ {
if (null === $start || null === $end) { if (null === $start || null === $end) {

View File

@@ -59,6 +59,8 @@ class RecurrenceController extends Controller
/** /**
* Shows all events for a repetition. Used in calendar. * Shows all events for a repetition. Used in calendar.
* *
* @SuppressWarnings(PHPMD.NPathComplexity)
*
* @throws FireflyException * @throws FireflyException
*/ */
public function events(Request $request): JsonResponse public function events(Request $request): JsonResponse

View File

@@ -74,7 +74,7 @@ class IndexController extends Controller
* @return Factory|View * @return Factory|View
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function index() public function index()
{ {
$this->cleanupObjectGroups(); $this->cleanupObjectGroups();

View File

@@ -66,7 +66,7 @@ class ShowController extends Controller
* @return Factory|View * @return Factory|View
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function show(PiggyBank $piggyBank) public function show(PiggyBank $piggyBank)
{ {
/** @var Carbon $end */ /** @var Carbon $end */

View File

@@ -150,6 +150,7 @@ class PreferencesController extends Controller
* @throws FireflyException * @throws FireflyException
* *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/ */
public function postIndex(Request $request) public function postIndex(Request $request)
{ {

View File

@@ -66,7 +66,7 @@ class BudgetController extends Controller
* @return Factory|View * @return Factory|View
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function accountPerBudget(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end) public function accountPerBudget(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end)
{ {
/** @var BudgetReportGenerator $generator */ /** @var BudgetReportGenerator $generator */
@@ -257,7 +257,7 @@ class BudgetController extends Controller
* @return string * @return string
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function general(Collection $accounts, Carbon $start, Carbon $end) public function general(Collection $accounts, Carbon $start, Carbon $end)
{ {
/** @var BudgetReportGenerator $generator */ /** @var BudgetReportGenerator $generator */

View File

@@ -85,6 +85,8 @@ use Laravel\Passport\Events\AccessTokenCreated;
/** /**
* Class EventServiceProvider. * Class EventServiceProvider.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/ */
class EventServiceProvider extends ServiceProvider class EventServiceProvider extends ServiceProvider
{ {

View File

@@ -75,6 +75,8 @@ use Illuminate\Support\ServiceProvider;
/** /**
* Class FireflyServiceProvider. * Class FireflyServiceProvider.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/ */
class FireflyServiceProvider extends ServiceProvider class FireflyServiceProvider extends ServiceProvider
{ {

View File

@@ -221,7 +221,7 @@ class AccountRepository implements AccountRepositoryInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function getCashAccount(): Account public function getCashAccount(): Account
{ {
/** @var AccountType $type */ /** @var AccountType $type */
@@ -342,7 +342,7 @@ class AccountRepository implements AccountRepositoryInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function getReconciliation(Account $account): ?Account public function getReconciliation(Account $account): ?Account
{ {
if (AccountType::ASSET !== $account->accountType->type) { if (AccountType::ASSET !== $account->accountType->type) {
@@ -617,7 +617,7 @@ class AccountRepository implements AccountRepositoryInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function store(array $data): Account public function store(array $data): Account
{ {
/** @var AccountFactory $factory */ /** @var AccountFactory $factory */
@@ -629,7 +629,7 @@ class AccountRepository implements AccountRepositoryInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function update(Account $account, array $data): Account public function update(Account $account, array $data): Account
{ {
/** @var AccountUpdateService $service */ /** @var AccountUpdateService $service */

View File

@@ -42,7 +42,7 @@ class AccountTasker implements AccountTaskerInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function getAccountReport(Collection $accounts, Carbon $start, Carbon $end): array public function getAccountReport(Collection $accounts, Carbon $start, Carbon $end): array
{ {
$yesterday = clone $start; $yesterday = clone $start;
@@ -109,7 +109,7 @@ class AccountTasker implements AccountTaskerInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function getExpenseReport(Carbon $start, Carbon $end, Collection $accounts): array public function getExpenseReport(Carbon $start, Carbon $end, Collection $accounts): array
{ {
// get all expenses for the given accounts in the given period! // get all expenses for the given accounts in the given period!
@@ -140,7 +140,7 @@ class AccountTasker implements AccountTaskerInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function getIncomeReport(Carbon $start, Carbon $end, Collection $accounts): array public function getIncomeReport(Carbon $start, Carbon $end, Collection $accounts): array
{ {
// get all incomes for the given accounts in the given period! // get all incomes for the given accounts in the given period!
@@ -175,7 +175,7 @@ class AccountTasker implements AccountTaskerInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
private function groupExpenseByDestination(array $array): array private function groupExpenseByDestination(array $array): array
{ {
$defaultCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup); $defaultCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);
@@ -235,7 +235,7 @@ class AccountTasker implements AccountTaskerInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
private function groupIncomeBySource(array $array): array private function groupIncomeBySource(array $array): array
{ {
$defaultCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup); $defaultCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);

View File

@@ -218,6 +218,7 @@ class OperationsRepository implements OperationsRepositoryInterface
/** /**
* @SuppressWarnings(PHPMD.ExcessiveParameterList) * @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/ */
private function getTransactionsForSum( private function getTransactionsForSum(
string $type, string $type,

View File

@@ -421,8 +421,7 @@ class BillRepository implements BillRepositoryInterface
/** /**
* Given the date in $date, this method will return a moment in the future where the bill is expected to be paid. * Given the date in $date, this method will return a moment in the future where the bill is expected to be paid.
* */
* */
public function nextExpectedMatch(Bill $bill, Carbon $date): Carbon public function nextExpectedMatch(Bill $bill, Carbon $date): Carbon
{ {
$cache = new CacheProperties(); $cache = new CacheProperties();
@@ -463,7 +462,7 @@ class BillRepository implements BillRepositoryInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function store(array $data): Bill public function store(array $data): Bill
{ {
/** @var BillFactory $factory */ /** @var BillFactory $factory */
@@ -643,7 +642,7 @@ class BillRepository implements BillRepositoryInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function update(Bill $bill, array $data): Bill public function update(Bill $bill, array $data): Bill
{ {
/** @var BillUpdateService $service */ /** @var BillUpdateService $service */

View File

@@ -261,7 +261,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function store(array $data): BudgetLimit public function store(array $data): BudgetLimit
{ {
// if no currency has been provided, use the user's default currency: // if no currency has been provided, use the user's default currency:
@@ -316,7 +316,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function update(BudgetLimit $budgetLimit, array $data): BudgetLimit public function update(BudgetLimit $budgetLimit, array $data): BudgetLimit
{ {
$budgetLimit->amount = array_key_exists('amount', $data) ? $data['amount'] : $budgetLimit->amount; $budgetLimit->amount = array_key_exists('amount', $data) ? $data['amount'] : $budgetLimit->amount;

View File

@@ -233,7 +233,7 @@ class BudgetRepository implements BudgetRepositoryInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function update(Budget $budget, array $data): Budget public function update(Budget $budget, array $data): Budget
{ {
app('log')->debug('Now in update()'); app('log')->debug('Now in update()');
@@ -564,7 +564,9 @@ class BudgetRepository implements BudgetRepositoryInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ *
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function store(array $data): Budget public function store(array $data): Budget
{ {
$order = $this->getMaxOrder(); $order = $this->getMaxOrder();
@@ -750,7 +752,7 @@ class BudgetRepository implements BudgetRepositoryInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
private function updateAutoBudget(Budget $budget, array $data): void private function updateAutoBudget(Budget $budget, array $data): void
{ {
// update or create auto-budget: // update or create auto-budget:

View File

@@ -135,7 +135,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
* Used for connecting to a piggy bank. * Used for connecting to a piggy bank.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function getExactAmount(PiggyBank $piggyBank, PiggyBankRepetition $repetition, TransactionJournal $journal): string public function getExactAmount(PiggyBank $piggyBank, PiggyBankRepetition $repetition, TransactionJournal $journal): string
{ {
app('log')->debug(sprintf('Now in getExactAmount(%d, %d, %d)', $piggyBank->id, $repetition->id, $journal->id)); app('log')->debug(sprintf('Now in getExactAmount(%d, %d, %d)', $piggyBank->id, $repetition->id, $journal->id));
@@ -318,8 +318,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
/** /**
* Get for piggy account what is left to put in piggies. * Get for piggy account what is left to put in piggies.
* */
* */
public function leftOnAccount(PiggyBank $piggyBank, Carbon $date): string public function leftOnAccount(PiggyBank $piggyBank, Carbon $date): string
{ {
$balance = app('steam')->balanceIgnoreVirtual($piggyBank->account, $date); $balance = app('steam')->balanceIgnoreVirtual($piggyBank->account, $date);

View File

@@ -258,8 +258,7 @@ class RecurringRepository implements RecurringRepositoryInterface
/** /**
* Get the tags from the recurring transaction. * Get the tags from the recurring transaction.
* */
* */
public function getTags(RecurrenceTransaction $transaction): array public function getTags(RecurrenceTransaction $transaction): array
{ {
$tags = []; $tags = [];
@@ -479,7 +478,7 @@ class RecurringRepository implements RecurringRepositoryInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function store(array $data): Recurrence public function store(array $data): Recurrence
{ {
/** @var RecurrenceFactory $factory */ /** @var RecurrenceFactory $factory */

View File

@@ -255,7 +255,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
* Return all piggy bank events for all journals in the group. * Return all piggy bank events for all journals in the group.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function getPiggyEvents(TransactionGroup $group): array public function getPiggyEvents(TransactionGroup $group): array
{ {
$return = []; $return = [];
@@ -318,7 +318,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
/** /**
* @throws DuplicateTransactionException * @throws DuplicateTransactionException
* @throws FireflyException * @throws FireflyException
* */ */
public function store(array $data): TransactionGroup public function store(array $data): TransactionGroup
{ {
/** @var TransactionGroupFactory $factory */ /** @var TransactionGroupFactory $factory */

View File

@@ -157,6 +157,8 @@ class UserGroupRepository implements UserGroupRepositoryInterface
} }
/** /**
* @SuppressWarnings(PHPMD.NPathComplexity)
*
* @throws FireflyException * @throws FireflyException
*/ */
public function updateMembership(UserGroup $userGroup, array $data): UserGroup public function updateMembership(UserGroup $userGroup, array $data): UserGroup

View File

@@ -217,7 +217,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
* Find by object, ID or code. Returns user default or system default. * Find by object, ID or code. Returns user default or system default.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function findCurrency(?int $currencyId, ?string $currencyCode): TransactionCurrency public function findCurrency(?int $currencyId, ?string $currencyCode): TransactionCurrency
{ {
$result = $this->findCurrencyNull($currencyId, $currencyCode); $result = $this->findCurrencyNull($currencyId, $currencyCode);

View File

@@ -88,6 +88,8 @@ trait AccountServiceTrait
/** /**
* Update metadata for account. Depends on type which fields are valid. * Update metadata for account. Depends on type which fields are valid.
* *
* @SuppressWarnings(PHPMD.NPathComplexity)
*
* TODO this method treats expense accounts and liabilities the same way (tries to save interest) * TODO this method treats expense accounts and liabilities the same way (tries to save interest)
*/ */
public function updateMetaData(Account $account, array $data): void public function updateMetaData(Account $account, array $data): void
@@ -336,7 +338,7 @@ trait AccountServiceTrait
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
protected function getCurrency(int $currencyId, string $currencyCode): TransactionCurrency protected function getCurrency(int $currencyId, string $currencyCode): TransactionCurrency
{ {
// find currency, or use default currency instead. // find currency, or use default currency instead.
@@ -360,7 +362,7 @@ trait AccountServiceTrait
* Create the opposing "credit liability" transaction for credit liabilities. * Create the opposing "credit liability" transaction for credit liabilities.
* *
* @throws FireflyException * @throws FireflyException
* */ */
protected function updateCreditTransaction(Account $account, string $direction, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup protected function updateCreditTransaction(Account $account, string $direction, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup
{ {
app('log')->debug(sprintf('Now in %s', __METHOD__)); app('log')->debug(sprintf('Now in %s', __METHOD__));
@@ -416,7 +418,7 @@ trait AccountServiceTrait
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
protected function createCreditTransaction(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup protected function createCreditTransaction(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup
{ {
app('log')->debug('Now going to create an createCreditTransaction.'); app('log')->debug('Now going to create an createCreditTransaction.');
@@ -510,7 +512,7 @@ trait AccountServiceTrait
* Since opening balance and date can still be empty strings, it may fail. * Since opening balance and date can still be empty strings, it may fail.
* *
* @throws FireflyException * @throws FireflyException
* */ */
protected function updateOBGroupV2(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup protected function updateOBGroupV2(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup
{ {
app('log')->debug(sprintf('Now in %s', __METHOD__)); app('log')->debug(sprintf('Now in %s', __METHOD__));
@@ -566,7 +568,7 @@ trait AccountServiceTrait
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
protected function createOBGroupV2(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup protected function createOBGroupV2(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup
{ {
app('log')->debug('Now going to create an OB group.'); app('log')->debug('Now going to create an OB group.');

View File

@@ -243,7 +243,11 @@ class CreditRecalculateService
} }
/** /**
* A complex and long method, but rarely used luckily.
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
private function processTransaction(Account $account, string $direction, Transaction $transaction, string $leftOfDebt): string private function processTransaction(Account $account, string $direction, Transaction $transaction, string $leftOfDebt): string
{ {

View File

@@ -87,7 +87,9 @@ trait RecurringTransactionTrait
* Store transactions of a recurring transactions. It's complex but readable. * Store transactions of a recurring transactions. It's complex but readable.
* *
* @throws FireflyException * @throws FireflyException
* */ *
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function createTransactions(Recurrence $recurrence, array $transactions): void protected function createTransactions(Recurrence $recurrence, array $transactions): void
{ {
app('log')->debug('Now in createTransactions()'); app('log')->debug('Now in createTransactions()');

View File

@@ -63,7 +63,7 @@ class AccountUpdateService
* Update account data. * Update account data.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function update(Account $account, array $data): Account public function update(Account $account, array $data): Account
{ {
app('log')->debug(sprintf('Now in %s', __METHOD__)); app('log')->debug(sprintf('Now in %s', __METHOD__));

View File

@@ -46,7 +46,7 @@ class BillUpdateService
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function update(Bill $bill, array $data): Bill public function update(Bill $bill, array $data): Bill
{ {
$this->user = $bill->user; $this->user = $bill->user;
@@ -129,6 +129,9 @@ class BillUpdateService
return $bill; return $bill;
} }
/**
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
private function updateBillProperties(Bill $bill, array $data): Bill private function updateBillProperties(Bill $bill, array $data): Bill
{ {
if (array_key_exists('name', $data) && '' !== (string) $data['name']) { if (array_key_exists('name', $data) && '' !== (string) $data['name']) {

View File

@@ -41,7 +41,7 @@ class GroupUpdateService
* *
* @throws DuplicateTransactionException * @throws DuplicateTransactionException
* @throws FireflyException * @throws FireflyException
* */ */
public function update(TransactionGroup $transactionGroup, array $data): TransactionGroup public function update(TransactionGroup $transactionGroup, array $data): TransactionGroup
{ {
app('log')->debug(sprintf('Now in %s', __METHOD__)); app('log')->debug(sprintf('Now in %s', __METHOD__));
@@ -149,7 +149,7 @@ class GroupUpdateService
/** /**
* @throws DuplicateTransactionException * @throws DuplicateTransactionException
* @throws FireflyException * @throws FireflyException
* */ */
private function updateTransactions(TransactionGroup $transactionGroup, array $transactions): array private function updateTransactions(TransactionGroup $transactionGroup, array $transactions): array
{ {
app('log')->debug(sprintf('Now in %s', __METHOD__)); app('log')->debug(sprintf('Now in %s', __METHOD__));
@@ -206,7 +206,7 @@ class GroupUpdateService
/** /**
* @throws DuplicateTransactionException * @throws DuplicateTransactionException
* @throws FireflyException * @throws FireflyException
* */ */
private function createTransactionJournal(TransactionGroup $transactionGroup, array $data): ?TransactionJournal private function createTransactionJournal(TransactionGroup $transactionGroup, array $data): ?TransactionJournal
{ {
$submission = [ $submission = [

View File

@@ -192,7 +192,7 @@ class RecurrenceUpdateService
* TODO this method is very complex. * TODO this method is very complex.
* *
* @throws FireflyException * @throws FireflyException
* */ */
private function updateTransactions(Recurrence $recurrence, array $transactions): void private function updateTransactions(Recurrence $recurrence, array $transactions): void
{ {
app('log')->debug('Now in updateTransactions()'); app('log')->debug('Now in updateTransactions()');
@@ -244,17 +244,22 @@ class RecurrenceUpdateService
$this->createTransactions($recurrence, $transactions); $this->createTransactions($recurrence, $transactions);
} }
/**
* It's a complex method but nothing surprising.
*
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
private function updateCombination(Recurrence $recurrence, array $combination): void private function updateCombination(Recurrence $recurrence, array $combination): void
{ {
$original = $combination['original']; $original = $combination['original'];
$submitted = $combination['submitted']; $submitted = $combination['submitted'];
$currencyFactory = app(TransactionCurrencyFactory::class);
/** @var RecurrenceTransaction $transaction */ /** @var RecurrenceTransaction $transaction */
$transaction = $recurrence->recurrenceTransactions()->find($original['id']); $transaction = $recurrence->recurrenceTransactions()->find($original['id']);
app('log')->debug(sprintf('Now in updateCombination(#%d)', $original['id'])); app('log')->debug(sprintf('Now in updateCombination(#%d)', $original['id']));
$currencyFactory = app(TransactionCurrencyFactory::class);
// loop all and try to match them: // loop all and try to match them:
$currency = null; $currency = null;
$foreignCurrency = null; $foreignCurrency = null;

View File

@@ -40,7 +40,7 @@ trait ChartGeneration
* Shows an overview of the account balances for a set of accounts. * Shows an overview of the account balances for a set of accounts.
* *
* @throws FireflyException * @throws FireflyException
* */ */
protected function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array // chart helper method. protected function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array // chart helper method.
{ {
// chart properties for cache: // chart properties for cache:

View File

@@ -70,6 +70,8 @@ class ParseDateString
/** /**
* @throws FireflyException * @throws FireflyException
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/ */
public function parseDate(string $date): Carbon public function parseDate(string $date): Carbon
{ {

View File

@@ -134,7 +134,7 @@ class BudgetReportGenerator
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
public function setUser(User $user): void public function setUser(User $user): void
{ {
$this->repository->setUser($user); $this->repository->setUser($user);

View File

@@ -31,59 +31,24 @@ trait GetRecurrenceData
protected function getSingleTransactionData(array $transaction): array protected function getSingleTransactionData(array $transaction): array
{ {
$return = []; $return = [];
$stringKeys = ['id'];
$intKeys = ['currency_id', 'foreign_currency_id', 'source_id', 'destination_id', 'bill_id', 'piggy_bank_id', 'bill_id', 'budget_id', 'category_id'];
$keys = ['amount', 'currency_code', 'foreign_amount', 'foreign_currency_code', 'description', 'tags'];
if (array_key_exists('id', $transaction)) { foreach ($stringKeys as $key) {
$return['id'] = (string)$transaction['id']; if (array_key_exists($key, $transaction)) {
$return[$key] = (string) $transaction[$key];
} }
// amount + currency
if (array_key_exists('amount', $transaction)) {
$return['amount'] = $transaction['amount'];
} }
if (array_key_exists('currency_id', $transaction)) { foreach ($intKeys as $key) {
$return['currency_id'] = (int)$transaction['currency_id']; if (array_key_exists($key, $transaction)) {
$return[$key] = (int) $transaction[$key];
} }
if (array_key_exists('currency_code', $transaction)) {
$return['currency_code'] = $transaction['currency_code'];
} }
foreach ($keys as $key) {
// foreign amount + currency if (array_key_exists($key, $transaction)) {
if (array_key_exists('foreign_amount', $transaction)) { $return[$key] = $transaction[$key];
$return['foreign_amount'] = $transaction['foreign_amount'];
} }
if (array_key_exists('foreign_currency_id', $transaction)) {
$return['foreign_currency_id'] = (int)$transaction['foreign_currency_id'];
}
if (array_key_exists('foreign_currency_code', $transaction)) {
$return['foreign_currency_code'] = $transaction['foreign_currency_code'];
}
// source + dest
if (array_key_exists('source_id', $transaction)) {
$return['source_id'] = (int)$transaction['source_id'];
}
if (array_key_exists('destination_id', $transaction)) {
$return['destination_id'] = (int)$transaction['destination_id'];
}
// description
if (array_key_exists('description', $transaction)) {
$return['description'] = $transaction['description'];
}
if (array_key_exists('piggy_bank_id', $transaction)) {
$return['piggy_bank_id'] = (int)$transaction['piggy_bank_id'];
}
if (array_key_exists('bill_id', $transaction)) {
$return['bill_id'] = (int)$transaction['bill_id'];
}
if (array_key_exists('tags', $transaction)) {
$return['tags'] = $transaction['tags'];
}
if (array_key_exists('budget_id', $transaction)) {
$return['budget_id'] = (int)$transaction['budget_id'];
}
if (array_key_exists('category_id', $transaction)) {
$return['category_id'] = (int)$transaction['category_id'];
} }
return $return; return $return;

View File

@@ -59,6 +59,8 @@ use Illuminate\Support\Collection;
/** /**
* Class OperatorQuerySearch * Class OperatorQuerySearch
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/ */
class OperatorQuerySearch implements SearchInterface class OperatorQuerySearch implements SearchInterface
{ {
@@ -242,6 +244,8 @@ class OperatorQuerySearch implements SearchInterface
/** /**
* @throws FireflyException * @throws FireflyException
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
private function handleSearchNode(Node $searchNode): void private function handleSearchNode(Node $searchNode): void
{ {
@@ -325,6 +329,7 @@ class OperatorQuerySearch implements SearchInterface
* @throws FireflyException * @throws FireflyException
* *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
private function updateCollector(string $operator, string $value, bool $prohibited): bool private function updateCollector(string $operator, string $value, bool $prohibited): bool
{ {
@@ -1974,6 +1979,7 @@ class OperatorQuerySearch implements SearchInterface
* stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is * stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is
* *
* @SuppressWarnings(PHPMD.BooleanArgumentFlag) * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/ */
private function searchAccountNr(string $value, SearchDirection $searchDirection, StringPosition $stringPosition, bool $prohibited = false): void private function searchAccountNr(string $value, SearchDirection $searchDirection, StringPosition $stringPosition, bool $prohibited = false): void
{ {

View File

@@ -87,7 +87,7 @@ class Steam
* [yyyy-mm-dd] => 123,2 * [yyyy-mm-dd] => 123,2
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function balanceInRange(Account $account, Carbon $start, Carbon $end, ?TransactionCurrency $currency = null): array public function balanceInRange(Account $account, Carbon $start, Carbon $end, ?TransactionCurrency $currency = null): array
{ {
$cache = new CacheProperties(); $cache = new CacheProperties();

View File

@@ -29,7 +29,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Support\Search\OperatorQuerySearch; use FireflyIII\Support\Search\OperatorQuerySearch;
use League\CommonMark\GithubFlavoredMarkdownConverter; use League\CommonMark\GithubFlavoredMarkdownConverter;
use Route;
use Twig\Extension\AbstractExtension; use Twig\Extension\AbstractExtension;
use Twig\TwigFilter; use Twig\TwigFilter;
use Twig\TwigFunction; use Twig\TwigFunction;
@@ -111,6 +110,8 @@ class General extends AbstractExtension
/** /**
* Show icon with attachment. * Show icon with attachment.
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
protected function mimeIcon(): TwigFilter protected function mimeIcon(): TwigFilter
{ {

View File

@@ -121,7 +121,7 @@ class ConvertToDeposit implements ActionInterface
* Is converted to a deposit from C to A. * Is converted to a deposit from C to A.
* *
* @throws FireflyException * @throws FireflyException
* */ */
private function convertWithdrawalArray(TransactionJournal $journal): bool private function convertWithdrawalArray(TransactionJournal $journal): bool
{ {
$user = $journal->user; $user = $journal->user;
@@ -210,7 +210,7 @@ class ConvertToDeposit implements ActionInterface
* The source account is replaced. * The source account is replaced.
* *
* @throws FireflyException * @throws FireflyException
* */ */
private function convertTransferArray(TransactionJournal $journal): bool private function convertTransferArray(TransactionJournal $journal): bool
{ {
$user = $journal->user; $user = $journal->user;

View File

@@ -51,6 +51,7 @@ class ConvertToTransfer implements ActionInterface
/** /**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/ */
public function actOnArray(array $journal): bool public function actOnArray(array $journal): bool
{ {

View File

@@ -116,7 +116,7 @@ class ConvertToWithdrawal implements ActionInterface
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
private function convertDepositArray(TransactionJournal $journal): bool private function convertDepositArray(TransactionJournal $journal): bool
{ {
$user = $journal->user; $user = $journal->user;
@@ -202,7 +202,7 @@ class ConvertToWithdrawal implements ActionInterface
* Output is a withdrawal from A to C. * Output is a withdrawal from A to C.
* *
* @throws FireflyException * @throws FireflyException
* */ */
private function convertTransferArray(TransactionJournal $journal): bool private function convertTransferArray(TransactionJournal $journal): bool
{ {
// find or create expense account. // find or create expense account.

View File

@@ -49,7 +49,7 @@ class AccountTransformer extends AbstractTransformer
* Transform the account. * Transform the account.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function transform(Account $account): array public function transform(Account $account): array
{ {
$this->repository->setUser($account->user); $this->repository->setUser($account->user);
@@ -156,7 +156,7 @@ class AccountTransformer extends AbstractTransformer
/** /**
* @throws FireflyException * @throws FireflyException
* */ */
private function getCurrency(Account $account): array private function getCurrency(Account $account): array
{ {
$currency = $this->repository->getAccountCurrency($account); $currency = $this->repository->getAccountCurrency($account);

View File

@@ -53,6 +53,7 @@ class BillTransformer extends AbstractTransformer
* Transform the bill. * Transform the bill.
* *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/ */
public function transform(Bill $bill): array public function transform(Bill $bill): array
{ {

View File

@@ -49,7 +49,7 @@ class PiggyBankEventTransformer extends AbstractTransformer
* Convert piggy bank event. * Convert piggy bank event.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function transform(PiggyBankEvent $event): array public function transform(PiggyBankEvent $event): array
{ {
// get account linked to piggy bank // get account linked to piggy bank

View File

@@ -50,7 +50,7 @@ class PiggyBankTransformer extends AbstractTransformer
* Transform the piggy bank. * Transform the piggy bank.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function transform(PiggyBank $piggyBank): array public function transform(PiggyBank $piggyBank): array
{ {
$account = $piggyBank->account; $account = $piggyBank->account;

View File

@@ -139,7 +139,7 @@ class PiggyBankTransformer extends AbstractTransformer
* Transform the piggy bank. * Transform the piggy bank.
* *
* @throws FireflyException * @throws FireflyException
* */ */
public function transform(PiggyBank $piggyBank): array public function transform(PiggyBank $piggyBank): array
{ {
// $account = $piggyBank->account; // $account = $piggyBank->account;

View File

@@ -76,6 +76,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* Class User. * Class User.
* *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*
* @property int|string $id * @property int|string $id
* @property string $email * @property string $email
* @property bool $isAdmin * @property bool $isAdmin

View File

@@ -78,6 +78,12 @@ trait DepositValidation
abstract protected function findExistingAccount(array $validTypes, array $data): ?Account; abstract protected function findExistingAccount(array $validTypes, array $data): ?Account;
/**
* Pretty complex unfortunately.
*
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function validateDepositSource(array $array): bool protected function validateDepositSource(array $array): bool
{ {
$accountId = array_key_exists('id', $array) ? $array['id'] : null; $accountId = array_key_exists('id', $array) ? $array['id'] : null;

View File

@@ -247,7 +247,11 @@ class AccountValidator
} }
/** /**
* It's a long and fairly complex method, but I don't mind.
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.BooleanArgumentFlag) * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/ */
protected function findExistingAccount(array $validTypes, array $data, bool $inverse = false): ?Account protected function findExistingAccount(array $validTypes, array $data, bool $inverse = false): ?Account
{ {

View File

@@ -30,6 +30,9 @@ use Illuminate\Validation\Validator;
*/ */
trait ValidatesAutoBudgetRequest trait ValidatesAutoBudgetRequest
{ {
/**
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function validateAutoBudgetAmount(Validator $validator): void protected function validateAutoBudgetAmount(Validator $validator): void
{ {
$data = $validator->getData(); $data = $validator->getData();

View File

@@ -299,6 +299,9 @@ trait RecurrenceValidation
} }
} }
/**
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function validateTransactionId(Recurrence $recurrence, Validator $validator): void protected function validateTransactionId(Recurrence $recurrence, Validator $validator): void
{ {
app('log')->debug('Now in validateTransactionId'); app('log')->debug('Now in validateTransactionId');

View File

@@ -217,6 +217,9 @@ trait TransactionValidation
return $transactions; return $transactions;
} }
/**
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function validateSingleAccount(Validator $validator, int $index, string $transactionType, array $transaction): void protected function validateSingleAccount(Validator $validator, int $index, string $transactionType, array $transaction): void
{ {
app('log')->debug(sprintf('Now in validateSingleAccount(%d)', $index)); app('log')->debug(sprintf('Now in validateSingleAccount(%d)', $index));
@@ -395,6 +398,7 @@ trait TransactionValidation
* TODO describe this method. * TODO describe this method.
* *
* @SuppressWarnings(PHPMD.ExcessiveParameterList) * @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/ */
private function sanityCheckForeignCurrency( private function sanityCheckForeignCurrency(
Validator $validator, Validator $validator,

View File

@@ -527,6 +527,7 @@ class CreateMainTables extends Migration
/** /**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/ */
private function createTransactionTables(): void private function createTransactionTables(): void
{ {

View File

@@ -125,6 +125,7 @@ class ChangesForV550 extends Migration
* *
* @SuppressWarnings(PHPMD.ShortMethodName) * @SuppressWarnings(PHPMD.ShortMethodName)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/ */
public function up(): void public function up(): void
{ {