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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# Clippy Configuration for ZeroPool
# High-performance, thread-safe buffer pool library
# Edition: 2024 | Strictness: Balanced | Focus: Performance + Safety
# =============================================================================
# Cognitive Complexity Thresholds
# =============================================================================
# Allow slightly higher complexity for performance-critical hot paths
= 25
# Default type complexity is fine for generic pool implementations
= 500
# =============================================================================
# Naming Conventions
# =============================================================================
# Enforce consistent naming (but allow common abbreviations)
= false
# Allow single-char variable names in tight loops (i, j, k for performance)
= 4
# =============================================================================
# Documentation Requirements
# =============================================================================
# Enforce documentation for all public items
= true
# Maximum line length for doc comments
= ["ZeroPool", "LIFO", "CLOCK", "TLS", "mlock", "TiB"]
# =============================================================================
# Performance Tuning
# =============================================================================
# Be aggressive about performance lints (this is a perf-critical library)
= 7
# Allow moderate vector size for initialization
= 4096
# Stack size threshold for arrays (correct name: too-large-for-stack)
= 16384
# =============================================================================
# Safety & Correctness
# =============================================================================
# Strict enum variant name checking
= 3
# =============================================================================
# Code Organization
# =============================================================================
# Allow up to 150 lines for complex initialization functions
= 150
# Struct field count (pools have many config fields) - correct name: max-struct-bools
= 4
# =============================================================================
# Import & Module Settings
# =============================================================================
# Enforce consistent import ordering
= 3
# =============================================================================
# Literal & Magic Number Configuration
# =============================================================================
# Allow some magic numbers in performance-critical code (shard counts, etc.)
# These should still be well-documented
= 16
# =============================================================================
# Error Handling
# =============================================================================
# Be strict about error handling in public APIs (correct name: large-error-threshold)
# Internal panics are acceptable for invariant violations
= 128
# =============================================================================
# Dependencies
# =============================================================================
# Allow multiple versions of certain crates due to transitive dependencies
# bitflags: Used by both parking_lot (1.x) and newer dependencies (2.x)
# This will resolve itself when dependencies converge
= ["bitflags"]
# =============================================================================
# ALLOWED LINTS (Pragmatic Exceptions)
# =============================================================================
# These lints are explicitly allowed for valid reasons in performance code
# Performance & Optimization
# - inline_always: Used deliberately for hot-path functions
# - cast_possible_truncation: Intentional in shard indexing with masking
# - cast_precision_loss: Acceptable for statistics/metrics
# - module_name_repetition: Common in Rust libraries (pool::Pool)
# Complexity (for hot paths)
# - too_many_lines: Some functions are long but linear (initialization)
# - similar_names: shard/shard_idx, buf/buffer are clear in context
# Style (team preference)
# - must_use_candidate: Too noisy, prefer explicit annotations
# - return_self_not_must_use: Builder pattern returns Self intentionally
# - missing_errors_doc: Will be handled separately for public API
# Safety
# - multiple_unsafe_ops_per_block: Sometimes needed for atomicity
# - undocumented_safety: DENY this, but keep config flexible
# =============================================================================
# LINT LEVELS (Configured in Cargo.toml)
# =============================================================================
# This file contains Clippy-specific configuration options.
# Lint levels (warn/deny/allow) should be set in Cargo.toml [lints.clippy]
# or via #![warn(...)] / #![deny(...)] attributes in source files.
#
# Recommended configuration for Cargo.toml:
#
# [lints.rust]
# unsafe_code = "warn" # Allow but scrutinize
# missing_docs = "warn" # Enforce for public API
#
# [lints.clippy]
# # DENY: Critical correctness and safety issues
# correctness = "deny"
# suspicious = "deny"
# perf = "deny"
# undocumented_unsafe_blocks = "deny"
#
# # WARN: Code quality and style
# all = "warn"
# pedantic = "warn"
# complexity = "warn"
# style = "warn"
# cargo = "warn"
#
# # ALLOW: Pragmatic exceptions for performance
# inline_always = "allow"
# module_name_repetition = "allow"
# cast_possible_truncation = "allow"
# cast_precision_loss = "allow"
# too_many_lines = "allow"
# missing_errors_doc = "allow"
# must_use_candidate = "allow"
# return_self_not_must_use = "allow"
# similar_names = "allow"
# multiple_unsafe_ops_per_block = "allow"
#
# =============================================================================
# NOTES FOR DEVELOPERS
# =============================================================================
#
# 1. Unsafe Code Policy:
# - All unsafe blocks MUST have SAFETY comments
# - Prefer safe abstractions when performance cost < 5%
# - Benchmark before and after unsafe optimizations
#
# 2. Performance Guidelines:
# - Use #[inline] for functions < 20 lines called in hot paths
# - Use #[inline(always)] only for trivial getters/setters
# - Profile before adding complexity for performance
#
# 3. Documentation Standards:
# - All public items require doc comments
# - Include examples for non-trivial functions
# - Document panics, safety, and errors clearly
#
# 4. Testing Requirements:
# - All public functions must have tests
# - Unsafe code requires extra test coverage
# - Benchmark changes that affect hot paths
#
# =============================================================================