for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Tavii\SQSJobQueueBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Tavii\SQSJobQueue\Queue\QueueName;
class QueueCreateCommand extends ContainerAwareCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
$this->setName('sqs_job_queue:queue-create')
->setDescription('create queue')
->addArgument('queue', InputArgument::REQUIRED, 'queue name')
->addOption('delaySec', 'S', InputOption::VALUE_OPTIONAL, 'DelaySeconds', 0)
;
}
public function execute(InputInterface $input, OutputInterface $output)
$prefix = $this->getContainer()->getParameter('sqs_job_queue.prefix');
$prefix
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.
$myVar
$higher
$client = $this->getContainer()->get('sqs_job_queue.client');
$queueName = new QueueName($input->getArgument('queue'), $this->getContainer()->getParameter('sqs_job_queue.prefix'));
$client->createQueue(array(
'QueueName' => $queueName->getQueueName(),
'Attributes' => array(
'DelaySeconds' => $input->getOption('delaySec')
),
));
$output->writeln('<info>SUCCESS:</info> '.$queueName->getQueueName());
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.