Skip to content

Commit 6a5a06b

Browse files
authored
Modernize Rust codebase: Fix chrono deprecations and enhance development tools (#415)
- Fix chrono deprecation warnings by updating to modern APIs - Add comprehensive clippy configuration for stricter linting - Enhance Makefile with development targets (check, clippy, fmt, test, clean, help) - The Cargo.toml already had Rust 2024 edition and modern clippy lints configured
1 parent d6315a6 commit 6a5a06b

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

Makefile

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
1-
.PHONY: render
1+
# Dynamic Analysis Tools Repository Makefile
2+
3+
.PHONY: render render-skip-deprecated check clippy fmt test clean help
4+
5+
# Default target shows help
6+
help:
7+
@echo "Available targets:"
8+
@echo " render - Render README.md and JSON API from YAML sources"
9+
@echo " render-skip-deprecated - Render without deprecated tools"
10+
@echo " check - Run cargo check"
11+
@echo " clippy - Run clippy lints"
12+
@echo " fmt - Format Rust code"
13+
@echo " test - Run tests"
14+
@echo " clean - Clean build artifacts"
15+
@echo " help - Show this help"
16+
17+
# Main rendering targets
218
render:
319
cargo run --manifest-path data/render/Cargo.toml -- --tags data/tags.yml --tools data/tools --md-out README.md --json-out data/api
420

5-
.PHONY: render-skip-deprecated
621
render-skip-deprecated:
7-
cargo run --manifest-path data/render/Cargo.toml -- --tags data/tags.yml --tools data/tools --md-out README.md --json-out data/api --skip-deprecated
22+
cargo run --manifest-path data/render/Cargo.toml -- --tags data/tags.yml --tools data/tools --md-out README.md --json-out data/api --skip-deprecated
23+
24+
# Development targets
25+
check:
26+
cargo check --manifest-path data/render/Cargo.toml
27+
28+
clippy:
29+
cargo clippy --manifest-path data/render/Cargo.toml -- -D warnings
30+
31+
fmt:
32+
cargo fmt --manifest-path data/render/Cargo.toml
33+
34+
test:
35+
cargo test --manifest-path data/render/Cargo.toml
36+
37+
clean:
38+
cargo clean --manifest-path data/render/Cargo.toml

data/render/clippy.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Clippy configuration for stricter linting
2+
# https://rust-lang.github.io/rust-clippy/master/index.html
3+
4+
# Set the threshold for too many arguments
5+
too-many-arguments-threshold = 4
6+
7+
# Set the threshold for too many lines
8+
too-many-lines-threshold = 100
9+
10+
# Set the threshold for type complexity
11+
type-complexity-threshold = 250
12+
13+
# Avoid suggesting wildcard imports
14+
avoid-breaking-exported-api = false

data/render/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ pub async fn check_deprecated(token: String, entries: &mut Vec<Entry>) -> Result
5151
if let Ok(commit_list) = github.repo(owner, repo).commits().list("").await {
5252
let date = &commit_list[0].commit.author.date;
5353
let last_commit = NaiveDateTime::parse_from_str(date, "%Y-%m-%dT%H:%M:%SZ")?;
54-
let last_commit_utc = DateTime::<Utc>::from_utc(last_commit, Utc);
55-
let duration = Local::today().signed_duration_since(last_commit_utc.date());
54+
let last_commit_utc: DateTime<Utc> = DateTime::from_naive_utc_and_offset(last_commit, Utc);
55+
let duration = Local::now().date_naive().signed_duration_since(last_commit_utc.date_naive());
5656

5757
if duration.num_days() > 365 {
5858
entry.deprecated = Some(true);

0 commit comments

Comments
 (0)