New clippy script (#2400)

* claude.ai

* aaa

* ps1

* set -e

* nightly

* nightly default

* components?
This commit is contained in:
Dongjia "toka" Zhang 2024-07-15 19:17:21 +02:00 committed by GitHub
parent 50a4a0abd9
commit 8919024e83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 150 additions and 33 deletions

View File

@ -6,7 +6,9 @@ runs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
toolchain: nightly
components: llvm-tools, clippy, rustfmt
default: true
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Build docs

View File

@ -23,6 +23,7 @@ default-members = [
"libafl_derive",
"libafl_targets",
]
exclude = [
"bindings",
"fuzzers",
@ -32,6 +33,7 @@ exclude = [
"utils/desyscall",
"utils/multi_machine_generator",
"scripts",
# additional crates
"libafl_concolic/symcc_runtime",
"libafl_concolic/symcc_libafl",
"libafl_frida",

View File

@ -1,4 +1,20 @@
cargo clippy --all --all-features --exclude libafl_qemu --no-deps --tests --benches --examples -- `
# Clippy Runner Script for PowerShell (Windows)
$ErrorActionPreference = "Stop" # This is similar to set -e in Bash
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location (Split-Path -Parent $ScriptDir)
# Function to run Clippy on a single directory
function Run-Clippy {
param (
[string]$dir
)
Write-Host "Running Clippy on $dir"
Push-Location $dir
try {
$env:RUST_BACKTRACE = "full"
cargo +nightly clippy --all --all-features --no-deps --tests --examples --benches -- -Z macro-backtrace `
-D clippy::all `
-D clippy::pedantic `
-W clippy::similar_names `
@ -12,3 +28,56 @@ cargo clippy --all --all-features --exclude libafl_qemu --no-deps --tests --benc
-A clippy::unseparated-literal-suffix `
-A clippy::module-name-repetitions `
-A clippy::unreadable-literal
}
finally {
Pop-Location
}
}
# Define projects for Windows
$AllProjects = @(
"libafl_frida",
"libafl_libfuzzer",
"libafl_nyx",
"libafl_tinyinst"
)
# Check if arguments were provided
if ($args.Count -eq 0) {
# No arguments provided, run on all projects
$Projects = $AllProjects
}
else {
# Arguments provided, split the input string into an array
$Projects = $args[0] -split ','
}
# First run it on all
$env:RUST_BACKTRACE = "full"
cargo +nightly clippy --all --all-features --no-deps --tests --examples --benches -- -Z macro-backtrace `
-D clippy::all `
-D clippy::pedantic `
-W clippy::similar_names `
-A clippy::type_repetition_in_bounds `
-A clippy::missing-errors-doc `
-A clippy::cast-possible-truncation `
-A clippy::used-underscore-binding `
-A clippy::ptr-as-ptr `
-A clippy::missing-panics-doc `
-A clippy::missing-docs-in-private-items `
-A clippy::unseparated-literal-suffix `
-A clippy::module-name-repetitions `
-A clippy::unreadable-literal
# Loop through each project and run Clippy
foreach ($project in $Projects) {
$project = $project.Trim()
if (Test-Path $project -PathType Container) {
Run-Clippy $project
}
else {
Write-Host "Warning: Directory $project does not exist. Skipping."
}
}
Write-Host "Clippy run completed for all specified projects."

View File

@ -1,8 +1,14 @@
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
cd "$SCRIPT_DIR/.." || exit 1
set -e
# Function to run Clippy on a single directory
run_clippy() {
local dir="$1"
echo "Running Clippy on $dir"
pushd "$dir" || return 1
RUST_BACKTRACE=full cargo +nightly clippy --all --all-features --no-deps --tests --examples --benches -- -Z macro-backtrace \
-D clippy::all \
@ -19,8 +25,33 @@ RUST_BACKTRACE=full cargo +nightly clippy --all --all-features --no-deps --tests
-A clippy::module-name-repetitions \
-A clippy::unreadable-literal
popd || return 1
}
# Define projects based on the operating system
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
cd libafl_libfuzzer_runtime
ALL_PROJECTS=(
"libafl_concolic/symcc_runtime"
"libafl_concolic/symcc_libafl"
"libafl_frida"
"libafl_libfuzzer"
"libafl_nyx"
"libafl_qemu"
"libafl_tinyinst"
"libafl_qemu/libafl_qemu_build"
"libafl_qemu/libafl_qemu_sys"
)
fi
if [ "$#" -eq 0 ]; then
# No arguments provided, run on all projects
PROJECTS=("${ALL_PROJECTS[@]}")
else
# Arguments provided, split the input string into an array
IFS=',' read -ra PROJECTS <<<"$1"
fi
# First run it on all
RUST_BACKTRACE=full cargo +nightly clippy --all --all-features --no-deps --tests --examples --benches -- -Z macro-backtrace \
-D clippy::all \
-D clippy::pedantic \
@ -35,4 +66,17 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
-A clippy::unseparated-literal-suffix \
-A clippy::module-name-repetitions \
-A clippy::unreadable-literal
# Loop through each project and run Clippy
for project in "${PROJECTS[@]}"; do
# Trim leading and trailing whitespace
project=$(echo "$project" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
if [ -d "$project" ]; then
run_clippy "$project"
else
echo "Warning: Directory $project does not exist. Skipping."
fi
done
echo "Clippy run completed for all specified projects."