PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/dev/build/publication/sanity/sanity.php

https://bitbucket.org/sunil_nextbits/magento2
PHP | 75 lines | 43 code | 7 blank | 25 comment | 4 complexity | ec87c002a40689236773ceb014d3bbb3 MD5 | raw file
  1. #!/usr/bin/php
  2. <?php
  3. /**
  4. * Magento
  5. *
  6. * NOTICE OF LICENSE
  7. *
  8. * This source file is subject to the Open Software License (OSL 3.0)
  9. * that is bundled with this package in the file LICENSE.txt.
  10. * It is also available through the world-wide-web at this URL:
  11. * http://opensource.org/licenses/osl-3.0.php
  12. * If you did not receive a copy of the license and are unable to
  13. * obtain it through the world-wide-web, please send an email
  14. * to license@magentocommerce.com so we can send you a copy immediately.
  15. *
  16. * DISCLAIMER
  17. *
  18. * Do not edit or add to this file if you wish to upgrade Magento to newer
  19. * versions in the future. If you wish to customize Magento for your
  20. * needs please refer to http://www.magentocommerce.com for more information.
  21. *
  22. * @category build
  23. * @package sanity
  24. * @copyright Copyright (c) 2012 X.commerce, Inc. (http://www.magentocommerce.com)
  25. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  26. */
  27. require __DIR__ . '/../../../../app/autoload.php';
  28. Magento_Autoload_IncludePath::addIncludePath(array(
  29. __DIR__,
  30. realpath(__DIR__ . '/../../../tests/static/framework')
  31. ));
  32. define('USAGE', <<<USAGE
  33. php -f sanity.php -c <config_file> [-w <dir>] [-v]
  34. -c <config_file> path to configuration file with rules and white list
  35. [-w <dir>] use specified working dir instead of current
  36. [-v] verbose mode
  37. USAGE
  38. );
  39. $shortOpts = 'c:w:v';
  40. $options = getopt($shortOpts);
  41. if (!isset($options['c'])) {
  42. print USAGE;
  43. exit(1);
  44. }
  45. $configFile = $options['c'];
  46. $workingDir = __DIR__;
  47. if (isset($options['w'])) {
  48. $workingDir = $options['w'];
  49. }
  50. $wordsFinder = new SanityWordsFinder($configFile, $workingDir);
  51. $verbose = isset($options['v']) ? true : false;
  52. if ($verbose) {
  53. $words = $wordsFinder->getSearchedWords();
  54. printf('Searching for banned words: "%s"...', implode('", "', $words));
  55. }
  56. $found = $wordsFinder->findWordsRecursively();
  57. if ($found) {
  58. echo "Found banned words in the following files:\n";
  59. foreach ($found as $info) {
  60. echo $info['file'] . ' - "' . implode('", "', $info['words']) . "\"\n";
  61. }
  62. exit(1);
  63. }
  64. if ($verbose) {
  65. echo "No banned words found in the source code.\n";
  66. }
  67. exit(0);