Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
datashaman committed Apr 15, 2019
1 parent 847d12c commit 9997b03
Show file tree
Hide file tree
Showing 24 changed files with 130 additions and 109 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ phpcheck:
phpcheck-no-defects:
@phpcheck -d

php-cs-fixer:
php-cs-fixer fix --using-cache=no

phpmd:
@phpmd src,checks text phpmd.xml

Expand Down
3 changes: 2 additions & 1 deletion checks/GenCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck\Checks;

use Datashaman\PHPCheck\Check;
Expand Down
8 changes: 7 additions & 1 deletion phpmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
<description>
Mess detection rules for PHPCheck
</description>
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag" />
<rule ref="rulesets/cleancode.xml/ElseExpression" />
<rule ref="rulesets/cleancode.xml/StaticAccess">
<properties>
<property name="exceptions" value="\Faker\Factory,\phpDocumentor\Reflection\DocBlockFactory,\Webmozart\Assert\Assert" />
</properties>
</rule>
<rule ref="rulesets/codesize.xml" />
<rule ref="rulesets/cleancode.xml" />
<rule ref="rulesets/controversial.xml" />
<rule ref="rulesets/design.xml" />
<rule ref="rulesets/naming.xml" />
Expand Down
3 changes: 2 additions & 1 deletion src/ArgumentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck;

use Exception;
Expand Down
3 changes: 2 additions & 1 deletion src/Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck;

class Check
Expand Down
3 changes: 2 additions & 1 deletion src/CheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck;

use Symfony\Component\Console\Command\Command;
Expand Down
3 changes: 2 additions & 1 deletion src/CheckEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck;

final class CheckEvents
Expand Down
3 changes: 2 additions & 1 deletion src/Events/EndAllEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck\Events;

class EndAllEvent extends Event
Expand Down
3 changes: 2 additions & 1 deletion src/Events/EndEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck\Events;

use ReflectionMethod;
Expand Down
3 changes: 2 additions & 1 deletion src/Events/ErrorEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck\Events;

class ErrorEvent extends ResultEvent
Expand Down
3 changes: 2 additions & 1 deletion src/Events/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck\Events;

abstract class Event extends \Symfony\Component\EventDispatcher\Event
Expand Down
3 changes: 2 additions & 1 deletion src/Events/FailureEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck\Events;

class FailureEvent extends ResultEvent
Expand Down
3 changes: 2 additions & 1 deletion src/Events/ResultEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck\Events;

use ReflectionMethod;
Expand Down
3 changes: 2 additions & 1 deletion src/Events/StartAllEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck\Events;

class StartAllEvent extends Event
Expand Down
3 changes: 2 additions & 1 deletion src/Events/StartEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck\Events;

use ReflectionMethod;
Expand Down
3 changes: 2 additions & 1 deletion src/Events/SuccessEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck\Events;

class SuccessEvent extends ResultEvent
Expand Down
3 changes: 2 additions & 1 deletion src/ExecutionError.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck;

use Exception;
Expand Down
3 changes: 2 additions & 1 deletion src/ExecutionFailure.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck;

use Exception;
Expand Down
7 changes: 4 additions & 3 deletions src/Gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck;

use Faker\Factory;
Expand All @@ -18,8 +19,6 @@

class Gen
{
protected const DEFAULT_SIZE = 30;

public const MIN_UNICODE = 0;

public const MAX_UNICODE = 0x10FFFF;
Expand All @@ -32,6 +31,8 @@ class Gen
[0x100000, 0x10FFFD],
];

protected const DEFAULT_SIZE = 30;

/**
* @var FakerGenerator
*/
Expand Down
9 changes: 5 additions & 4 deletions src/Reporters/ConsoleReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck\Reporters;

use Datashaman\PHPCheck\CheckCommand;
Expand Down Expand Up @@ -95,12 +96,12 @@ public function onEnd(Events\EndEvent $event): void

public function onEndAll(Events\EndAllEvent $event): void
{
$errors = $this->state->getErrors();
$failures = $this->state->getFailures();
$errors = $this->state->getErrors();
$failures = $this->state->getFailures();
$successes = $this->state->getSuccesses();

$successCount = \count($successes);
$errorCount = \count($errors);
$errorCount = \count($errors);
$failureCount = \count($failures);

$totalCount = $successCount + $errorCount + $failureCount;
Expand Down
3 changes: 2 additions & 1 deletion src/Reporters/JUnitReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck\Reporters;

use Datashaman\PHPCheck\CheckEvents;
Expand Down
9 changes: 5 additions & 4 deletions src/Reporters/Reporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/*
* This file is part of the phpcheck package.
*
* (c) Marlin Forbes <marlinf@datashaman.com>
* ©Marlin Forbes <marlinf@datashaman.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Datashaman\PHPCheck\Reporters;

use Datashaman\PHPCheck\Runner;
Expand Down Expand Up @@ -44,9 +45,9 @@ protected function convertBytes(int $bytes): string
return '0.00 B';
}

$s = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
$e = (int) \floor(\log($bytes, 1024));
$suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
$exponent = (int) \floor(\log($bytes, 1024));

return \sprintf('%.2f %s', \round($bytes / 1024 ** $e, 2), $s[$e]);
return \sprintf('%.2f %s', \round($bytes / 1024 ** $exponent, 2), $suffixes[$exponent]);
}
}
Loading

0 comments on commit 9997b03

Please sign in to comment.