Various code cleanup.

This commit is contained in:
James Cole
2017-09-16 07:41:03 +02:00
parent fe9adba7fb
commit 3424ec1c27
10 changed files with 58 additions and 61 deletions

View File

@@ -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 mixed

View File

@@ -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()
{

View File

@@ -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): void

View File

@@ -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 VerifiesAccessToken
abstract public function option($key = null);
/**
* Returns false when given token does not match given user token.
*
* @return bool
*/
protected function verifyAccessToken(): bool

View File

@@ -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
{