/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $fileInput = trim($input->getArgument('file'));
     $pathInfoFile = pathinfo(realpath($fileInput));
     $file = new File('', realpath($fileInput), $pathInfoFile['dirname']);
     $fileCollection = new FileCollection();
     $fileCollection = $fileCollection->append($file);
     $reporter = new Reporter($output, 1);
     $review = new StaticReview($reporter);
     $review->addReview(new PhpCsFixerReview(self::AUTO_ADD_GIT));
     // Review the staged files.
     $review->files($fileCollection);
     // Check if any matching issues were found.
     if ($reporter->hasIssues()) {
         $reporter->displayReport();
     }
     if ($reporter->hasIssueLevel(Issue::LEVEL_ERROR)) {
         $io->error('✘ Please fix the errors above.');
         exit(1);
     } else {
         $io->success('✔ Looking good.');
         exit(0);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $git = new GitVersionControl();
     $stagedFiles = $git->getStagedFiles();
     $projectBase = $git->getProjectBase();
     $reporter = new Reporter($output, count($stagedFiles));
     $review = new StaticReview($reporter);
     $review->addReview(new ComposerLockReview())->addReview(new ComposerLintReview())->addReview(new PhpLintReview())->addReview(new PhpStopWordsReview())->addReview(new JsStopWordsReview())->addReview(new EsLintReview(self::AUTO_ADD_GIT))->addReview(new YmlLintReview())->addReview(new JsonLintReview())->addReview(new XmlLintReview())->addReview(new GitConflictReview());
     // --------------------------------------------------------
     // Front Dev profile
     // --------------------------------------------------------
     /*$review->addReview(new ScssLintReview())
       ->addReview(new SassConvertFixerReview(self::AUTO_ADD_GIT));*/
     // --------------------------------------------------------
     // Dev PHP profile
     // --------------------------------------------------------
     $phpCodeSniffer = new PhpCodeSnifferReview();
     $phpCodeSniffer->setOption('standard', 'Pear');
     $phpCodeSniffer->setOption('sniffs', 'PEAR.Commenting.FunctionComment');
     $review->addReview(new PhpCPDReview())->addReview(new PhpMDReview())->addReview($phpCodeSniffer);
     // --------------------------------------------------------
     $review->files($stagedFiles);
     $reporter->displayReport();
     $testingReporter = new Reporter($output, 0);
     // --------------------------------------------------------
     // Dev PHP profile
     // --------------------------------------------------------
     if (!$reporter->hasIssueLevel(Issue::LEVEL_ERROR) && count($stagedFiles) > 0) {
         $testingReview = new TestingReview($testingReporter);
         if ($input->getOption('phpunit')) {
             $testingReview->addReview(new PhpUnitReview($input->getOption('phpunit-bin-path'), $input->getOption('phpunit-conf'), $projectBase));
         }
         $testingReview->review();
         $testingReporter->displayReport();
     }
     // --------------------------------------------------------
     if ($reporter->hasIssueLevel(Issue::LEVEL_ERROR) || $testingReporter->hasIssueLevel(Issue::LEVEL_ERROR)) {
         $io->error('✘ Please fix the errors above or use --no-verify.');
         exit(1);
     } elseif ($reporter->hasIssueLevel(Issue::LEVEL_WARNING) || $testingReporter->hasIssueLevel(Issue::LEVEL_WARNING)) {
         $io->note('Try to fix warnings !');
     } else {
         $io->success('✔ Looking good.');
     }
     exit(0);
 }
Esempio n. 3
0
/*
 * This file is part of StaticReview
 *
 * Copyright (c) 2014 Samuel Parkinson <@samparkinson_>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @see http://github.com/sjparkinson/static-review/blob/master/LICENSE.md
 */
$included = (include file_exists(__DIR__ . '/../vendor/autoload.php') ? __DIR__ . '/../vendor/autoload.php' : __DIR__ . '/../../../autoload.php');
if (!$included) {
    echo 'You must set up the project dependencies, run the following commands:' . PHP_EOL . 'curl -sS https://getcomposer.org/installer | php' . PHP_EOL . 'php composer.phar install' . PHP_EOL;
    exit(1);
}
// Reference the required classes and the reviews you want to use.
use StaticReview\Reporter\Reporter;
use StaticReview\Review\General\LineEndingsReview;
use StaticReview\StaticReview;
use StaticReview\VersionControl\GitVersionControl;
$reporter = new Reporter();
$review = new StaticReview($reporter);
// Add any reviews to the StaticReview instance, supports a fluent interface.
$review->addReview(new LineEndingsReview());
$git = new GitVersionControl();
// Review the staged files.
$review->review($git->getStagedFiles());
echo PHP_EOL;
// Check if any issues were found.
// Exit with a non-zero to block the commit.
$reporter->hasIssues() ? exit(1) : exit(0);
Esempio n. 4
0
 * @see http://github.com/sjparkinson/static-review/blob/master/LICENSE
 */
$included = (include file_exists(__DIR__ . '/../vendor/autoload.php') ? __DIR__ . '/../vendor/autoload.php' : __DIR__ . '/../../../autoload.php');
if (!$included) {
    echo 'You must set up the project dependencies, run the following commands:' . PHP_EOL . 'curl -sS https://getcomposer.org/installer | php' . PHP_EOL . 'php composer.phar install' . PHP_EOL;
    exit(1);
}
use League\CLImate\CLImate;
use StaticReview\Issue\Issue;
use StaticReview\Reporter\Reporter;
use StaticReview\StaticReview;
use StaticReview\VersionControl\GitVersionControl;
use Symfony\Component\Process\Process;
use StasPiv\Review\Fixer\PhpCsFixer;
$reporter = new Reporter();
$review = new StaticReview($reporter);
// Add any reviews to the StaticReview instance, supports a fluent interface.
$review->addReview(new PhpCsFixer());
$git = new GitVersionControl();
// Review the staged files.
$review->files($git->getStagedFiles());
echo PHP_EOL;
$climate = new CLImate();
$warnings = $errors = $info = 0;
if ($reporter->hasIssues()) {
    foreach ($reporter->getIssues() as $issue) {
        /** @var Issue $issue */
        if ($issue->getLevel() == Issue::LEVEL_INFO) {
            (new Process('git add ' . $issue->getSubject()->getName()))->run();
            ++$info;
        }
Esempio n. 5
0
    exit(1);
}
// Reference the required classes and the reviews you want to use.
use League\CLImate\CLImate;
use StaticReview\Reporter\Reporter;
use StaticReview\Review\Composer\ComposerLintReview;
use StaticReview\Review\General\LineEndingsReview;
use StaticReview\Review\General\NoCommitTagReview;
use StaticReview\Review\PHP\PhpLeadingLineReview;
use StaticReview\Review\PHP\PhpLintReview;
use StaticReview\StaticReview;
use StaticReview\VersionControl\GitVersionControl;
$reporter = new Reporter();
$climate = new CLImate();
$git = new GitVersionControl();
$review = new StaticReview($reporter);
// Add any reviews to the StaticReview instance, supports a fluent interface.
$review->addReview(new LineEndingsReview())->addReview(new PhpLeadingLineReview())->addReview(new NoCommitTagReview())->addReview(new PhpLintReview())->addReview(new ComposerLintReview());
// Review the staged files.
$review->review($git->getStagedFiles());
// Check if any matching issues were found.
if ($reporter->hasIssues()) {
    $climate->out('')->out('');
    foreach ($reporter->getIssues() as $issue) {
        $climate->red($issue);
    }
    $climate->out('')->red('✘ Please fix the errors above.');
    exit(1);
} else {
    $climate->out('')->green('✔ Looking good.')->white('Have you tested everything?');
    exit(0);
    exit(1);
}
require $autoload;
use League\CLImate\CLImate;
use StaticReview\Reporter\Reporter;
use StaticReview\Review\Composer\ComposerLintReview;
use StaticReview\Review\Composer\ComposerSecurityReview;
use StaticReview\Review\General\LineEndingsReview;
use StaticReview\Review\PHP\PhpCodeSnifferReview;
use StaticReview\Review\PHP\PhpLintReview;
use StaticReview\StaticReview;
use StaticReview\VersionControl\GitVersionControl;
$reporter = new Reporter();
$climate = new CLImate();
$git = new GitVersionControl();
$review = new StaticReview($reporter);
// Add any reviews to the StaticReview instance, supports a fluent interface.
$review->addReview(new LineEndingsReview())->addReview(new PhpLintReview())->addReview(new ComposerLintReview())->addReview(new ComposerSecurityReview());
$codeSniffer = new PhpCodeSnifferReview();
$codeSniffer->setOption('standard', 'PSR2');
$review->addReview($codeSniffer);
if ($git->getStagedFiles()->count() === 0) {
    $climate->out('')->yellow('[-] Nothing to do.')->white('No files founded in the git staged.');
    exit(0);
}
// Review the staged files.
$review->files($git->getStagedFiles());
// Check if any matching issues were found.
if ($reporter->hasIssues()) {
    $climate->out('')->out('');
    foreach ($reporter->getIssues() as $issue) {
// Reference the required classes and the reviews you want to use.
use League\CLImate\CLImate;
use StaticReview\Issue\Issue;
use StaticReview\Reporter\Reporter;
use StaticReview\Review\Message\BodyLineLengthReview;
use StaticReview\Review\Message\SubjectImperativeReview;
use StaticReview\Review\Message\SubjectLineCapitalReview;
use StaticReview\Review\Message\SubjectLineLengthReview;
use StaticReview\Review\Message\SubjectLinePeriodReview;
use StaticReview\Review\Message\WorkInProgressReview;
use StaticReview\StaticReview;
use StaticReview\VersionControl\GitVersionControl;
$reporter = new Reporter();
$climate = new CLImate();
$git = new GitVersionControl();
$review = new StaticReview($reporter);
// Add any reviews to the StaticReview instance, supports a fluent interface.
$review->addReview(new BodyLineLengthReview())->addReview(new SubjectImperativeReview())->addReview(new SubjectLineCapitalReview())->addReview(new SubjectLineLengthReview())->addReview(new SubjectLinePeriodReview())->addReview(new WorkInProgressReview());
// Check the commit message.
$review->message($git->getCommitMessage($argv[1]));
// Check if any matching issues were found.
if ($reporter->hasIssues()) {
    $climate->out('')->out('');
    foreach ($reporter->getIssues() as $issue) {
        $climate->red($issue);
    }
    $climate->out('')->red('✘ Please fix the errors above using: git commit --amend');
    exit(0);
} else {
    $climate->green('✔ That commit looks good!');
    exit(0);
use StaticReview\Reporter\Reporter;
use StaticReview\Review\Composer\ComposerLintReview;
use StaticReview\Review\Composer\ComposerSecurityReview;
use StaticReview\Review\General\LineEndingsReview;
use StaticReview\Review\PHP\PhpLintReview;
use StaticReview\StaticReview;
use StaticReview\VersionControl\GitVersionControl;
//PADOSOFT REVIEW
use Padosoft\StaticReview\PHP\VarDumpReview;
use Padosoft\StaticReview\PHP\DdReview;
use Padosoft\StaticReview\PHP\PhpLeadingLineReviewNoBlade;
use Padosoft\StaticReview\PHP\PhpCodeSnifferReviewNoBlade;
$reporter = new Reporter();
$climate = new CLImate();
$git = new GitVersionControl();
$review = new StaticReview($reporter);
// Add any reviews to the StaticReview instance, supports a fluent interface.
$review->addReview(new LineEndingsReview())->addReview(new PhpLintReview())->addReview(new ComposerLintReview())->addReview(new ComposerSecurityReview())->addReview(new VarDumpReview())->addReview(new DdReview())->addReview(new PhpLeadingLineReviewNoBlade());
$codeSniffer = new PhpCodeSnifferReviewNoBlade();
$codeSniffer->setOption('standard', 'PSR2');
$review->addReview($codeSniffer);
// Review the staged files.
$review->files($git->getStagedFiles());
// Check if any matching issues were found.
if ($reporter->hasIssues()) {
    $climate->out('')->out('');
    foreach ($reporter->getIssues() as $issue) {
        $climate->red($issue);
    }
    $climate->out('')->red('✘ Please fix the errors above.');
    exit(1);
Esempio n. 9
0
    exit(1);
}
// Reference the required classes and the reviews you want to use.
use League\CLImate\CLImate;
use StaticReview\Reporter\Reporter;
use StaticReview\Review\Composer\ComposerLintReview;
use StaticReview\Review\General\LineEndingsReview;
use StaticReview\Review\PHP\PhpCodeSnifferReview;
use StaticReview\Review\PHP\PhpLeadingLineReview;
use StaticReview\Review\PHP\PhpLintReview;
use StaticReview\StaticReview;
use StaticReview\VersionControl\GitVersionControl;
$reporter = new Reporter();
$climate = new CLImate();
$git = new GitVersionControl();
$review = new StaticReview($reporter);
$review->addReview(new LineEndingsReview())->addReview(new PhpLeadingLineReview())->addReview(new PhpLintReview())->addReview(new ComposerLintReview());
//->addReview(new ComposerSecurityReview()); - Can lead to false positives, so currently disabled...
$codeSniffer = new PhpCodeSnifferReview();
$codeSniffer->setOption('standard', 'PSR2');
$review->addReview($codeSniffer);
$review->review($git->getStagedFiles());
if ($reporter->hasIssues()) {
    $climate->out('')->out('');
    foreach ($reporter->getIssues() as $issue) {
        $climate->red($issue);
    }
    $climate->out('')->red('✘ Please fix the errors above.');
    exit(1);
} else {
    $climate->out('')->green('✔ Looking good.')->white('Have you tested everything?');