mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #8030 from drinkcat/clippy-better
clippy pre-commit/CI improvements
This commit is contained in:
commit
94132060b6
4 changed files with 25 additions and 5 deletions
24
.github/workflows/code-quality.yml
vendored
24
.github/workflows/code-quality.yml
vendored
|
@ -78,7 +78,7 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
job:
|
job:
|
||||||
- { os: ubuntu-latest , features: feat_os_unix }
|
- { os: ubuntu-latest , features: all , workspace: true }
|
||||||
- { os: macos-latest , features: feat_os_macos }
|
- { os: macos-latest , features: feat_os_macos }
|
||||||
- { os: windows-latest , features: feat_os_windows }
|
- { os: windows-latest , features: feat_os_windows }
|
||||||
steps:
|
steps:
|
||||||
|
@ -104,6 +104,16 @@ jobs:
|
||||||
*) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;;
|
*) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;;
|
||||||
esac;
|
esac;
|
||||||
outputs FAIL_ON_FAULT FAULT_TYPE
|
outputs FAIL_ON_FAULT FAULT_TYPE
|
||||||
|
- name: Install/setup prerequisites
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
## Install/setup prerequisites
|
||||||
|
case '${{ matrix.job.os }}' in
|
||||||
|
ubuntu-*)
|
||||||
|
# selinux headers needed to enable all features
|
||||||
|
sudo apt-get -y install libselinux1-dev
|
||||||
|
;;
|
||||||
|
esac
|
||||||
- name: "`cargo clippy` lint testing"
|
- name: "`cargo clippy` lint testing"
|
||||||
uses: nick-fields/retry@v3
|
uses: nick-fields/retry@v3
|
||||||
with:
|
with:
|
||||||
|
@ -117,7 +127,17 @@ jobs:
|
||||||
fault_type="${{ steps.vars.outputs.FAULT_TYPE }}"
|
fault_type="${{ steps.vars.outputs.FAULT_TYPE }}"
|
||||||
fault_prefix=$(echo "$fault_type" | tr '[:lower:]' '[:upper:]')
|
fault_prefix=$(echo "$fault_type" | tr '[:lower:]' '[:upper:]')
|
||||||
# * convert any warnings to GHA UI annotations; ref: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
|
# * convert any warnings to GHA UI annotations; ref: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
|
||||||
S=$(cargo clippy --all-targets --features ${{ matrix.job.features }} --tests -pcoreutils -- -D warnings 2>&1) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+(.*):([0-9]+):([0-9]+).*$/::${fault_type} file=\2,line=\3,col=\4::${fault_prefix}: \`cargo clippy\`: \1 (file:'\2', line:\3)/p;" -e '}' ; fault=true ; }
|
if [[ "${{ matrix.job.features }}" == "all" ]]; then
|
||||||
|
extra="--all-features"
|
||||||
|
else
|
||||||
|
extra="--features ${{ matrix.job.features }}"
|
||||||
|
fi
|
||||||
|
case '${{ matrix.job.workspace-tests }}' in
|
||||||
|
1|t|true|y|yes)
|
||||||
|
extra="${extra} --workspace"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
S=$(cargo clippy --all-targets $extra --tests -pcoreutils -- -D warnings 2>&1) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+(.*):([0-9]+):([0-9]+).*$/::${fault_type} file=\2,line=\3,col=\4::${fault_prefix}: \`cargo clippy\`: \1 (file:'\2', line:\3)/p;" -e '}' ; fault=true ; }
|
||||||
if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi
|
if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi
|
||||||
|
|
||||||
style_spellcheck:
|
style_spellcheck:
|
||||||
|
|
|
@ -11,7 +11,7 @@ repos:
|
||||||
- id: rust-clippy
|
- id: rust-clippy
|
||||||
name: Rust clippy
|
name: Rust clippy
|
||||||
description: Run cargo clippy on files included in the commit.
|
description: Run cargo clippy on files included in the commit.
|
||||||
entry: cargo +stable clippy --workspace --all-targets --all-features --
|
entry: cargo +stable clippy --workspace --all-targets --all-features -- -D warnings
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
types: [file, rust]
|
types: [file, rust]
|
||||||
language: system
|
language: system
|
||||||
|
|
|
@ -164,7 +164,7 @@ impl ProcessInformation {
|
||||||
let pid = {
|
let pid = {
|
||||||
value
|
value
|
||||||
.iter()
|
.iter()
|
||||||
.last()
|
.next_back()
|
||||||
.ok_or(io::ErrorKind::Other)?
|
.ok_or(io::ErrorKind::Other)?
|
||||||
.to_str()
|
.to_str()
|
||||||
.ok_or(io::ErrorKind::InvalidData)?
|
.ok_or(io::ErrorKind::InvalidData)?
|
||||||
|
|
|
@ -73,7 +73,7 @@ impl TryFrom<PathBuf> for Teletype {
|
||||||
let f = |prefix: &str| {
|
let f = |prefix: &str| {
|
||||||
value
|
value
|
||||||
.iter()
|
.iter()
|
||||||
.last()?
|
.next_back()?
|
||||||
.to_str()?
|
.to_str()?
|
||||||
.strip_prefix(prefix)?
|
.strip_prefix(prefix)?
|
||||||
.parse::<u64>()
|
.parse::<u64>()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue