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

@@ -267,21 +267,21 @@ class CreateController extends Controller
// redirect to show bill.
if ('true' === $request->get('return_to_bill') && (int)$request->get('bill_id') > 0) {
return redirect(route('bills.show', [(int)$request->get('bill_id')])); // @codeCoverageIgnore
return redirect(route('bills.show', [(int)$request->get('bill_id')]));
}
// redirect to new bill creation.
if ((int)$request->get('bill_id') > 0) {
return redirect($this->getPreviousUri('bills.create.uri')); // @codeCoverageIgnore
return redirect($this->getPreviousUri('bills.create.uri'));
}
$redirect = redirect($this->getPreviousUri('rules.create.uri'));
if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart
session()->put('rules.create.fromStore', true);
$redirect = redirect(route('rules.create', [$data['rule_group_id']]))->withInput();
// @codeCoverageIgnoreEnd
}
return $redirect;

View File

@@ -168,7 +168,7 @@ class EditController extends Controller
'triggers' => $triggers,
]
)->render();
} catch (Throwable $e) {
} catch (Throwable $e) { // @phpstan-ignore-line
Log::debug(sprintf('Throwable was thrown in getPreviousTriggers(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
}
@@ -195,11 +195,11 @@ class EditController extends Controller
app('preferences')->mark();
$redirect = redirect($this->getPreviousUri('rules.edit.uri'));
if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
session()->put('rules.edit.fromUpdate', true);
$redirect = redirect(route('rules.edit', [$rule->id]))->withInput(['return_to_edit' => 1]);
// @codeCoverageIgnoreEnd
}
return $redirect;

View File

@@ -145,7 +145,7 @@ class SelectController extends Controller
// warn if nothing.
if (0 === count($textTriggers)) {
return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore
return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);
}
foreach ($textTriggers as $textTrigger) {
@@ -168,21 +168,21 @@ class SelectController extends Controller
// Warn the user if only a subset of transactions is returned
$warning = '';
if (0 === count($collection)) {
$warning = (string)trans('firefly.warning_no_matching_transactions'); // @codeCoverageIgnore
$warning = (string)trans('firefly.warning_no_matching_transactions');
}
// Return json response
$view = 'ERROR, see logs.';
try {
$view = prefixView('list.journals-array-tiny', ['groups' => $collection])->render();
// @codeCoverageIgnoreStart
} catch (Throwable $exception) {
} catch (Throwable $exception) { // @phpstan-ignore-line
Log::error(sprintf('Could not render view in testTriggers(): %s', $exception->getMessage()));
Log::error($exception->getTraceAsString());
$view = sprintf('Could not render list.journals-tiny: %s', $exception->getMessage());
}
// @codeCoverageIgnoreEnd
return response()->json(['html' => $view, 'warning' => $warning]);
}
@@ -201,7 +201,7 @@ class SelectController extends Controller
$triggers = $rule->ruleTriggers;
if (0 === count($triggers)) {
return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore
return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);
}
// create new rule engine:
$newRuleEngine = app(RuleEngineInterface::class);
@@ -213,20 +213,20 @@ class SelectController extends Controller
$warning = '';
if (0 === count($collection)) {
$warning = (string)trans('firefly.warning_no_matching_transactions'); // @codeCoverageIgnore
$warning = (string)trans('firefly.warning_no_matching_transactions');
}
// Return json response
$view = 'ERROR, see logs.';
try {
$view = prefixView('list.journals-array-tiny', ['groups' => $collection])->render();
// @codeCoverageIgnoreStart
} catch (Throwable $exception) {
} catch (Throwable $exception) { // @phpstan-ignore-line
Log::error(sprintf('Could not render view in testTriggersByRule(): %s', $exception->getMessage()));
Log::error($exception->getTraceAsString());
}
// @codeCoverageIgnoreEnd
return response()->json(['html' => $view, 'warning' => $warning]);
}