Code clean up. [skip ci]

This commit is contained in:
James Cole 2016-04-26 12:39:29 +02:00
parent d551333fa2
commit dfbe6e5b6e
17 changed files with 47 additions and 64 deletions

View File

@ -1,36 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
command line:
phpmd app html ./_development/phpmd/phpmd.xml > ./public/result.html
-->
<ruleset name="pcsg-generated-ruleset"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>Created with the PHP Coding Standard Generator. http://edorian.github.com/php-coding-standard-generator/
</description>
<description>Bla bla</description>
<!-- Import the entire controversial code rule set, except one -->
<rule ref="rulesets/controversial.xml">
<exclude name="CamelCasePropertyName" />
</rule>
<!-- clean code -->
<!-- <rule ref="rulesets/cleancode.xml" /> -->
<rule ref="rulesets/codesize.xml" />
<rule ref="rulesets/design.xml" />
<rule ref="rulesets/naming.xml" />
<rule ref="rulesets/unusedcode.xml" />
<!-- clean code static calling rule can be a little more lax: -->
<rule ref="rulesets/cleancode.xml">
<exclude name="StaticAccess" />
</rule>
<!-- report level 5 for cyclomatic complexity -->
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">
<properties>
<property name="reportLevel" value="5"/>
</properties>
<properties>
<property name="reportLevel" value="5"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/NPathComplexity">
<properties>
<property name="minimum" value="128"/>
</properties>
<properties>
<property name="minimum" value="128"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
<properties>
<property name="minimum" value="40"/>
</properties>
<properties>
<property name="minimum" value="40"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveParameterList">
<properties>
<property name="minimum" value="5"/>
</properties>
<properties>
<property name="minimum" value="5"/>
</properties>
</rule>
<!-- Import rule set and exclude rules -->
<rule ref="rulesets/controversial.xml">
<exclude name="CamelCasePropertyName" />
</rule>
</ruleset>
</ruleset>

View File

@ -61,7 +61,6 @@ class Kernel extends ConsoleKernel
*
* @return void
*
* @SuppressWarnings(PHPMD.UnusedFormalParameters)
*/
protected function schedule(Schedule $schedule)
{

View File

@ -10,6 +10,7 @@ declare(strict_types = 1);
namespace FireflyIII\Export;
use FireflyIII\Export\Entry\Entry;
use FireflyIII\Models\ExportJob;
use Log;
use Storage;

View File

@ -8,7 +8,7 @@ declare(strict_types = 1);
* of the MIT license. See the LICENSE file for details.
*/
namespace FireflyIII\Export;
namespace FireflyIII\Export\Entry;
use FireflyIII\Models\Account;
use FireflyIII\Models\Budget;
@ -30,7 +30,7 @@ use FireflyIII\Models\TransactionJournal;
*
* Class Entry
*
* @package FireflyIII\Export
* @package FireflyIII\Export\Entry
*/
class Entry
{

View File

@ -10,7 +10,7 @@ declare(strict_types = 1);
namespace FireflyIII\Export\Exporter;
use FireflyIII\Export\Entry;
use FireflyIII\Export\Entry\Entry;
use FireflyIII\Models\ExportJob;
use League\Csv\Writer;
use SplFileObject;

View File

@ -13,6 +13,7 @@ namespace FireflyIII\Export;
use Auth;
use Config;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Export\Entry\Entry;
use FireflyIII\Models\ExportJob;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalCollector;

View File

@ -178,7 +178,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface
* @param Carbon $start
* @param Carbon $end
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*
*
* @return BalanceLine
*/

View File

@ -232,7 +232,6 @@ class BudgetController extends Controller
* @param Collection $accounts
* @param Collection $budgets
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList) // need all parameters
*
* @return \Illuminate\Http\JsonResponse
*/

View File

@ -49,8 +49,6 @@ class CategoryController extends Controller
* @param SCRI $repository
* @param Category $category
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function all(SCRI $repository, Category $category)
@ -115,10 +113,6 @@ class CategoryController extends Controller
* @param Carbon $end
* @param Collection $accounts
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList) // cant avoid it.
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // it's long but ok.
*
* @return \Illuminate\Http\JsonResponse
*/
public function earnedInPeriod(CRI $repository, string $reportType, Carbon $start, Carbon $end, Collection $accounts)
@ -307,8 +301,6 @@ class CategoryController extends Controller
* @param Carbon $end
* @param Collection $accounts
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList) // need all parameters
* @SuppressWarnings(PHPMD.ExcessuveMethodLength) // need the length
*
* @return \Illuminate\Http\JsonResponse
*/

View File

@ -88,7 +88,6 @@ class ReportController extends Controller
* @param Carbon $end
* @param Collection $accounts
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList) // cant avoid it.
*
* @return \Illuminate\Http\JsonResponse
*/

View File

@ -337,7 +337,6 @@ class CsvController extends Controller
*
* STEP SIX
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity) it's 6, but it's allright.
*
* @return \Illuminate\Http\RedirectResponse
*/
@ -383,9 +382,6 @@ class CsvController extends Controller
*
* STEP TWO
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // need the length.
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // its exactly 5, its ok
*
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse

View File

@ -566,8 +566,6 @@ class AccountRepository implements AccountRepositoryInterface
* @param Account $account
* @param array $data
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // need the complexity.
*
* @return Account
*/
public function update(Account $account, array $data): Account

View File

@ -310,8 +310,6 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
* @param Carbon $start
* @param Carbon $end
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // it's a query.
*
* @return array
*/
public function getBudgetsAndExpensesPerYear(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array

View File

@ -388,7 +388,6 @@ class JournalRepository implements JournalRepositoryInterface
*
* @return array
* @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function storeAccounts(TransactionType $type, array $data): array
{

View File

@ -36,8 +36,6 @@ class TagRepository implements TagRepositoryInterface
* @param TransactionJournal $journal
* @param Tag $tag
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
*
* @return bool
*/
public function connect(TransactionJournal $journal, Tag $tag): bool
@ -139,8 +137,6 @@ class TagRepository implements TagRepositoryInterface
* @param TransactionJournal $journal
* @param Tag $tag
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*
* @return bool
*/
protected function connectAdvancePayment(TransactionJournal $journal, Tag $tag): bool
@ -222,7 +218,6 @@ class TagRepository implements TagRepositoryInterface
* @param TransactionJournal $journal
* @param Tag $tag
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's complex but nothing can be done.
*
* @return bool
*/

View File

@ -237,7 +237,6 @@ class TestData
* @param Carbon $date
*
* @return TransactionJournal
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public static function createCar(User $user, Carbon $date): TransactionJournal
{
@ -283,7 +282,6 @@ class TestData
*
* @return bool
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public static function createDrinksAndOthers(User $user, Carbon $date): bool
{
@ -350,7 +348,6 @@ class TestData
*
* @return bool
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public static function createGroceries(User $user, Carbon $date): bool
{
@ -453,7 +450,6 @@ class TestData
*
* @return bool
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public static function createPiggybanks(User $user): bool
{

View File

@ -38,7 +38,6 @@ class FireflyValidator extends Validator
* @param array $messages
* @param array $customAttributes
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList) // inherited from Laravel.
*/
public function __construct(TranslatorInterface $translator, array $data, array $rules, array $messages = [], array $customAttributes = [])
{
@ -50,7 +49,6 @@ class FireflyValidator extends Validator
* @param $value
* @param $parameters
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return bool
*/
@ -92,7 +90,6 @@ class FireflyValidator extends Validator
* @param $attribute
* @param $value
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return bool
*/
@ -214,7 +211,6 @@ class FireflyValidator extends Validator
* @param $value
* @param $parameters
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return bool
*/
@ -279,7 +275,6 @@ class FireflyValidator extends Validator
* @param $value
* @param $parameters
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return bool
*/
@ -310,7 +305,6 @@ class FireflyValidator extends Validator
* @param $value
* @param $parameters
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return bool
*/
@ -342,9 +336,6 @@ class FireflyValidator extends Validator
* @param $value
* @param $parameters
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter) // cant remove it
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // its as simple as I can get it.
*
* @return bool
*/
public function validateUniquePiggyBankForUser($attribute, $value, $parameters): bool