From fc0ef4b79de59803871fab228c936422c41834bd Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 17 Jan 2015 10:05:43 +0100 Subject: [PATCH] Small optimizations. --- app/controllers/BudgetController.php | 8 ++++++-- app/controllers/CategoryController.php | 8 ++++++-- app/controllers/CurrencyController.php | 5 ++++- app/controllers/GoogleChartController.php | 2 +- app/controllers/HelpController.php | 2 ++ app/controllers/PiggybankController.php | 2 ++ app/controllers/ProfileController.php | 4 +++- app/controllers/RelatedController.php | 4 ++++ app/controllers/RepeatedExpenseController.php | 3 ++- 9 files changed, 30 insertions(+), 8 deletions(-) diff --git a/app/controllers/BudgetController.php b/app/controllers/BudgetController.php index 9365d67d2c..53ae58aef2 100644 --- a/app/controllers/BudgetController.php +++ b/app/controllers/BudgetController.php @@ -145,6 +145,8 @@ class BudgetController extends BaseController } /** + * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. + * * @param Budget $budget * @param LimitRepetition $repetition * @@ -181,10 +183,11 @@ class BudgetController extends BaseController Session::flash('errors', $messages['errors']); if ($messages['errors']->count() > 0) { Session::flash('error', 'Could not validate budget: ' . $messages['errors']->first()); + return Redirect::route('budgets.create')->withInput(); } // return to create screen: - if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { + if ($data['post_submit_action'] == 'validate_only') { return Redirect::route('budgets.create')->withInput(); } @@ -219,10 +222,11 @@ class BudgetController extends BaseController Session::flash('errors', $messages['errors']); if ($messages['errors']->count() > 0) { Session::flash('error', 'Could not update budget: ' . $messages['errors']->first()); + return Redirect::route('budgets.edit', $budget->id)->withInput(); } // return to update screen: - if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { + if ($data['post_submit_action'] == 'validate_only') { return Redirect::route('budgets.edit', $budget->id)->withInput(); } diff --git a/app/controllers/CategoryController.php b/app/controllers/CategoryController.php index 915562cfc2..bc5d0846f1 100644 --- a/app/controllers/CategoryController.php +++ b/app/controllers/CategoryController.php @@ -105,6 +105,7 @@ class CategoryController extends BaseController } /** + * * @return $this * @throws FireflyException */ @@ -122,10 +123,11 @@ class CategoryController extends BaseController Session::flash('errors', $messages['errors']); if ($messages['errors']->count() > 0) { Session::flash('error', 'Could not store category: ' . $messages['errors']->first()); + return Redirect::route('categories.create')->withInput(); } // return to create screen: - if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { + if ($data['post_submit_action'] == 'validate_only') { return Redirect::route('categories.create')->withInput(); } @@ -140,6 +142,7 @@ class CategoryController extends BaseController } /** + * * @param Category $category * * @return $this @@ -159,10 +162,11 @@ class CategoryController extends BaseController Session::flash('errors', $messages['errors']); if ($messages['errors']->count() > 0) { Session::flash('error', 'Could not update category: ' . $messages['errors']->first()); + return Redirect::route('categories.edit', $category->id)->withInput(); } // return to update screen: - if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { + if ($data['post_submit_action'] == 'validate_only') { return Redirect::route('categories.edit', $category->id)->withInput(); } diff --git a/app/controllers/CurrencyController.php b/app/controllers/CurrencyController.php index 5e79791af3..9b55132333 100644 --- a/app/controllers/CurrencyController.php +++ b/app/controllers/CurrencyController.php @@ -122,6 +122,8 @@ class CurrencyController extends BaseController } /** + * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. + * * @return $this|\Illuminate\Http\RedirectResponse */ public function store() @@ -173,10 +175,11 @@ class CurrencyController extends BaseController Session::flash('errors', $messages['errors']); if ($messages['errors']->count() > 0) { Session::flash('error', 'Could not update currency: ' . $messages['errors']->first()); + return Redirect::route('currency.edit', $currency->id)->withInput(); } // return to update screen: - if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { + if ($data['post_submit_action'] == 'validate_only') { return Redirect::route('currency.edit', $currency->id)->withInput(); } diff --git a/app/controllers/GoogleChartController.php b/app/controllers/GoogleChartController.php index f2cfb3a0cf..99d5662b12 100644 --- a/app/controllers/GoogleChartController.php +++ b/app/controllers/GoogleChartController.php @@ -72,7 +72,7 @@ class GoogleChartController extends BaseController } /** - * This method renders the b + * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. */ public function allAccountsBalanceChart() { diff --git a/app/controllers/HelpController.php b/app/controllers/HelpController.php index 356f86b397..dbb9f7a2aa 100644 --- a/app/controllers/HelpController.php +++ b/app/controllers/HelpController.php @@ -1,8 +1,10 @@ count() > 0) { Session::flash('error', 'Could not store repeated expense: ' . $messages['errors']->first()); + return Redirect::route('repeated.create')->withInput(); } // return to create screen: - if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { + if ($data['post_submit_action'] == 'validate_only') { return Redirect::route('repeated.create')->withInput(); }