Skip to content

Commit 6283d48

Browse files
committed
🚨 Fine-tune lint settings for clarity
Revamp the Clippy lint configuration to better communicate coding standards and accommodate practical exceptions: - Shift `missing_docs` in Rust lints to early mentions by allowing missing documentation entries - Refine organization of Clippy lint levels, highlighting warnings, denials, and specific allowances - Introduce detailed prioritization levels within lint categories, emphasizing critical safety checks - Permit pragmatic code style preferences while elevating performance and safety-critical denials Each adjustment aims to balance code quality, practical considerations, and ease of future configuration adaptations.
1 parent 4e89381 commit 6283d48

File tree

3 files changed

+42
-19
lines changed

3 files changed

+42
-19
lines changed

Cargo.toml

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,41 @@ integration = []
100100

101101
[lints.rust]
102102
unsafe_code = "forbid"
103+
missing_docs = { level = "allow", priority = 1 }
103104

104105
[lints.clippy]
106+
# Base lint groups
105107
all = { level = "deny", priority = 0 }
106-
pedantic = { level = "deny", priority = 1 }
107-
enum_glob_use = { level = "deny", priority = 2 }
108-
module_name_repetitions = { level = "allow", priority = 3 }
109-
cast_precision_loss = { level = "allow", priority = 4 }
110-
cast_possible_truncation = { level = "allow", priority = 5 }
111-
cast_sign_loss = { level = "allow", priority = 6 }
112-
out_of_bounds_indexing = { level = "allow", priority = 7 }
113-
perf = { level = "warn", priority = 8 }
114-
style = { level = "warn", priority = 9 }
115-
missing_errors_doc = { level = "allow", priority = 10 }
116-
must_use_candidate = { level = "allow", priority = 11 }
117-
missing_panics_doc = { level = "allow", priority = 12 }
118-
missing_docs = { level = "allow", priority = 13 }
119-
significant_drop_tightening = { level = "allow", priority = 14 }
120-
# maybe this should be enabled in the future
121-
unwrap_used = { level = "deny", priority = 10 }
122-
#expect_used = { level = "deny", priority = 11 }
108+
style = { level = "warn", priority = 1 }
109+
perf = { level = "deny", priority = 1 }
110+
111+
# Pedantic lints
112+
pedantic = { level = "deny", priority = 10 }
113+
114+
# Documentation allowances
115+
missing_errors_doc = { level = "allow", priority = 20 }
116+
missing_panics_doc = { level = "allow", priority = 20 }
117+
missing_safety_doc = { level = "allow", priority = 20 }
118+
119+
# Code style allowances - These remain allowed for pragmatic reasons
120+
module_name_repetitions = { level = "allow", priority = 21 }
121+
significant_drop_tightening = { level = "allow", priority = 21 }
122+
must_use_candidate = { level = "allow", priority = 21 }
123+
124+
# Numeric casting and conversion warnings
125+
cast_precision_loss = { level = "warn", priority = 22 }
126+
cast_possible_truncation = { level = "warn", priority = 22 }
127+
cast_sign_loss = { level = "warn", priority = 22 }
128+
as_conversions = { level = "warn", priority = 22 }
129+
130+
# Safety-critical denials
131+
out_of_bounds_indexing = { level = "deny", priority = 30 }
132+
enum_glob_use = { level = "deny", priority = 30 }
133+
unwrap_used = { level = "deny", priority = 30 }
134+
undocumented_unsafe_blocks = { level = "deny", priority = 30 }
135+
136+
# Future considerations
137+
#expect_used = { level = "deny", priority = 30 }
138+
#todo = { level = "warn", priority = 20 } # Consider warning on TODOs
139+
#dbg_macro = { level = "warn", priority = 30 } # Consider warning on dbg! macro usage
140+
#print_stdout = { level = "warn", priority = 30 } # Consider warning on print!/println! usage

src/changes/change_analyzer.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,20 +200,24 @@ impl ChangeAnalyzer {
200200

201201
/// Extract associated issue numbers from the commit message
202202
fn extract_associated_issues(commit_message: &str) -> Vec<String> {
203-
let re = Regex::new(r"(?:#|GH-)(\d+)").unwrap();
203+
let re = Regex::new(r"(?:#|GH-)(\d+)")
204+
.expect("Failed to compile issue number regex pattern - this is a bug");
204205
re.captures_iter(commit_message)
205206
.map(|cap| format!("#{}", &cap[1]))
206207
.collect()
207208
}
208209

209210
/// Extract pull request number from the commit message
210211
fn extract_pull_request(commit_message: &str) -> Option<String> {
211-
let re = Regex::new(r"(?i)(?:pull request|PR)\s*#?(\d+)").unwrap();
212+
let re = Regex::new(r"(?i)(?:pull request|PR)\s*#?(\d+)")
213+
.expect("Failed to compile pull request regex pattern - this is a bug");
212214
re.captures(commit_message)
213215
.map(|cap| format!("PR #{}", &cap[1]))
214216
}
215217

216218
/// Calculate the impact score of the change
219+
#[allow(clippy::cast_precision_loss)]
220+
#[allow(clippy::as_conversions)]
217221
fn calculate_impact_score(
218222
metrics: &ChangeMetrics,
219223
file_changes: &[FileChange],

src/tui/ui.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ pub fn draw_status(f: &mut Frame, state: &mut TuiState, area: Rect) {
269269
)
270270
};
271271

272+
#[allow(clippy::as_conversions)]
272273
let terminal_width = f.area().width as usize;
273274

274275
// Ensure we don't overflow when calculating padding

0 commit comments

Comments
 (0)