Remove inspection, add TODO's, make code a bit simpler.

This commit is contained in:
James Cole 2019-08-16 21:38:35 +02:00
parent 820358af73
commit f09d0e87e4
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
23 changed files with 79 additions and 90 deletions

View File

@ -73,7 +73,7 @@ class ShowController extends Controller
); );
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Show an account. * Show an account.
* *

View File

@ -65,7 +65,7 @@ class ShowController extends Controller
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Show a single category. * Show a single category.
* *

View File

@ -382,7 +382,7 @@ class BudgetController extends Controller
return response()->json($data); return response()->json($data);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Shows a budget overview chart (spent and budgeted). * Shows a budget overview chart (spent and budgeted).
* *

View File

@ -66,7 +66,7 @@ class BudgetReportController extends Controller
); );
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Chart that groups expenses by the account. * Chart that groups expenses by the account.
* *
@ -97,7 +97,7 @@ class BudgetReportController extends Controller
return response()->json($data); return response()->json($data);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Chart that groups the expenses by budget. * Chart that groups the expenses by budget.
* *
@ -128,7 +128,7 @@ class BudgetReportController extends Controller
return response()->json($data); return response()->json($data);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Main overview of a budget in the budget report. * Main overview of a budget in the budget report.
* *

View File

@ -260,7 +260,7 @@ class CategoryController extends Controller
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Chart for period for transactions without a category. * Chart for period for transactions without a category.

View File

@ -61,7 +61,7 @@ class CategoryReportController extends Controller
); );
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Chart for expenses grouped by expense account. * Chart for expenses grouped by expense account.
* *
@ -89,7 +89,7 @@ class CategoryReportController extends Controller
return response()->json($data); return response()->json($data);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Chart for income grouped by revenue account. * Chart for income grouped by revenue account.
* *
@ -120,7 +120,7 @@ class CategoryReportController extends Controller
return response()->json($data); return response()->json($data);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Chart for expenses grouped by expense account. * Chart for expenses grouped by expense account.
* *
@ -151,7 +151,7 @@ class CategoryReportController extends Controller
return response()->json($data); return response()->json($data);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Piechart for income grouped by account. * Piechart for income grouped by account.
* *
@ -182,7 +182,7 @@ class CategoryReportController extends Controller
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Main report category chart. * Main report category chart.
* *

View File

@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection MoreThanThreeArgumentsInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart; namespace FireflyIII\Http\Controllers\Chart;
@ -64,7 +64,7 @@ class ExpenseReportController extends Controller
); );
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Main chart that shows income and expense for a combination of expense/revenue accounts. * Main chart that shows income and expense for a combination of expense/revenue accounts.
* *

View File

@ -53,7 +53,7 @@ class TagReportController extends Controller
$this->generator = app(GeneratorInterface::class); $this->generator = app(GeneratorInterface::class);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Generate expenses for tags grouped on account. * Generate expenses for tags grouped on account.
* *
@ -84,7 +84,7 @@ class TagReportController extends Controller
return response()->json($data); return response()->json($data);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Generate income for tag grouped by account. * Generate income for tag grouped by account.
* *
@ -115,7 +115,7 @@ class TagReportController extends Controller
return response()->json($data); return response()->json($data);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Generate expense for tag grouped on budget. * Generate expense for tag grouped on budget.
* *
@ -145,7 +145,7 @@ class TagReportController extends Controller
return response()->json($data); return response()->json($data);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Generate expense for tag grouped on category. * Generate expense for tag grouped on category.
* *
@ -175,7 +175,7 @@ class TagReportController extends Controller
return response()->json($data); return response()->json($data);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Generate main tag overview chart. * Generate main tag overview chart.
* *
@ -292,7 +292,7 @@ class TagReportController extends Controller
return response()->json($data); return response()->json($data);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Show expense grouped by expense account. * Show expense grouped by expense account.
* *
@ -323,7 +323,7 @@ class TagReportController extends Controller
return response()->json($data); return response()->json($data);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Show income grouped by tag. * Show income grouped by tag.
* *

View File

@ -37,7 +37,7 @@ use Log;
*/ */
class ExchangeController extends Controller class ExchangeController extends Controller
{ {
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Returns an exchange rate. * Returns an exchange rate.
* *

View File

@ -63,7 +63,7 @@ class ExpenseController extends Controller
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Generates the overview per budget. * Generates the overview per budget.
* *
@ -117,7 +117,7 @@ class ExpenseController extends Controller
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Generates the overview per category (spent and earned). * Generates the overview per category (spent and earned).
* *
@ -179,7 +179,7 @@ class ExpenseController extends Controller
return $result; return $result;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Overview of spending. * Overview of spending.
* *
@ -232,7 +232,7 @@ class ExpenseController extends Controller
// for period, get spent and earned for each account (by name) // for period, get spent and earned for each account (by name)
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* List of top expenses. * List of top expenses.
* *
@ -284,7 +284,7 @@ class ExpenseController extends Controller
return $result; return $result;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* List of top income. * List of top income.
* *

View File

@ -69,7 +69,7 @@ class ReportController extends Controller
} }
); );
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Show account report. * Show account report.
* *
@ -138,7 +138,7 @@ class ReportController extends Controller
return $generator->generate(); return $generator->generate();
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Show budget report. * Show budget report.
* *
@ -176,7 +176,7 @@ class ReportController extends Controller
return $generator->generate(); return $generator->generate();
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Show category report. * Show category report.
* *
@ -386,7 +386,7 @@ class ReportController extends Controller
return redirect($uri); return redirect($uri);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Get a tag report. * Get a tag report.
* *

View File

@ -90,7 +90,7 @@ class FireflyServiceProvider extends ServiceProvider
public function boot(): void public function boot(): void
{ {
Validator::resolver( Validator::resolver(
/** @noinspection MoreThanThreeArgumentsInspection */
function ($translator, $data, $rules, $messages) { function ($translator, $data, $rules, $messages) {
return new FireflyValidator($translator, $data, $rules, $messages); return new FireflyValidator($translator, $data, $rules, $messages);
} }

View File

@ -467,7 +467,7 @@ class BudgetRepository implements BudgetRepositoryInterface
return $amount; return $amount;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* @param Carbon $start * @param Carbon $start
@ -544,7 +544,7 @@ class BudgetRepository implements BudgetRepositoryInterface
return $set; return $set;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Get all budgets with these ID's. * Get all budgets with these ID's.
@ -570,7 +570,7 @@ class BudgetRepository implements BudgetRepositoryInterface
return $set; return $set;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* @param Collection $accounts * @param Collection $accounts
@ -822,7 +822,7 @@ class BudgetRepository implements BudgetRepositoryInterface
return $newBudget; return $newBudget;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* @param array $data * @param array $data

View File

@ -147,6 +147,8 @@ interface BudgetRepositoryInterface
public function getAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end): string; public function getAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end): string;
/** /**
* TODO only used in API
*
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* *
@ -165,6 +167,8 @@ interface BudgetRepositoryInterface
public function getAvailableBudgetsByDate(?Carbon $start, ?Carbon $end): Collection; public function getAvailableBudgetsByDate(?Carbon $start, ?Carbon $end): Collection;
/** /**
* TODO only used in API
*
* Returns all available budget objects. * Returns all available budget objects.
* *
* @param TransactionCurrency $currency * @param TransactionCurrency $currency
@ -205,7 +209,7 @@ interface BudgetRepositoryInterface
*/ */
public function getByIds(array $budgetIds): Collection; public function getByIds(array $budgetIds): Collection;
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* @return Collection * @return Collection
@ -244,7 +248,7 @@ interface BudgetRepositoryInterface
*/ */
public function setBudgetOrder(Budget $budget, int $order): void; public function setBudgetOrder(Budget $budget, int $order): void;
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* @param User $user * @param User $user
@ -252,6 +256,7 @@ interface BudgetRepositoryInterface
public function setUser(User $user); public function setUser(User $user);
/** /**
* TODO this method is not multi-currency aware.
* @param Collection $budgets * @param Collection $budgets
* @param Collection $accounts * @param Collection $accounts
* @param Carbon $start * @param Carbon $start
@ -261,7 +266,7 @@ interface BudgetRepositoryInterface
*/ */
public function spentInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): string; public function spentInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): string;
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Return multi-currency spent information. * Return multi-currency spent information.
@ -332,7 +337,7 @@ interface BudgetRepositoryInterface
*/ */
public function updateBudgetLimit(BudgetLimit $budgetLimit, array $data): BudgetLimit; public function updateBudgetLimit(BudgetLimit $budgetLimit, array $data): BudgetLimit;
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* @param Budget $budget * @param Budget $budget
* @param Carbon $start * @param Carbon $start

View File

@ -279,7 +279,7 @@ class CategoryRepository implements CategoryRepositoryInterface
return $this->user->categories()->find($categoryId); return $this->user->categories()->find($categoryId);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Find a category. * Find a category.
@ -317,7 +317,7 @@ class CategoryRepository implements CategoryRepositoryInterface
return $factory->findOrCreate(null, $data['name']); return $factory->findOrCreate(null, $data['name']);
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* @param Category $category * @param Category $category
@ -389,7 +389,7 @@ class CategoryRepository implements CategoryRepositoryInterface
return $lastJournalDate; return $lastJournalDate;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* @param Collection $categories * @param Collection $categories
@ -433,7 +433,7 @@ class CategoryRepository implements CategoryRepositoryInterface
return $data; return $data;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* @param Collection $accounts * @param Collection $accounts
@ -472,7 +472,7 @@ class CategoryRepository implements CategoryRepositoryInterface
return $result; return $result;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* @param Collection $categories * @param Collection $categories

View File

@ -124,7 +124,7 @@ interface CategoryRepositoryInterface
*/ */
public function getCategories(): Collection; public function getCategories(): Collection;
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Return most recent transaction(journal) date or null when never used before. * Return most recent transaction(journal) date or null when never used before.
@ -146,7 +146,7 @@ interface CategoryRepositoryInterface
*/ */
public function periodExpenses(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array; public function periodExpenses(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* @param Collection $accounts * @param Collection $accounts
@ -176,7 +176,7 @@ interface CategoryRepositoryInterface
*/ */
public function periodIncomeNoCategory(Collection $accounts, Carbon $start, Carbon $end): array; public function periodIncomeNoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* @param string $query * @param string $query
@ -185,7 +185,7 @@ interface CategoryRepositoryInterface
*/ */
public function searchCategory(string $query): Collection; public function searchCategory(string $query): Collection;
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* @param User $user * @param User $user

View File

@ -39,7 +39,7 @@ use Tests\Object\FakeApiContext;
*/ */
class ApiContext class ApiContext
{ {
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* @param BunqEnumApiEnvironmentType $environmentType * @param BunqEnumApiEnvironmentType $environmentType
* @param string $apiKey * @param string $apiKey

View File

@ -36,7 +36,7 @@ use Preferences as Prefs;
*/ */
class Amount class Amount
{ {
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* bool $sepBySpace is $localeconv['n_sep_by_space'] * bool $sepBySpace is $localeconv['n_sep_by_space']
* int $signPosn = $localeconv['n_sign_posn'] * int $signPosn = $localeconv['n_sign_posn']

View File

@ -575,7 +575,7 @@ trait AugumentData
return $grouped; return $grouped;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Spent by budget. * Spent by budget.
@ -635,7 +635,7 @@ trait AugumentData
return $sum; return $sum;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Spent by category. * Spent by category.
@ -696,7 +696,7 @@ trait AugumentData
return $sum; return $sum;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Spent in a period. * Spent in a period.
@ -744,7 +744,7 @@ trait AugumentData
return $sum; return $sum;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Returns an array with the following values: * Returns an array with the following values:

View File

@ -32,7 +32,7 @@ use Illuminate\Support\Facades\Log;
*/ */
trait CalculateRangeOccurrences trait CalculateRangeOccurrences
{ {
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences. * Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.
* *
@ -60,7 +60,7 @@ trait CalculateRangeOccurrences
return $return; return $return;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences. * Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.
* *
@ -107,7 +107,7 @@ trait CalculateRangeOccurrences
return $return; return $return;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences. * Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.

View File

@ -32,7 +32,7 @@ use Carbon\Carbon;
*/ */
trait CalculateXOccurrences trait CalculateXOccurrences
{ {
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Calculates the number of daily occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip * Calculates the number of daily occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences. * over $skipMod -1 recurrences.
@ -61,7 +61,7 @@ trait CalculateXOccurrences
return $return; return $return;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Calculates the number of monthly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip * Calculates the number of monthly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
@ -100,7 +100,7 @@ trait CalculateXOccurrences
return $return; return $return;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Calculates the number of NDOM occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip * Calculates the number of NDOM occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences. * over $skipMod -1 recurrences.
@ -139,7 +139,7 @@ trait CalculateXOccurrences
return $return; return $return;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Calculates the number of weekly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip * Calculates the number of weekly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
@ -183,7 +183,7 @@ trait CalculateXOccurrences
return $return; return $return;
} }
/** @noinspection MoreThanThreeArgumentsInspection */
/** /**
* Calculates the number of yearly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip * Calculates the number of yearly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip

View File

@ -122,7 +122,7 @@ class AmountFormat extends Twig_Extension
{ {
return new Twig_SimpleFunction( return new Twig_SimpleFunction(
'formatAmountBySymbol', 'formatAmountBySymbol',
/** @noinspection MoreThanThreeArgumentsInspection */
static function (string $amount, string $symbol, int $decimalPlaces = null, bool $coloured = null): string { static function (string $amount, string $symbol, int $decimalPlaces = null, bool $coloured = null): string {
$decimalPlaces = $decimalPlaces ?? 2; $decimalPlaces = $decimalPlaces ?? 2;
$coloured = $coloured ?? true; $coloured = $coloured ?? true;

View File

@ -63,8 +63,10 @@ class AccountValidator
$this->destError = 'No error yet.'; $this->destError = 'No error yet.';
$this->sourceError = 'No error yet.'; $this->sourceError = 'No error yet.';
$this->combinations = config('firefly.source_dests'); $this->combinations = config('firefly.source_dests');
/** @var AccountRepositoryInterface accountRepository */ /** @var AccountRepositoryInterface accountRepository */
$this->accountRepository = app(AccountRepositoryInterface::class); $this->accountRepository = app(AccountRepositoryInterface::class);
if ('testing' === config('app.env')) { if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
} }
@ -174,25 +176,12 @@ class AccountValidator
*/ */
private function canCreateType(string $accountType): bool private function canCreateType(string $accountType): bool
{ {
$result = false; $canCreate = [AccountType::EXPENSE, AccountType::REVENUE, AccountType::INITIAL_BALANCE];
switch ($accountType) { if (in_array($accountType, $canCreate, true)) {
default: return true;
Log::error(sprintf('AccountValidator::validateSource cannot handle "%s".', $this->transactionType));
break;
case AccountType::ASSET:
case AccountType::LOAN:
case AccountType::MORTGAGE:
case AccountType::DEBT:
$result = false;
break;
case AccountType::EXPENSE:
case AccountType::REVENUE:
case AccountType::INITIAL_BALANCE:
$result = true;
break;
} }
return $result; return false;
} }
/** /**
@ -225,25 +214,20 @@ class AccountValidator
*/ */
private function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account private function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account
{ {
$result = null;
// find by ID // find by ID
if ($accountId > 0) { if ($accountId > 0) {
$first = $this->accountRepository->findNull($accountId); $first = $this->accountRepository->findNull($accountId);
if ((null !== $first) && in_array($first->accountType->type, $validTypes, true)) { if ((null !== $first) && in_array($first->accountType->type, $validTypes, true)) {
$result = $first; return $first;
} }
} }
// find by name: // find by name:
if (null === $result && '' !== $accountName) { if ('' !== $accountName) {
$second = $this->accountRepository->findByName($accountName, $validTypes); return $this->accountRepository->findByName($accountName, $validTypes);
if (null !== $second) {
$result = $second;
}
} }
return $result; return null;
} }
/** /**