Code should not be duplicated

  • Minor
  • Architecture

More information: https://insight.sensiolabs.com/what-we-analyse/php.duplicated_code

  1. * @return ResponseInterface
  2. */
  3. public function __invoke(
  4. ServerRequestInterface $request,
  5. ResponseInterface $response,
  6. Exception $error

    The next 84 lines appear both in src/Charcoal/App/Handler/Error.php:36 and src/Charcoal/App/Handler/PhpError.php:36.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Chauncey McAskill
  7. ) {
  8. $this->setHttpRequest($request);
  9. $this->setThrown($error);
  10. $contentType = $this->determineContentType($request);

Source code should not contain TODO comments 2

  • Minor
  • Architecture

More information: https://insight.sensiolabs.com/what-we-analyse/task_todo_comment

  1. * @return void
  2. */
  3. protected function registerScriptServices(Container $container)
  4. {
  5. /**
  6. * @todo Needs implementation

    TODO comments are left in the code when a feature (or a bug) isn't completely developed (or fixed). You should complete the implementation and remove the comment.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Chauncey McAskill
  7. * @param Container $container A container instance.
  8. * @return null|\League\CLImate\Util\Reader\ReaderInterface
  9. */
  10. $container['climate/reader'] = function (Container $container) {
  11. return null;
  1. abstract public function getMessage();
  2. /**
  3. * Set dependencies from the service locator.
  4. *
  5. * @todo Maybe add \Psr\Log\LoggerInterface?

    TODO comments are left in the code when a feature (or a bug) isn't completely developed (or fixed). You should complete the implementation and remove the comment.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Chauncey McAskill
  6. * @param Container $container A service locator.
  7. * @return self
  8. */
  9. protected function setDependencies(Container $container)
  10. {

Unused method, property, variable or parameter 5

  • Minor
  • Deadcode

More information: https://insight.sensiolabs.com/what-we-analyse/php.unused_local_variable_or_private_member

Updated rule! We've recently tweaked this rule. This may explain the disappearance of false positives, or new violations not linked to any activity in the code.
  1. private $ignoredQuery;
  2. /**
  3. * @var boolean
  4. */
  5. private $headers;

    This headers attribute is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Mathieu Ducharme
  6. /**
  7. * @param array $data Constructor dependencies and options.
  8. */
  9. public function __construct(array $data)
  1. /**
  2. * @param RequestInterface $request The PSR-7 HTTP request.
  3. * @return string
  4. */
  5. private function getClientIp(RequestInterface $request)

    This request argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Mathieu Ducharme
  6. {
  7. if (isset($_SERVER['REMOTE_ADDR'])) {
  8. return filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
  9. }
  10. return '';
  1. */
  2. protected function templateContent(
  3. Container $container,
  4. RequestInterface $request
  5. ) {
  6. $config = $this->config();

    This config local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Chauncey McAskill
  7. if ($this->cacheEnabled()) {
  8. $cachePool = $container['cache'];
  9. $cacheKey = str_replace('/', '.', 'template.'.$this->cacheIdent());
  10. $cacheItem = $cachePool->getItem($cacheKey);
  1. $this->{$setter}($value);
  2. }
  3. if ($ask) {
  4. if (isset($param['prompt'])) {
  5. $label = $param['prompt'];

    This label local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Chauncey McAskill
  6. } else {
  7. continue;
  8. }
  9. $value = $this->input($key);
  1. *
  2. * @param Container $container A Pimple DI container.
  3. * @return \Charcoal\App\Handler\HandlerInterface
  4. */
  5. $container['maintenanceHandler'] = function (Container $container) use ($config) {
  6. $maintenanceConfig = isset($config['maintenance']) ? $config['maintenance'] : [];

    This maintenanceConfig local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Mathieu Ducharme
  7. $handler = new Maintenance($container, $config['maintenance']);
  8. return $handler->init();
  9. };
  10. }