From 336503db3e40bc928b359d21c5e9efc7a1b08c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Mon, 24 Dec 2018 16:28:50 +0100 Subject: [PATCH 1/2] Fix: Return early --- src/Command/NormalizeCommand.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Command/NormalizeCommand.php b/src/Command/NormalizeCommand.php index 69ea6e7e..3f2f5676 100644 --- a/src/Command/NormalizeCommand.php +++ b/src/Command/NormalizeCommand.php @@ -235,24 +235,24 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O $noUpdateLock = $input->getOption('no-update-lock'); - if (false === $noUpdateLock && true === $locker->isLocked()) { - $io->write('Updating lock file.'); + if (true === $noUpdateLock || false === $locker->isLocked()) { + return 0; + } - $this->resetComposer(); + $io->write('Updating lock file.'); - $file = $input->getArgument('file'); + $this->resetComposer(); - if (\is_string($file)) { - return $this->updateLockerInWorkingDirectory( - $output, - \dirname($file) - ); - } + $file = $input->getArgument('file'); - return $this->updateLocker($output); + if (\is_string($file)) { + return $this->updateLockerInWorkingDirectory( + $output, + \dirname($file) + ); } - return 0; + return $this->updateLocker($output); } /** From 1264aaf71c3baa51c3eaa65d315019e013dacb9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Mon, 24 Dec 2018 16:30:48 +0100 Subject: [PATCH 2/2] Fix: Inline variables --- src/Command/NormalizeCommand.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Command/NormalizeCommand.php b/src/Command/NormalizeCommand.php index 3f2f5676..8a149193 100644 --- a/src/Command/NormalizeCommand.php +++ b/src/Command/NormalizeCommand.php @@ -106,8 +106,6 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O { $io = $this->getIO(); - $dryRun = $input->getOption('dry-run'); - try { $indent = $this->indentFrom($input); } catch (\RuntimeException $exception) { @@ -199,7 +197,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O return 0; } - if (true === $dryRun) { + if (true === $input->getOption('dry-run')) { $io->writeError(\sprintf( '%s is not normalized.', $composerFile @@ -233,9 +231,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O $composerFile )); - $noUpdateLock = $input->getOption('no-update-lock'); - - if (true === $noUpdateLock || false === $locker->isLocked()) { + if (true === $input->getOption('no-update-lock') || false === $locker->isLocked()) { return 0; }