-
Notifications
You must be signed in to change notification settings - Fork 5
Reducing complexity of execute method in SuggestCommand #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
just wondering, should I reformat the whole thing to match psr2? would look cleaner obviously and could be tested automatically, on the other hand it might makie diffs across that change harder to read. |
Please keep the style as is for now. I'd rather not have style change because of an unrelated PR. |
bin/php-semver-checker-git
Outdated
require $path; | ||
$found = true; | ||
break; | ||
require($path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit unrelated to this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, not quite sure why I committed this to this branch. Should I remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Please keep the PR contained 😉.
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use vierbergenlars\SemVer\expression as SemanticExpression; | ||
use vierbergenlars\SemVer\SemVerException as SemanticVersionException; | ||
use vierbergenlars\SemVer\version as SemanticVersion; | ||
use PHPSemVerChecker\Report\Report; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow alphabetical ordering.
array(Level::PATCH, $this->getMockedVersion(1,0,0), '1.0.1'), | ||
array(Level::MINOR, $this->getMockedVersion(1,0,0), '1.1.0'), | ||
array(Level::MAJOR, $this->getMockedVersion(1,0,0), '2.0.0'), | ||
//v2.3.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything in particular not tested by the v1.0.0 case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
making sure the incrementing does zero out the next lower version number. Might be a bit more than required.
* @test | ||
* @dataProvider provideGetNextTag | ||
*/ | ||
public function testGetNextTag($level, version $version, $expected) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would probably be simpler to read using mockery.
use PHPSemVerChecker\SemanticVersioning\Level; | ||
use vierbergenlars\SemVer\version; | ||
|
||
class SuggestCommandTest extends TestCase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for the added tests.
* @param string[] $files | ||
* @param Scanner $scanner | ||
*/ | ||
public function __construct($originalAmount, array &$files, Scanner &$scanner) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather have the list of original (unfiltered) files here than the count.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's any usage of that list after this point, but I'll adjust the class.
* @param string[] $files | ||
* @param Scanner $scanner | ||
*/ | ||
public function __construct($originalAmount, array &$files, Scanner &$scanner) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a reference to the files array?
* @param $exclude | ||
* @return ProcessedFileList | ||
*/ | ||
public function processFileList( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this on multiple lines?
* @param Scanner $scanner | ||
* @param array $files | ||
*/ | ||
private function scanFileList(Scanner &$scanner, array &$files) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why references?
adjusting ordering of use statements in SuggestCommand adjusting ProcessedFileList to hold the actual file lists removing useless linebreaks from method definition extracting reflecting in test for easier readability
@@ -50,8 +50,8 @@ private function getRepository($directory) | |||
} | |||
|
|||
/** | |||
* @param \Symfony\Component\Console\Input\InputInterface $input | |||
* @param \Symfony\Component\Console\Output\OutputInterface $output | |||
* @param InputInterface $input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful, we still want the FQCN (fully qualified class name).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having FQN in PHPdoc looks inconsistent to me when they aren't also used elsewhere, Will fix those.
/** | ||
* @return int | ||
*/ | ||
public function getOriginalAmount() | ||
public function getFilteredAmount() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use "count" instead of "amount" (see https://english.stackexchange.com/questions/141564/differences-between-amount-count-number-and-quantity)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very useful, thank you.
changing Amount to Count for list size
is there any todo left @tomzx ? |
I'll review this again over the next few days. Thanks for the ping. |
thanks :) |
I took the liberty of ripping appart the execute method to make other goals(like testing) easier to achieve.
The following was done: