Skip to content

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

Merged
merged 16 commits into from
Jul 29, 2018

Conversation

Idrinth
Copy link
Contributor

@Idrinth Idrinth commented Mar 20, 2018

I took the liberty of ripping appart the execute method to make other goals(like testing) easier to achieve.

The following was done:

  • moved duplicate code to methods
  • extracted classes to wrap logically related functionality or data

@Idrinth
Copy link
Contributor Author

Idrinth commented Mar 20, 2018

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.

@tomzx
Copy link
Owner

tomzx commented Apr 13, 2018

Please keep the style as is for now. I'd rather not have style change because of an unrelated PR.

require $path;
$found = true;
break;
require($path);
Copy link
Owner

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.

Copy link
Contributor Author

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?

Copy link
Owner

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;
Copy link
Owner

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
Copy link
Owner

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?

Copy link
Contributor Author

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) {
Copy link
Owner

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
Copy link
Owner

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)
Copy link
Owner

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.

Copy link
Contributor Author

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)
Copy link
Owner

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(
Copy link
Owner

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why references?

Idrinth added 2 commits April 14, 2018 13:36
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
Copy link
Owner

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).

Copy link
Contributor Author

@Idrinth Idrinth Apr 14, 2018

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()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very useful, thank you.

Idrinth added 2 commits April 14, 2018 18:46
changing Amount to Count for list size
@Idrinth
Copy link
Contributor Author

Idrinth commented Jul 24, 2018

is there any todo left @tomzx ?

@tomzx
Copy link
Owner

tomzx commented Jul 24, 2018

I'll review this again over the next few days. Thanks for the ping.

@tomzx tomzx merged commit 54c5324 into tomzx:master Jul 29, 2018
@Idrinth
Copy link
Contributor Author

Idrinth commented Jul 29, 2018

thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants