Add forbid script (#827)

This commit is contained in:
Casey Rodarmor 2021-05-10 23:58:05 -07:00 committed by GitHub
parent 50cd24d37b
commit d8c00ac2e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 11 deletions

View File

@ -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/')

9
bin/forbid Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euxo pipefail
! rg \
--glob !bin/forbid \
--glob !CHANGELOG.md \
--ignore-case \
'dbg!|fixme|todo|xxx'

View File

@ -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