Various code cleanup.

This commit is contained in:
James Cole
2021-04-07 07:28:43 +02:00
parent 4ddcb0c965
commit f12744ad8c
180 changed files with 714 additions and 721 deletions

View File

@@ -115,7 +115,7 @@ class Amount
$cache = new CacheProperties;
$cache->addProperty('getCurrencyCode');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
$currencyPreference = app('preferences')->get('currencyPreference', config('firefly.default_currency', 'EUR'));
@@ -152,7 +152,7 @@ class Amount
$cache->addProperty('getDefaultCurrency');
$cache->addProperty($user->id);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
$currencyPreference = app('preferences')->getForUser($user, 'currencyPreference', config('firefly.default_currency', 'EUR'));
$currencyPrefStr = $currencyPreference ? $currencyPreference->data : 'EUR';

View File

@@ -54,12 +54,12 @@ class BudgetList implements BinderInterface
$list = array_unique(array_map('\intval', explode(',', $value)));
// @codeCoverageIgnoreStart
if (0 === count($list)) {
Log::warning('Budget list count is zero, return 404.');
throw new NotFoundHttpException;
}
// @codeCoverageIgnoreEnd
/** @var Collection $collection */
$collection = auth()->user()->budgets()

View File

@@ -51,7 +51,7 @@ class CategoryList implements BinderInterface
$list = array_unique(array_map('\intval', explode(',', $value)));
if (0 === count($list)) {
throw new NotFoundHttpException; // @codeCoverageIgnore
throw new NotFoundHttpException;
}
/** @var \Illuminate\Support\Collection $collection */

View File

@@ -69,7 +69,7 @@ class JournalList implements BinderInterface
{
$list = array_unique(array_map('\intval', explode(',', $value)));
if (0 === count($list)) {
throw new NotFoundHttpException; // @codeCoverageIgnore
throw new NotFoundHttpException;
}
return $list;

View File

@@ -52,12 +52,12 @@ class TagList implements BinderInterface
}
$list = array_unique(array_map('\strtolower', explode(',', $value)));
Log::debug('List of tags is', $list);
// @codeCoverageIgnoreStart
if (0 === count($list)) {
Log::error('Tag list is empty.');
throw new NotFoundHttpException;
}
// @codeCoverageIgnoreEnd
/** @var TagRepositoryInterface $repository */
$repository = app(TagRepositoryInterface::class);

View File

@@ -130,13 +130,13 @@ class WholePeriodChartGenerator
$step = '1D';
$months = $start->diffInMonths($end);
if ($months > 3) {
$step = '1W'; // @codeCoverageIgnore
$step = '1W';
}
if ($months > 24) {
$step = '1M'; // @codeCoverageIgnore
$step = '1M';
}
if ($months > 100) {
$step = '1Y'; // @codeCoverageIgnore
$step = '1Y';
}
return $step;

View File

@@ -206,7 +206,7 @@ trait AugumentData
$cache->addProperty('get-limits');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
$set = $blRepository->getBudgetLimits($budget, $start, $end);

View File

@@ -57,7 +57,7 @@ trait ChartGeneration
$cache->addProperty('chart.account.account-balance-chart');
$cache->addProperty($accounts);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
Log::debug('Regenerate chart.account.account-balance-chart from scratch.');
$locale = app('steam')->getLocale();

View File

@@ -129,7 +129,7 @@ trait CreateStuff
$keys = RSA::createKey(4096);
}
// @codeCoverageIgnoreStart
Log::alert('NO OAuth keys were found. They have been created.');
file_put_contents($publicKey, $keys['publickey']);

View File

@@ -88,13 +88,13 @@ trait DateCalculation
$step = '1D';
$months = $start->diffInMonths($end);
if ($months > 3) {
$step = '1W'; // @codeCoverageIgnore
$step = '1W';
}
if ($months > 24) {
$step = '1M'; // @codeCoverageIgnore
$step = '1M';
}
if ($months > 100) {
$step = '1Y'; // @codeCoverageIgnore
$step = '1Y';
}
return $step;

View File

@@ -89,7 +89,7 @@ trait PeriodOverview
$cache->addProperty('account-show-period-entries');
$cache->addProperty($account->id);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
/** @var array $dates */
$dates = app('navigation')->blockPeriods($start, $end, $range);
@@ -281,7 +281,7 @@ trait PeriodOverview
$cache->addProperty($category->id);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
/** @var array $dates */
$dates = app('navigation')->blockPeriods($start, $end, $range);
@@ -356,7 +356,7 @@ trait PeriodOverview
$cache->addProperty('no-budget-period-entries');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
/** @var array $dates */
@@ -415,7 +415,7 @@ trait PeriodOverview
$cache->addProperty('no-category-period-entries');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
$dates = app('navigation')->blockPeriods($start, $end, $range);
@@ -490,7 +490,7 @@ trait PeriodOverview
$cache->addProperty('tag-period-entries');
$cache->addProperty($tag->id);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
/** @var array $dates */
$dates = app('navigation')->blockPeriods($start, $end, $range);
@@ -564,7 +564,7 @@ trait PeriodOverview
$cache->addProperty('transactions-period-entries');
$cache->addProperty($transactionType);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
/** @var array $dates */
$dates = app('navigation')->blockPeriods($start, $end, $range);

View File

@@ -65,7 +65,7 @@ trait RenderPartialViews
$account = $accountRepos->findNull((int)$attributes['accountId']);
$journals = $popupHelper->balanceForBudget($budget, $account, $attributes);
// @codeCoverageIgnoreStart
try {
$view = prefixView('popup.report.balance-amount', compact('journals', 'budget', 'account'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -73,7 +73,7 @@ trait RenderPartialViews
$view = 'Firefly III could not render the view. Please see the log files.';
}
// @codeCoverageIgnoreEnd
return $view;
}
@@ -88,7 +88,7 @@ trait RenderPartialViews
/** @var BudgetRepositoryInterface $repository */
$repository = app(BudgetRepositoryInterface::class);
$budgets = $repository->getBudgets();
// @codeCoverageIgnoreStart
try {
$result = prefixView('reports.options.budget', compact('budgets'))->render();
} catch (Throwable $e) {// @phpstan-ignore-line
@@ -96,7 +96,7 @@ trait RenderPartialViews
$result = 'Could not render view.';
}
// @codeCoverageIgnoreEnd
return $result;
}
@@ -121,7 +121,7 @@ trait RenderPartialViews
$budget = new Budget;
}
$journals = $popupHelper->byBudget($budget, $attributes);
// @codeCoverageIgnoreStart
try {
$view = prefixView('popup.report.budget-spent-amount', compact('journals', 'budget'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -129,7 +129,7 @@ trait RenderPartialViews
$view = 'Firefly III could not render the view. Please see the log files.';
}
// @codeCoverageIgnoreEnd
return $view;
}
@@ -171,7 +171,7 @@ trait RenderPartialViews
/** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class);
$categories = $repository->getCategories();
// @codeCoverageIgnoreStart
try {
$result = prefixView('reports.options.category', compact('categories'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -179,7 +179,7 @@ trait RenderPartialViews
$result = 'Could not render view.';
}
// @codeCoverageIgnoreEnd
return $result;
}
@@ -214,7 +214,7 @@ trait RenderPartialViews
}
}
// @codeCoverageIgnoreStart
try {
$result = prefixView('reports.options.double', compact('set'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -222,7 +222,7 @@ trait RenderPartialViews
$result = 'Could not render view.';
}
// @codeCoverageIgnoreEnd
return $result;
}
@@ -249,7 +249,7 @@ trait RenderPartialViews
}
$journals = $popupHelper->byExpenses($account, $attributes);
// @codeCoverageIgnoreStart
try {
$view = prefixView('popup.report.expense-entry', compact('journals', 'account'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -257,7 +257,7 @@ trait RenderPartialViews
$view = 'Firefly III could not render the view. Please see the log files.';
}
// @codeCoverageIgnoreEnd
return $view;
}
@@ -288,12 +288,12 @@ trait RenderPartialViews
'count' => $count,
]
)->render();
// @codeCoverageIgnoreStart
} catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Throwable was thrown in getCurrentActions(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
}
// @codeCoverageIgnoreEnd
++$index;
}
@@ -339,12 +339,12 @@ trait RenderPartialViews
'triggers' => $triggers,
]
)->render();
// @codeCoverageIgnoreStart
} catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Throwable was thrown in getCurrentTriggers(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
}
// @codeCoverageIgnoreEnd
++$index;
}
}
@@ -373,7 +373,7 @@ trait RenderPartialViews
}
$journals = $popupHelper->byIncome($account, $attributes);
// @codeCoverageIgnoreStart
try {
$view = prefixView('popup.report.income-entry', compact('journals', 'account'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -381,7 +381,7 @@ trait RenderPartialViews
$view = 'Firefly III could not render the view. Please see the log files.';
}
// @codeCoverageIgnoreEnd
return $view;
}
@@ -393,7 +393,7 @@ trait RenderPartialViews
*/
protected function noReportOptions(): string // render a view
{
// @codeCoverageIgnoreStart
try {
$result = prefixView('reports.options.no-options')->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -401,7 +401,7 @@ trait RenderPartialViews
$result = 'Could not render view.';
}
// @codeCoverageIgnoreEnd
return $result;
}
@@ -417,7 +417,7 @@ trait RenderPartialViews
$repository = app(TagRepositoryInterface::class);
$tags = $repository->get();
// @codeCoverageIgnoreStart
try {
$result = prefixView('reports.options.tag', compact('tags'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
@@ -425,7 +425,7 @@ trait RenderPartialViews
$result = 'Could not render view.';
}
// @codeCoverageIgnoreEnd
return $result;
}

View File

@@ -113,7 +113,7 @@ trait RequestInformation
return $content;
}
return '<p>' . trans('firefly.route_has_no_help') . '</p>'; // @codeCoverageIgnore
return '<p>' . trans('firefly.route_has_no_help') . '</p>';
}
/**
@@ -180,7 +180,7 @@ trait RequestInformation
$shownDemo = app('preferences')->get($key, false)->data;
}
if (!is_bool($shownDemo)) {
$shownDemo = true; // @codeCoverageIgnore
$shownDemo = true;
}
return $shownDemo;

View File

@@ -60,7 +60,7 @@ trait UserNavigation
Log::debug(sprintf('The URI is %s', $uri));
if (false !== strpos($uri, 'jscript')) {
$uri = $this->redirectUri; // @codeCoverageIgnore
$uri = $this->redirectUri;
Log::debug(sprintf('URI is now %s (uri contains jscript)', $uri));
}

View File

@@ -56,7 +56,7 @@ class Steam
$cache->addProperty($date);
$cache->addProperty($currency ? $currency->id : 0);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
@@ -101,7 +101,7 @@ class Steam
$cache->addProperty('balance-no-virtual');
$cache->addProperty($date);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
@@ -170,7 +170,7 @@ class Steam
$cache->addProperty($start);
$cache->addProperty($end);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
$start->subDay();
@@ -250,7 +250,7 @@ class Steam
$cache->addProperty('balance-per-currency');
$cache->addProperty($date);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
$query = $account->transactions()
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
@@ -284,7 +284,7 @@ class Steam
$cache->addProperty('balances');
$cache->addProperty($date);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
// need to do this per account.
@@ -316,7 +316,7 @@ class Steam
$cache->addProperty('balances-per-currency');
$cache->addProperty($date);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
return $cache->get();
}
// need to do this per account.