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

@@ -128,7 +128,7 @@ class AccountRepository implements AccountRepositoryInterface
->where('account_meta.name', 'account_number')
->where('account_meta.data', json_encode($number));
if (count($types) > 0) {
if (!empty($types)) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types);
}
@@ -152,7 +152,7 @@ class AccountRepository implements AccountRepositoryInterface
{
$query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban');
if (count($types) > 0) {
if (!empty($types)) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types);
}
@@ -180,7 +180,7 @@ class AccountRepository implements AccountRepositoryInterface
{
$query = $this->user->accounts();
if (count($types) > 0) {
if (!empty($types)) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types);
}
@@ -260,7 +260,7 @@ class AccountRepository implements AccountRepositoryInterface
/** @var Collection $result */
$query = $this->user->accounts();
if (count($accountIds) > 0) {
if (!empty($accountIds)) {
$query->whereIn('accounts.id', $accountIds);
}
$query->orderBy('accounts.order', 'ASC');
@@ -279,7 +279,7 @@ class AccountRepository implements AccountRepositoryInterface
{
/** @var Collection $result */
$query = $this->user->accounts();
if (count($types) > 0) {
if (!empty($types)) {
$query->accountTypeIn($types);
}
$query->orderBy('accounts.order', 'ASC');
@@ -303,7 +303,7 @@ class AccountRepository implements AccountRepositoryInterface
$query->where('name', 'account_role');
}, 'attachments']
);
if (count($types) > 0) {
if (!empty($types)) {
$query->accountTypeIn($types);
}
$query->where('active', 1);
@@ -572,7 +572,7 @@ class AccountRepository implements AccountRepositoryInterface
}
}
if (count($types) > 0) {
if (!empty($types)) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$dbQuery->whereIn('account_types.type', $types);
}
@@ -630,7 +630,7 @@ class AccountRepository implements AccountRepositoryInterface
$query->where('name', 'account_role');
}]
);
if (count($types) > 0) {
if (!empty($types)) {
$query->accountTypeIn($types);
}
$query->where('active', 0);
@@ -728,7 +728,7 @@ class AccountRepository implements AccountRepositoryInterface
});
}
}
if (count($types) > 0) {
if (!empty($types)) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$dbQuery->whereIn('account_types.type', $types);
}

View File

@@ -157,7 +157,6 @@ class BudgetRepository implements BudgetRepositoryInterface
*/
public function firstUseDate(Budget $budget): ?Carbon
{
$oldest = null;
$journal = $budget->transactionJournals()->orderBy('date', 'ASC')->first();
if (null !== $journal) {
return $journal->date;

View File

@@ -215,7 +215,6 @@ class JournalRepository implements JournalRepositoryInterface
*/
public function getLinkNoteText(TransactionJournalLink $link): string
{
$notes = null;
/** @var Note $note */
$note = $link->notes()->first();
if (null !== $note) {

View File

@@ -60,7 +60,6 @@ trait CreatesObjectGroups
*/
protected function findOrCreateObjectGroup(string $title): ?ObjectGroup
{
$group = null;
$maxOrder = $this->getObjectGroupMaxOrder();
if (!$this->hasObjectGroup($title)) {
return ObjectGroup::create(

View File

@@ -327,7 +327,7 @@ class RecurringRepository implements RecurringRepositoryInterface
foreach ($journalMeta as $journalId) {
$search[] = (int)$journalId;
}
if (0 === count($search)) {
if (empty($search)) {
return new Collection;
}

View File

@@ -476,7 +476,6 @@ class TagRepository implements TagRepositoryInterface
*/
public function update(Tag $tag, array $data): Tag
{
$oldTag = $data['tag'];
$tag->tag = $data['tag'];
$tag->date = $data['date'];
$tag->description = $data['description'];