Various issues fixed (SonarQube)

This commit is contained in:
James Cole
2020-10-26 19:15:57 +01:00
parent e4923a3c69
commit 372c6ac667
57 changed files with 86 additions and 221 deletions

View File

@@ -275,7 +275,7 @@ trait RecurringTransactionTrait
*/
protected function updateTags(RecurrenceTransaction $transaction, array $tags): void
{
if (count($tags) > 0) {
if (!empty($tags)) {
/** @var RecurrenceMeta $entry */
$entry = $transaction->recurrenceTransactionMeta()->where('name', 'tags')->first();
if (null === $entry) {
@@ -284,7 +284,7 @@ trait RecurringTransactionTrait
$entry->value = json_encode($tags);
$entry->save();
}
if (0 === count($tags)) {
if (empty($tags)) {
// delete if present
$transaction->recurrenceTransactionMeta()->where('name', 'tags')->delete();
}

View File

@@ -76,10 +76,6 @@ class JournalUpdateService
private $transactionGroup;
/** @var TransactionJournal The journal to update. */
private $transactionJournal;
/** @var Account If new account info is submitted, this array will hold the valid destination. */
private $validDestination;
/** @var Account If new account info is submitted, this array will hold the valid source. */
private $validSource;
/**
* JournalUpdateService constructor.

View File

@@ -41,8 +41,7 @@ class RecurrenceUpdateService
{
use TransactionTypeTrait, RecurringTransactionTrait;
/** @var User */
private $user;
private User $user;
/**
* Updates a recurrence.
@@ -99,7 +98,7 @@ class RecurrenceUpdateService
$this->createRepetitions($recurrence, $data['repetitions'] ?? []);
}
// update all transactions (and associated meta-data);
// update all transactions (and associated meta-data)
if (null !== $data['transactions']) {
$this->deleteTransactions($recurrence);
$this->createTransactions($recurrence, $data['transactions'] ?? []);