-
Notifications
You must be signed in to change notification settings - Fork 0
/
callinectes.sh
executable file
·94 lines (84 loc) · 1.95 KB
/
callinectes.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#! /usr/bin/env bash
# Copyright 2024 Dotanuki Labs
# SPDX-License-Identifier: MIT
set -e
usage() {
echo
echo "Available checks:"
echo
echo "fmt # Checks formatting on Rust source files"
echo "clippy # Runs Clippy lints against Rust source files"
echo "deny # Checks vulnerabilities and compliance of project dependencies"
echo "machete # Checks unused dependencies declared in Cargo.toml files"
echo "msrv # Checks the Minimal Supported Rust Version for the project"
echo "cyclonedx # Generates a CycloneDx SBOM file from project dependencies"
echo
}
check_sources_formatting() {
echo
echo "🦀 Checking code formatting (rustfmt)"
echo
cargo fmt --check
}
lint_source_files() {
echo
echo "🦀 Checking code smells (clippy)"
echo
cargo clippy --all-targets --all-features -- -D warnings
}
check_vulnerable_dependencies() {
echo
echo "🦀 Checking supply chain issues (cargo-deny)"
echo
cargo deny check
}
check_unused_dependencies() {
echo
echo "🦀 Checking declared and unused dependencies (cargo-machete)"
echo
cargo machete
}
check_msrv() {
echo
echo "🦀 Checking Minimal Supported Rust Version (cargo-msrv)"
echo
cargo msrv verify
}
generate_cyclonedx_sbom() {
echo
echo "🦀 Generating CycloneDX SBOM (cargo-cyclonedx)"
echo
cargo cyclonedx --format json
}
if test "$#" -eq 0; then
usage
exit 0
fi
while test "$#" -gt 0; do
case "$1" in
"fmt")
check_sources_formatting
;;
"clippy")
lint_source_files
;;
"deny")
check_vulnerable_dependencies
;;
"machete")
check_unused_dependencies
;;
"msrv")
check_msrv
;;
"cyclonedx")
generate_cyclonedx_sbom
;;
*)
echo "Error: unsupported checks → $1"
usage
exit 1
;;
esac
shift
done