Fix sonarcloud issues

This commit is contained in:
James Cole
2020-06-27 17:33:18 +02:00
parent 1e35f0e7e3
commit 415fb7294c
38 changed files with 25 additions and 522 deletions

View File

@@ -79,7 +79,6 @@ class ShowController extends Controller
*/
public function show(Request $request, Category $category, Carbon $start = null, Carbon $end = null)
{
//Log::debug('Now in show()');
/** @var Carbon $start */
$start = $start ?? session('start', Carbon::now()->startOfMonth());
/** @var Carbon $end */
@@ -106,8 +105,6 @@ class ShowController extends Controller
$groups = $collector->getPaginatedGroups();
$groups->setPath($path);
//Log::debug('End of show()');
return view('categories.show', compact('category','attachments', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
}

View File

@@ -111,7 +111,6 @@ class BudgetController extends Controller
$loopStart = app('navigation')->startOfPeriod($loopStart, $step);
$currencies = [];
$defaultEntries = [];
// echo '<hr>';
while ($end >= $loopStart) {
/** @var Carbon $currentEnd */
$loopEnd = app('navigation')->endOfPeriod($loopStart, $step);

View File

@@ -85,8 +85,6 @@ class CategoryController extends Controller
$start = app('navigation')->startOfPeriod($start, $range);
$end = $this->getDate();
//Log::debug(sprintf('Full range is %s to %s', $start->format('Y-m-d'), $end->format('Y-m-d')));
/** @var WholePeriodChartGenerator $generator */
$generator = app(WholePeriodChartGenerator::class);
$chartData = $generator->generate($category, $start, $end);

View File

@@ -64,61 +64,6 @@ class CategoryReportController extends Controller
);
}
//
// /**
// * Chart for expenses grouped by expense account.
// *
// * TODO this chart is not multi-currency aware.
// *
// * @param Collection $accounts
// * @param Collection $categories
// * @param Carbon $start
// * @param Carbon $end
// * @param string $others
// *
// * @return JsonResponse
// */
// public function accountExpense(Collection $accounts, Collection $categories, Carbon $start, Carbon $end, string $others): JsonResponse
// {
// /** @var MetaPieChartInterface $helper */
// $helper = app(MetaPieChartInterface::class);
// $helper->setAccounts($accounts)->setCategories($categories)->setStart($start)->setEnd($end)->setCollectOtherObjects(1 === (int)$others);
//
// $chartData = $helper->generate('expense', 'account');
// $data = $this->generator->pieChart($chartData);
//
// return response()->json($data);
// }
//
// /**
// * Chart for income grouped by revenue account.
// *
// * TODO this chart is not multi-currency aware.
// *
// * @param Collection $accounts
// * @param Collection $categories
// * @param Carbon $start
// * @param Carbon $end
// * @param string $others
// *
// * @return JsonResponse
// */
// public function accountIncome(Collection $accounts, Collection $categories, Carbon $start, Carbon $end, string $others): JsonResponse
// {
// /** @var MetaPieChartInterface $helper */
// $helper = app(MetaPieChartInterface::class);
// $helper->setAccounts($accounts);
// $helper->setCategories($categories);
// $helper->setStart($start);
// $helper->setEnd($end);
// $helper->setCollectOtherObjects(1 === (int)$others);
// $chartData = $helper->generate('income', 'account');
// $data = $this->generator->pieChart($chartData);
//
// return response()->json($data);
// }
/**
* @param Collection $accounts
* @param Collection $categories

View File

@@ -237,20 +237,16 @@ class ProfileController extends Controller
/** @var Collection $set */
$set = app('preferences')->findByName('email_change_confirm_token');
$user = null;
//Log::debug(sprintf('Found %d preferences', $set->count()));
/** @var Preference $preference */
foreach ($set as $preference) {
if ($preference->data === $token) {
//Log::debug('Found user');
$user = $preference->user;
}
}
// update user to clear blocked and blocked_code.
if (null === $user) {
//Log::debug('Found no user');
throw new FireflyException('Invalid token.');
}
//Log::debug('Will unblock user.');
$repository->unblockUser($user);
// return to login.
@@ -372,7 +368,7 @@ class ProfileController extends Controller
/**
* @return Factory|View
*/
public function newBackupCodes()
public function newBackupCodes(Request $request)
{
if ($this->externalIdentity) {
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));

View File

@@ -121,10 +121,6 @@ class IndexController extends Controller
}
}
//if (0 !== $recurrence->recurrenceRepetitions->count()) {
//$array['ocurrences'] = array_slice($this->recurring->getOccurrencesInRange($recurrence->recurrenceRepetitions->first(), $today, $year), 0, 1);
//}
$recurring[] = $array;
}
$paginator = new LengthAwarePaginator($recurring, $total, $pageSize, $page);

View File

@@ -489,287 +489,6 @@ class DoubleController extends Controller
return $result;
}
//
//
// /**
// * Generates the overview per budget.
// *
// * @param Collection $accounts
// * @param Collection $expense
// * @param Carbon $start
// * @param Carbon $end
// *
// * @return string
// */
// public function budget(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): string
// {
// // Properties for cache:
// $cache = new CacheProperties;
// $cache->addProperty($start);
// $cache->addProperty($end);
// $cache->addProperty('expense-budget');
// $cache->addProperty($accounts->pluck('id')->toArray());
// $cache->addProperty($expense->pluck('id')->toArray());
// if ($cache->has()) {
// return $cache->get(); // @codeCoverageIgnore
// }
// $combined = $this->combineAccounts($expense);
// $all = new Collection;
// foreach ($combined as $combi) {
// $all = $all->merge($combi);
// }
// // now find spent / earned:
// $spent = $this->spentByBudget($accounts, $all, $start, $end);
// // join arrays somehow:
// $together = [];
// foreach ($spent as $categoryId => $spentInfo) {
// if (!isset($together[$categoryId])) {
// $together[$categoryId]['spent'] = $spentInfo;
// $together[$categoryId]['budget'] = $spentInfo['name'];
// $together[$categoryId]['grand_total'] = '0';
// }
// $together[$categoryId]['grand_total'] = bcadd($spentInfo['grand_total'], $together[$categoryId]['grand_total']);
// }
// try {
// $result = view('reports.partials.exp-budgets', compact('together'))->render();
// // @codeCoverageIgnoreStart
// } catch (Throwable $e) {
// Log::error(sprintf('Could not render category::budget: %s', $e->getMessage()));
// $result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
// }
// // @codeCoverageIgnoreEnd
// $cache->store($result);
//
// return $result;
// }
//
//
//
// /**
// * Generates the overview per category (spent and earned).
// *
// * @param Collection $accounts
// * @param Collection $expense
// * @param Carbon $start
// * @param Carbon $end
// *
// * @return string
// */
// public function category(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): string
// {
// // Properties for cache:
// $cache = new CacheProperties;
// $cache->addProperty($start);
// $cache->addProperty($end);
// $cache->addProperty('expense-category');
// $cache->addProperty($accounts->pluck('id')->toArray());
// $cache->addProperty($expense->pluck('id')->toArray());
// if ($cache->has()) {
// return $cache->get(); // @codeCoverageIgnore
// }
// $combined = $this->combineAccounts($expense);
// $all = new Collection;
// foreach ($combined as $combi) {
// $all = $all->merge($combi);
// }
// // now find spent / earned:
// $spent = $this->spentByCategory($accounts, $all, $start, $end);
// $earned = $this->earnedByCategory($accounts, $all, $start, $end);
// // join arrays somehow:
// $together = [];
// foreach ($spent as $categoryId => $spentInfo) {
// if (!isset($together[$categoryId])) {
// $together[$categoryId]['spent'] = $spentInfo;
// $together[$categoryId]['category'] = $spentInfo['name'];
// $together[$categoryId]['grand_total'] = '0';
// }
// $together[$categoryId]['grand_total'] = bcadd($spentInfo['grand_total'], $together[$categoryId]['grand_total']);
// }
// foreach ($earned as $categoryId => $earnedInfo) {
// if (!isset($together[$categoryId])) {
// $together[$categoryId]['earned'] = $earnedInfo;
// $together[$categoryId]['category'] = $earnedInfo['name'];
// $together[$categoryId]['grand_total'] = '0';
// }
// $together[$categoryId]['grand_total'] = bcadd($earnedInfo['grand_total'], $together[$categoryId]['grand_total']);
// }
// try {
// $result = view('reports.partials.exp-categories', compact('together'))->render();
// // @codeCoverageIgnoreStart
// } catch (Throwable $e) {
// Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
// $result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
// }
// // @codeCoverageIgnoreEnd
// $cache->store($result);
//
// return $result;
// }
//
//
// /**
// * Overview of spending.
// *
// * @param Collection $accounts
// * @param Collection $expense
// * @param Carbon $start
// * @param Carbon $end
// *
// * @return array|mixed|string
// */
// public function spent(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
// {
// // chart properties for cache:
// $cache = new CacheProperties;
// $cache->addProperty($start);
// $cache->addProperty($end);
// $cache->addProperty('expense-spent');
// $cache->addProperty($accounts->pluck('id')->toArray());
// $cache->addProperty($expense->pluck('id')->toArray());
// if ($cache->has()) {
// return $cache->get(); // @codeCoverageIgnore
// }
//
// $combined = $this->combineAccounts($expense);
// $result = [];
//
// foreach ($combined as $name => $combi) {
// /**
// * @var string
// * @var Collection $combi
// */
// $spent = $this->spentInPeriod($accounts, $combi, $start, $end);
// $earned = $this->earnedInPeriod($accounts, $combi, $start, $end);
// $result[$name] = [
// 'spent' => $spent,
// 'earned' => $earned,
// ];
// }
// try {
// $result = view('reports.partials.exp-not-grouped', compact('result'))->render();
// // @codeCoverageIgnoreStart
// } catch (Throwable $e) {
// Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
// $result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
// }
// // @codeCoverageIgnoreEnd
// $cache->store($result);
//
// return $result;
// // for period, get spent and earned for each account (by name)
// }
//
//
// /**
// * List of top expenses.
// *
// * @param Collection $accounts
// * @param Collection $expense
// * @param Carbon $start
// * @param Carbon $end
// *
// * @return string
// */
// public function topExpense(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): string
// {
// // Properties for cache:
// $cache = new CacheProperties;
// $cache->addProperty($start);
// $cache->addProperty($end);
// $cache->addProperty('top-expense');
// $cache->addProperty($accounts->pluck('id')->toArray());
// $cache->addProperty($expense->pluck('id')->toArray());
// if ($cache->has()) {
// return $cache->get(); // @codeCoverageIgnore
// }
// $combined = $this->combineAccounts($expense);
// $all = new Collection;
// foreach ($combined as $combi) {
// $all = $all->merge($combi);
// }
// // get all expenses in period:
// /** @var GroupCollectorInterface $collector */
// $collector = app(GroupCollectorInterface::class);
//
// $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setAccounts($accounts);
// $collector->setAccounts($all)->withAccountInformation();
// $sorted = $collector->getExtractedJournals();
//
// usort($sorted, function ($a, $b) {
// return $a['amount'] <=> $b['amount']; // @codeCoverageIgnore
// });
//
// try {
// $result = view('reports.partials.top-transactions', compact('sorted'))->render();
// // @codeCoverageIgnoreStart
// } catch (Throwable $e) {
// Log::error(sprintf('Could not render category::topExpense: %s', $e->getMessage()));
// $result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
// }
// // @codeCoverageIgnoreEnd
// $cache->store($result);
//
// return $result;
// }
//
// /**
// * List of top income.
// *
// * @param Collection $accounts
// * @param Collection $expense
// * @param Carbon $start
// * @param Carbon $end
// *
// * @return mixed|string
// */
// public function topIncome(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
// {
// // Properties for cache:
// $cache = new CacheProperties;
// $cache->addProperty($start);
// $cache->addProperty($end);
// $cache->addProperty('top-income');
// $cache->addProperty($accounts->pluck('id')->toArray());
// $cache->addProperty($expense->pluck('id')->toArray());
// if ($cache->has()) {
// return $cache->get(); // @codeCoverageIgnore
// }
// $combined = $this->combineAccounts($expense);
// $all = new Collection;
// foreach ($combined as $combi) {
// $all = $all->merge($combi);
// }
// // get all expenses in period:
//
// /** @var GroupCollectorInterface $collector */
// $collector = app(GroupCollectorInterface::class);
//
// $total = $accounts->merge($all);
// $collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAccounts($total)->withAccountInformation();
// $sorted = $collector->getExtractedJournals();
//
// foreach (array_keys($sorted) as $key) {
// $sorted[$key]['amount'] = bcmul($sorted[$key]['amount'], '-1');
// }
//
// usort($sorted, function ($a, $b) {
// return $a['amount'] <=> $b['amount']; // @codeCoverageIgnore
// });
//
// try {
// $result = view('reports.partials.top-transactions', compact('sorted'))->render();
// // @codeCoverageIgnoreStart
// } catch (Throwable $e) {
// Log::error(sprintf('Could not render category::topIncome: %s', $e->getMessage()));
// $result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());
// }
// // @codeCoverageIgnoreEnd
// $cache->store($result);
//
// return $result;
// }
/**
* TODO this method is double.
*

View File

@@ -182,8 +182,6 @@ class MassController extends Controller
$count++;
} catch (FireflyException $e) { // @codeCoverageIgnore
// do something with error.
//echo $e->getMessage();
//exit;
}
}

View File

@@ -46,7 +46,6 @@ class InterestingMessage
*/
public function handle(Request $request, Closure $next)
{
//Log::debug(sprintf('Interesting Message middleware for URI %s', $request->url()));
if ($this->testing()) {
return $next($request);
}