From d8c00ac2e49d858aeb7a2af25a477130bf123131 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Mon, 10 May 2021 23:58:05 -0700 Subject: [PATCH] Add forbid script (#827) --- .github/workflows/build.yaml | 11 +++++++---- bin/forbid | 9 +++++++++ justfile | 11 ++++------- 3 files changed, 20 insertions(+), 11 deletions(-) create mode 100755 bin/forbid diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 777ed64..e4f10b1 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -77,10 +77,6 @@ jobs: - name: Clippy run: cargo clippy --all --all-targets --all-features - - name: Lint - if: matrix.os != 'windows-2016' - run: cargo run lint - - name: Install Rustfmt Toolchain uses: actions-rs/toolchain@v1 with: @@ -98,6 +94,13 @@ jobs: ./bin/generate-completions git diff --no-ext-diff --quiet --exit-code + - name: Check for Forbidden Words + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install ripgrep + ./bin/forbid + - name: Package id: package if: startsWith(github.ref, 'refs/tags/') diff --git a/bin/forbid b/bin/forbid new file mode 100755 index 0000000..e9f16e5 --- /dev/null +++ b/bin/forbid @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +! rg \ + --glob !bin/forbid \ + --glob !CHANGELOG.md \ + --ignore-case \ + 'dbg!|fixme|todo|xxx' diff --git a/justfile b/justfile index c21dbe1..8b9e69a 100755 --- a/justfile +++ b/justfile @@ -61,7 +61,7 @@ version := `sed -En 's/version[[:space:]]*=[[:space:]]*"([^"]+)"/v\1/p' Cargo.to changes: git log --pretty=format:%s >> CHANGELOG.md -check: lint clippy test +check: clippy test forbid git diff --no-ext-diff --quiet --exit-code grep {{version}} CHANGELOG.md cargo +nightly generate-lockfile -Z minimal-versions @@ -114,16 +114,13 @@ install-dev-deps-homebrew: clippy: cargo clippy --all --all-targets --all-features +forbid: + ./bin/forbid + # count non-empty lines of code sloc: @cat src/*.rs | sed '/^\s*$/d' | wc -l -@lint: - echo Checking for FIXME/TODO... - ! grep --color -Ein 'fixme|todo|xxx|#\[ignore\]' src/*.rs - echo Checking for long lines... - ! grep --color -En '.{101}' src/*.rs - replace FROM TO: sd '{{FROM}}' '{{TO}}' src/*.rs