Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Various code cleanup.
James Cole3424ec1c2792
diff --git a/app/Console/Commands/CreateExport.php b/app/Console/Commands/CreateExport.phpindex 0b94db7880..0420ac7eea 100644--- a/app/Console/Commands/CreateExport.php+++ b/app/Console/Commands/CreateExport.php@@ -25,7 +25,9 @@ use Storage;/**- * Class CreateExportextends+ * Class CreateExport+ *+ * Generates export from the command line.** @package FireflyIII\Console\Commands*/@@ -61,6 +63,10 @@ class CreateExport extends Command}/**+ *+ * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five its fine.+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)+ ** Execute the console command.** @return mixeddiff --git a/app/Console/Commands/DecryptAttachment.php b/app/Console/Commands/DecryptAttachment.phpindex d1ffbdb8c6..9e70200f85 100644--- a/app/Console/Commands/DecryptAttachment.php+++ b/app/Console/Commands/DecryptAttachment.php@@ -51,6 +51,10 @@ class DecryptAttachment extends Command/*** Execute the console command.+ *+ * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five its fine.+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)+ **/public function handle(){diff --git a/app/Console/Commands/UpgradeDatabase.php b/app/Console/Commands/UpgradeDatabase.phpindex 4cd2d6a5cf..62fdc69d14 100644--- a/app/Console/Commands/UpgradeDatabase.php+++ b/app/Console/Commands/UpgradeDatabase.php@@ -35,8 +35,10 @@ use Schema;/*** Class UpgradeDatabase*- * @SuppressWarnings(PHPMD.CouplingBetweenObjects) // it just touches a lot of things.+ * Upgrade user database.+ **+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) // it just touches a lot of things.* @package FireflyIII\Console\Commands*/class UpgradeDatabase extends Command@@ -138,6 +140,9 @@ class UpgradeDatabase extends Command/*** Each (asset) account must have a reference to a preferred currency. If the account does not have one, it's forced upon the account.+ *+ * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's seven but it can't really be helped.+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)*/public function updateAccountCurrencies(): void{@@ -192,6 +197,8 @@ class UpgradeDatabase extends Command** Both source and destination must match the respective currency preference of the related asset account.* So FF3 must verify all transactions.+ *+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)*/public function updateOtherCurrencies(): void{@@ -353,6 +360,12 @@ class UpgradeDatabase extends Command** The transaction that is sent to this function MUST be the source transaction (amount negative).*+ * Method is long and complex bit I'm taking it for granted.+ *+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)+ * @SuppressWarnings(PHPMD.NPathComplexity)+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)+ ** @param Transaction $transaction*/private function updateTransactionCurrency(Transaction $transaction): voiddiff --git a/app/Console/Commands/VerifiesAccessToken.php b/app/Console/Commands/VerifiesAccessToken.phpindex d051d68f69..889f64ad0e 100644--- a/app/Console/Commands/VerifiesAccessToken.php+++ b/app/Console/Commands/VerifiesAccessToken.php@@ -16,9 +16,17 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;use Log;use Preferences;+/**+ * Trait VerifiesAccessToken+ *+ * Verifies user access token for sensitive commands.+ *+ * @package FireflyIII\Console\Commands+ */trait VerifiesAccessToken{/**+ * Abstract method to make sure trait knows about method "option".* @param null $key** @return mixed@@ -26,6 +34,8 @@ trait VerifiesAccessTokenabstract public function option($key = null);/**+ * Returns false when given token does not match given user token.+ ** @return bool*/protected function verifyAccessToken(): booldiff --git a/app/Console/Commands/VerifyDatabase.php b/app/Console/Commands/VerifyDatabase.phpindex 60bda05c5d..aea9a40417 100644--- a/app/Console/Commands/VerifyDatabase.php+++ b/app/Console/Commands/VerifyDatabase.php@@ -34,6 +34,8 @@ use stdClass;/*** Class VerifyDatabase*+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)+ ** @package FireflyIII\Console\Commands*/class VerifyDatabase extends Command@@ -72,44 +74,23 @@ class VerifyDatabase extends Command$this->reportObject('budget');$this->reportObject('category');$this->reportObject('tag');-- // accounts with no transactions.$this->reportAccounts();- // budgets with no limits$this->reportBudgetLimits();- // budgets with no transactions-- // sum of transactions is not zero.$this->reportSum();- // any deleted transaction journals that have transactions that are NOT deleted:$this->reportJournals();- // deleted transactions that are connected to a not deleted journal.$this->reportTransactions();- // deleted accounts that still have not deleted transactions or journals attached to them.$this->reportDeletedAccounts();-- // report on journals with no transactions at all.$this->reportNoTransactions();-- // transfers with budgets.$this->reportTransfersBudgets();-- // report on journals with the wrong types of accounts.$this->reportIncorrectJournals();-- // report (and fix) piggy banks$this->repairPiggyBanks();-- // create default link types if necessary$this->createLinkTypes();-- // create user access tokens, if not present already.$this->createAccessTokens();}/**- *+ * Create user access tokens, if not present already.*/private function createAccessTokens(){@@ -126,7 +107,7 @@ class VerifyDatabase extends Command}/**- *+ * Create default link types if necessary.*/private function createLinkTypes(){@@ -150,7 +131,7 @@ class VerifyDatabase extends Command}/**- * Make sure there are only transfers linked to piggy bank events.+ * Eeport (and fix) piggy banks. Make sure there are only transfers linked to piggy bank events.*/private function repairPiggyBanks(): void{diff --git a/app/Console/Kernel.php b/app/Console/Kernel.phpindex 2be137ec13..dd3f9e2719 100644--- a/app/Console/Kernel.php+++ b/app/Console/Kernel.php@@ -16,6 +16,9 @@ namespace FireflyIII\Console;use Illuminate\Console\Scheduling\Schedule;use Illuminate\Foundation\Console\Kernel as ConsoleKernel;+/**+ * File to make sure commnds work.+ */class Kernel extends ConsoleKernel{/**@@ -44,7 +47,7 @@ class Kernel extends ConsoleKernel* Define the application's command schedule.** @param \Illuminate\Console\Scheduling\Schedule $schedule- *+ * @SuppressWarnings(PHPMD.UnusedLocalVariable)* @return void*/protected function schedule(Schedule $schedule)diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.phpindex 7ae31ad35c..772a52171b 100644--- a/app/Exceptions/Handler.php+++ b/app/Exceptions/Handler.php@@ -67,6 +67,7 @@ class Handler extends ExceptionHandler** This is a great spot to send exceptions to Sentry, Bugsnag, etc.*+ * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five its fine.* @param \Exception $exception** @return voiddiff --git a/app/Export/Entry/Entry.php b/app/Export/Entry/Entry.phpindex 8aff206d47..1422750e6b 100644--- a/app/Export/Entry/Entry.php+++ b/app/Export/Entry/Entry.php@@ -31,6 +31,7 @@ use Steam;** Class Entry* @SuppressWarnings(PHPMD.LongVariable)+ * @SuppressWarnings(PHPMD.TooManyFields)** @package FireflyIII\Export\Entry*/@@ -84,40 +85,12 @@ final class Entry{}- /**- * @param $object- *- * @return Entry- */- public static function fromObject($object): Entry- {- $entry = new self;- $entry->journal_id = $object->transaction_journal_id;- $entry->description = Steam::decrypt(intval($object->journal_encrypted), $object->journal_description);- $entry->amount = $object->amount;- $entry->date = $object->date;- $entry->transaction_type = $object->transaction_type;- $entry->currency_code = $object->transaction_currency_code;- $entry->asset_account_id = $object->account_id;- $entry->asset_account_name = Steam::decrypt(intval($object->account_name_encrypted), $object->account_name);- $entry->opposing_account_id = $object->opposing_account_id;- $entry->opposing_account_name = Steam::decrypt(intval($object->opposing_account_encrypted), $object->opposing_account_name);- $entry->category_id = $object->category_id ?? '';- $entry->category_name = $object->category_name ?? '';- $entry->budget_id = $object->budget_id ?? '';- $entry->budget_name = $object->budget_name ?? '';-- // update description when transaction description is different:- if (!is_null($object->description) && $object->description !== $entry->description) {- $entry->description = $entry->description . ' (' . $object->description . ')';- }-- return $entry;- }-/*** Converts a given transaction (as collected by the collector) into an export entry.*+ * @SuppressWarnings(PHPMD.CyclomaticComplexity) // complex but little choice.+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped+ ** @param Transaction $transaction** @return Entrydiff --git a/app/Export/ExpandedProcessor.php b/app/Export/ExpandedProcessor.phpindex f8469246d6..b4a0ddc3e5 100644--- a/app/Export/ExpandedProcessor.php+++ b/app/Export/ExpandedProcessor.php@@ -34,6 +34,8 @@ use ZipArchive;/*** Class ExpandedProcessor*+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) // its doing a lot.+ ** @package FireflyIII\Export*/class ExpandedProcessor implements ProcessorInterface@@ -84,7 +86,10 @@ class ExpandedProcessor implements ProcessorInterface}/**+ * Collects all transaction journals.+ ** @return bool+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)*/public function collectJournals(): bool{@@ -102,6 +107,7 @@ class ExpandedProcessor implements ProcessorInterface$opposingIds = $transactions->pluck('opposing_account_id')->toArray();$notes = $this->getNotes($ids);$tags = $this->getTags($ids);+ /** @var array $ibans */$ibans = $this->getIbans($assetIds) + $this->getIbans($opposingIds);$currencies = $this->getAccountCurrencies($ibans);$transactions->each(diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.phpindex 43e23ad1a4..e5c97c92b5 100644--- a/app/Generator/Report/Audit/MonthReportGenerator.php+++ b/app/Generator/Report/Audit/MonthReportGenerator.php@@ -145,6 +145,9 @@ class MonthReportGenerator implements ReportGeneratorInterface* @param Carbon $date** @return array+ *+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength) // not that long+ **/private function getAuditReport(Account $account, Carbon $date): array{@@ -175,9 +178,6 @@ class MonthReportGenerator implements ReportGeneratorInterface$transaction->currency = $currency;}- /*- * Reverse set again.- */$return = ['journals' => $journals->reverse(),'exists' => $journals->count() > 0,