Source code should not contain TODO comments 3

  • Minor
  • Architecture

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

  1. * - domain : filename prefix
  2. * - recursive : level of recursiveness (how deep the glob checks for the strings)
  3. * - path : Path to get translation from a precise location (i.e: templates/emails/)
  4. * - type : file type (either mustache or php)
  5. *
  6. * @todo Support php file type.

    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 Bene
  7. * @return array
  8. */
  9. public function defaultArguments()
  10. {
  11. $arguments = [
  1. {
  2. if (!$this->paths) {
  3. $this->paths = $this->appConfig->get('view.paths');
  4. // Hardcoded
  5. // @todo change this

    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 Bene
  6. $this->paths[] = 'src/';
  7. }
  8. return $this->paths;
  9. }
  1. $container['translator/message-selector'] = function () {
  2. return null;
  3. };
  4. /**
  5. * @todo Improve file loader with a map of file formats.

    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 Pimple DI container.
  7. * @return Translator
  8. */
  9. $container['translator'] = function (Container $container) {

Commented code should not be committed 2

  • Minor
  • Deadcode

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

  1. $translations = [];
  2. // Array index for the preg_match.
  3. $index = 'text';
  4. // if ($fileType == 'php') {
  5. // $index = 'text';

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bene
  6. // }
  7. $k = 0;
  8. $this->climate()->inline('.');
  1. $files = glob($pattern, $flags);
  2. foreach (glob(dirname($pattern).'/*', (GLOB_ONLYDIR|GLOB_NOSORT)) as $dir) {
  3. $files = array_merge($files, $this->globRecursive($dir.'/'.basename($pattern), $flags));
  4. $i++;
  5. // if ($i >= $max) {
  6. // break;

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bene
  7. // }
  8. }
  9. return $files;
  10. }

Unused method, property, variable or parameter 2

  • Minor
  • Deadcode

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

  1. * @return array
  2. * @see http://in.php.net/manual/en/function.glob.php#106595
  3. */
  4. public function globRecursive($pattern, $flags = 0)
  5. {
  6. $max = $this->maxRecursiveLevel();

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

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Bene
  7. $i = 1;
  8. $files = glob($pattern, $flags);
  9. foreach (glob(dirname($pattern).'/*', (GLOB_ONLYDIR|GLOB_NOSORT)) as $dir) {
  10. $files = array_merge($files, $this->globRecursive($dir.'/'.basename($pattern), $flags));
  11. $i++;
  1. $enclosure = $this->enclosure();
  2. foreach ($translations as $lang => $trans) {
  3. // Create / open the handle
  4. $filePath = str_replace('/', DIRECTORY_SEPARATOR, $base.$output);
  5. $dirname = dirname($filePath);

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

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Bene
  6. if (!file_exists($filePath)) {
  7. mkdir($filePath, 0755, true);
  8. }
  9. $file = fopen($base.$output.$domain.'.'.$lang.'.csv', 'w');

Text files should end with a newline character

  • Info
  • Codestyle

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

in _config.yml, line 1
  1. theme: jekyll-theme-cayman

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Mathieu Ducharme