<commit_before>#!/usr/bin/env bash

gem install --no-document rubocop rubocop-checkstyle_formatter \
    rails_best_practices \
    brakeman brakeman_translate_checkstyle_format \
    reek \
    checkstyle_filter-git saddler saddler-reporter-github \
    scss_lint scss_lint_reporter_checkstyle

npm install -g eslint

if [ -z "${CI_PULL_REQUEST}" ]; then
    # when not pull request
    REPORTER=Saddler::Reporter::Github::CommitReviewComment
else
    REPORTER=Saddler::Reporter::Github::PullRequestReviewComment
fi

echo "********************"
echo "* RuboCop          *"
echo "********************"
rubocop --require `gem which rubocop/formatter/checkstyle_formatter` --format RuboCop::Formatter::CheckstyleFormatter --out rubocop.xml
cat rubocop.xml \
  | checkstyle_filter-git diff origin/master \
  | saddler report \
    --require saddler/reporter/github \
    --reporter $REPORTER

echo "***********************"
echo "* Rails Best Pratices *"
echo "***********************"
rails_best_practices -f xml

cat rails_best_practices_output.xml \
  | checkstyle_filter-git diff origin/master \
  | saddler report \
    --require saddler/reporter/github \
    --reporter $REPORTER

echo "********************"
echo "* Brakeman         *"
echo "********************"
brakeman -o brakeman.json
cat brakeman.json \
  | brakeman_translate_checkstyle_format translate \
  | checkstyle_filter-git diff origin/master \
  | saddler report \
    --require saddler/reporter/github \
    --reporter $REPORTER


echo "********************"
echo "* Reek             *"
echo "********************"
reek app --format xml > reek.xml
cat reek.xml \
  | checkstyle_filter-git diff origin/master \
  | saddler report \
    --require saddler/reporter/github \
    --reporter $REPORTER

echo "********************"
echo "* save outputs     *"
echo "********************"
LINT_RESULT_DIR="$CIRCLE_ARTIFACTS/lint"

mkdir "$LINT_RESULT_DIR"
cp -v "rubocop.xml" "$LINT_RESULT_DIR/"
cp -v "rails_best_practices_output.xml" "$LINT_RESULT_DIR/"
cp -v "brakeman.json" "$LINT_RESULT_DIR/"
cp -v "reek.xml" "$LINT_RESULT_DIR/"<commit_msg>[Update] Lint: remove brakeman<commit_after>#!/usr/bin/env bash

gem install --no-document rubocop rubocop-checkstyle_formatter \
    rails_best_practices \
    reek \
    checkstyle_filter-git saddler saddler-reporter-github \

if [ -z "${CI_PULL_REQUEST}" ]; then
    # when not pull request
    REPORTER=Saddler::Reporter::Github::CommitReviewComment
else
    REPORTER=Saddler::Reporter::Github::PullRequestReviewComment
fi

echo "********************"
echo "* RuboCop          *"
echo "********************"
rubocop --require `gem which rubocop/formatter/checkstyle_formatter` --format RuboCop::Formatter::CheckstyleFormatter --out rubocop.xml
cat rubocop.xml \
  | checkstyle_filter-git diff origin/master \
  | saddler report \
    --require saddler/reporter/github \
    --reporter $REPORTER

echo "***********************"
echo "* Rails Best Pratices *"
echo "***********************"
rails_best_practices -f xml

cat rails_best_practices_output.xml \
  | checkstyle_filter-git diff origin/master \
  | saddler report \
    --require saddler/reporter/github \
    --reporter $REPORTER

echo "********************"
echo "* Reek             *"
echo "********************"
reek app --format xml > reek.xml
cat reek.xml \
  | checkstyle_filter-git diff origin/master \
  | saddler report \
    --require saddler/reporter/github \
    --reporter $REPORTER

echo "********************"
echo "* save outputs     *"
echo "********************"
LINT_RESULT_DIR="$CIRCLE_ARTIFACTS/lint"

mkdir "$LINT_RESULT_DIR"
cp -v "rubocop.xml" "$LINT_RESULT_DIR/"
cp -v "rails_best_practices_output.xml" "$LINT_RESULT_DIR/"
cp -v "reek.xml" "$LINT_RESULT_DIR/"
{'fraction_non_alphanumeric': 0.20314164004259852, 'fraction_numerical': 0.0, 'mean_word_length': 4.0701754385964914, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 20}, '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': '5897161', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1218, 'n_words': 250}