<commit_before><?php

/*
 * This file is part of StaticReview
 *
 * Copyright (c) 2014 <NAME> <@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
 */

namespace StaticReview\Review\General;

use StaticReview\File\FileInterface;
use StaticReview\Reporter\ReporterInterface;
use StaticReview\Review\AbstractFileReview;
use StaticReview\Review\ReviewableInterface;

class LineEndingsReview extends AbstractFileReview
{
    /**
     * Review any text based file.
     *
     * @link http://stackoverflow.com/a/632786
     *
     * @param  FileInterface $file
     * @return bool
     */
    public function canReviewFile(FileInterface $file)
    {
        $mime = $file->getMimeType();

        // check to see if the mime-type starts with 'text'
        return (substr($mime, 0, 4) === 'text');
    }

    /**
     * Checks if the set file contains any CRLF line endings.
     *
     * @link http://stackoverflow.com/a/3570574
     */
    public function review(ReporterInterface $reporter, ReviewableInterface $file)
    {
        $cmd = sprintf('file %s | grep --fixed-strings --quiet "CRLF"', $file->getFullPath());

        $process = $this->getProcess($cmd);
        $process->run();

        if ($process->isSuccessful()) {
            $message = 'File contains CRLF line endings';
            $reporter->error($message, $this, $file);

        }
    }
}<commit_msg>- Blank line found at end of control structure<commit_after><?php

/*
 * This file is part of StaticReview
 *
 * Copyright (c) 2014 <NAME> <@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
 */

namespace StaticReview\Review\General;

use StaticReview\File\FileInterface;
use StaticReview\Reporter\ReporterInterface;
use StaticReview\Review\AbstractFileReview;
use StaticReview\Review\ReviewableInterface;

class LineEndingsReview extends AbstractFileReview
{
    /**
     * Review any text based file.
     *
     * @link http://stackoverflow.com/a/632786
     *
     * @param  FileInterface $file
     * @return bool
     */
    public function canReviewFile(FileInterface $file)
    {
        $mime = $file->getMimeType();

        // check to see if the mime-type starts with 'text'
        return (substr($mime, 0, 4) === 'text');
    }

    /**
     * Checks if the set file contains any CRLF line endings.
     *
     * @link http://stackoverflow.com/a/3570574
     */
    public function review(ReporterInterface $reporter, ReviewableInterface $file)
    {
        $cmd = sprintf('file %s | grep --fixed-strings --quiet "CRLF"', $file->getFullPath());

        $process = $this->getProcess($cmd);
        $process->run();

        if ($process->isSuccessful()) {
            $message = 'File contains CRLF line endings';
            $reporter->error($message, $this, $file);
        }
    }
}
{'fraction_non_alphanumeric': 0.12379421221864952, 'fraction_numerical': 0.012218649517684888, 'mean_word_length': 2.8265682656826567, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4810831', 'n_tokens_mistral': 965, 'n_tokens_neox': 898, 'n_words': 246}