Skip to content

Firefly III: a personal finances manager

Small optimizations.

James Colefc0ef4b79de5
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 @@
<?php
/**
+ * @SuppressWarnings("CamelCase") // I'm fine with this.
*
* Class HelpController
+ *
*/
class HelpController extends BaseController
{
diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.php
index 1523206116..051a5d2ca5 100644
--- a/app/controllers/PiggybankController.php
+++ b/app/controllers/PiggybankController.php
@@ -93,6 +93,8 @@ class PiggyBankController extends BaseController
}
/**
+ * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
+ *
* @param PiggyBank $piggyBank
*
* @return $this
diff --git a/app/controllers/ProfileController.php b/app/controllers/ProfileController.php
index a9f9419bea..8ac759f571 100644
--- a/app/controllers/ProfileController.php
+++ b/app/controllers/ProfileController.php
@@ -1,7 +1,7 @@
<?php
/**
- *
+ * @SuppressWarnings("CamelCase") // I'm fine with this.
* Class ProfileController
*/
class ProfileController extends BaseController
@@ -56,6 +56,8 @@ class ProfileController extends BaseController
}
/**
+ * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
+ *
* @param string $old
* @param string $new1
* @param string $new2
diff --git a/app/controllers/RelatedController.php b/app/controllers/RelatedController.php
index ec533564bb..fb77ee320c 100644
--- a/app/controllers/RelatedController.php
+++ b/app/controllers/RelatedController.php
@@ -22,6 +22,8 @@ class RelatedController extends BaseController
}
/**
+ * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
+ *
* @param TransactionJournal $journal
*
* @return \Illuminate\Http\JsonResponse
@@ -96,6 +98,8 @@ class RelatedController extends BaseController
}
/**
+ * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
+ *
* @param TransactionJournal $parentJournal
* @param TransactionJournal $childJournal
*
diff --git a/app/controllers/RepeatedExpenseController.php b/app/controllers/RepeatedExpenseController.php
index d9bf9f4002..61abf4a133 100644
--- a/app/controllers/RepeatedExpenseController.php
+++ b/app/controllers/RepeatedExpenseController.php
@@ -158,11 +158,12 @@ class RepeatedExpenseController extends BaseController
Session::flash('errors', $messages['errors']);
if ($messages['errors']->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();
}