Skip to content

Commit 15448c4

Browse files
committed
Clippy: Check also pub items
Turns out clippy has a terrible and shocking default: it won't make suggestions that require introducing breaking changes. This means that e.g. if we introduce a type which has a naming that clippy would normally complain about, it won't if the type is pub! For this reason we have many such types. This commit disables this absurd default, and adds comment and attribute to each place affected by this.
1 parent 64064c0 commit 15448c4

File tree

10 files changed

+52
-1
lines changed

10 files changed

+52
-1
lines changed

clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
avoid-breaking-exported-api = false

scylla-cql/src/deserialize/frame_slice.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ impl<'frame> FrameSlice<'frame> {
121121
/// Returns a new Bytes object which is a subslice of the original Bytes
122122
/// frame slice object.
123123
#[inline]
124+
// Check triggers because `self` is `Copy`, so `to_` should take it by value.
125+
// TODO(2.0): Take self by value.
126+
#[expect(clippy::wrong_self_convention)]
124127
pub fn to_bytes(&self) -> Bytes {
125128
if self.original_frame.is_empty() {
126129
// For the borrowed, deficient version of FrameSlice - the one created with

scylla-cql/src/deserialize/value.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,6 +2167,9 @@ impl From<VectorDeserializationErrorKind> for BuiltinDeserializationErrorKind {
21672167
/// Describes why deserialization of a map type failed.
21682168
#[derive(Debug)]
21692169
#[non_exhaustive]
2170+
// Check triggers because all variants end with "DeserializationFailed".
2171+
// TODO(2.0): Remove the "DeserializationFailed" postfix from variants.
2172+
#[expect(clippy::enum_variant_names)]
21702173
pub enum MapDeserializationErrorKind {
21712174
/// Failed to deserialize map's length.
21722175
LengthDeserializationFailed(DeserializationError),

scylla-cql/src/frame/frame_errors.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ pub enum CqlRequestSerializationError {
130130
/// server response fails.
131131
#[non_exhaustive]
132132
#[derive(Error, Debug, Clone)]
133+
// Check triggers because all variants begin with "Cql".
134+
// TODO(2.0): Remove the "Cql" prefix from variants.
135+
#[expect(clippy::enum_variant_names)]
133136
pub enum CqlResponseParseError {
134137
#[error("Failed to deserialize ERROR response: {0}")]
135138
CqlErrorParseError(#[from] CqlErrorParseError),
@@ -313,6 +316,9 @@ pub enum PreparedParseError {
313316
/// - paging state response
314317
#[non_exhaustive]
315318
#[derive(Debug, Error, Clone)]
319+
// Check triggers because all variants end with "ParseError".
320+
// TODO(2.0): Remove the "ParseError" postfix from variants.
321+
#[expect(clippy::enum_variant_names)]
316322
pub enum RawRowsAndPagingStateResponseParseError {
317323
/// Failed to parse metadata flags.
318324
#[error("Malformed metadata flags: {0}")]
@@ -331,6 +337,9 @@ pub enum RawRowsAndPagingStateResponseParseError {
331337
/// of statement's prepared metadata failed.
332338
#[non_exhaustive]
333339
#[derive(Error, Debug, Clone)]
340+
// Check triggers because all variants end with "ParseError".
341+
// TODO(2.0): Remove the "ParseError" postfix from variants.
342+
#[expect(clippy::enum_variant_names)]
334343
pub enum PreparedMetadataParseError {
335344
/// Failed to parse metadata flags.
336345
#[error("Malformed metadata flags: {0}")]
@@ -375,6 +384,9 @@ pub enum ResultMetadataAndRowsCountParseError {
375384
/// of result metadata failed.
376385
#[non_exhaustive]
377386
#[derive(Error, Debug, Clone)]
387+
// Check triggers because all variants end with "ParseError".
388+
// TODO(2.0): Remove the "ParseError" postfix from variants.
389+
#[expect(clippy::enum_variant_names)]
378390
pub enum ResultMetadataParseError {
379391
/// Failed to parse metadata flags.
380392
#[error("Malformed metadata flags: {0}")]
@@ -422,6 +434,9 @@ pub struct ColumnSpecParseError {
422434
/// of a column specification.
423435
#[non_exhaustive]
424436
#[derive(Error, Debug, Clone)]
437+
// Check triggers because all variants end with "ParseError".
438+
// TODO(2.0): Remove the "ParseError" postfix from variants.
439+
#[expect(clippy::enum_variant_names)]
425440
pub enum ColumnSpecParseErrorKind {
426441
#[error("Invalid table spec: {0}")]
427442
TableSpecParseError(#[from] TableSpecParseError),

scylla-cql/src/frame/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ pub mod flag {
3131
pub const WARNING: u8 = 0x08;
3232
}
3333

34-
// All of the Authenticators supported by Scylla
34+
/// All of the Authenticators supported by Scylla
3535
#[derive(Debug, PartialEq, Eq, Clone)]
36+
// Check triggers because all variants end with "Authenticator".
37+
// TODO(2.0): Remove the "Authenticator" postfix from variants.
38+
#[expect(clippy::enum_variant_names)]
3639
pub enum Authenticator {
3740
AllowAllAuthenticator,
3841
PasswordAuthenticator,

scylla-cql/src/frame/response/event.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ use crate::frame::types;
66
use std::net::SocketAddr;
77

88
#[derive(Debug)]
9+
// Check triggers because all variants end with "Change".
10+
// TODO(2.0): Remove the "Change" postfix from variants.
11+
#[expect(clippy::enum_variant_names)]
912
pub enum Event {
1013
TopologyChange(TopologyChangeEvent),
1114
StatusChange(StatusChangeEvent),
@@ -25,6 +28,9 @@ pub enum StatusChangeEvent {
2528
}
2629

2730
#[derive(Debug)]
31+
// Check triggers because all variants end with "Change".
32+
// TODO(2.0): Remove the "Change" postfix from variants.
33+
#[expect(clippy::enum_variant_names)]
2834
pub enum SchemaChangeEvent {
2935
KeyspaceChange {
3036
change_type: SchemaChangeType,

scylla-cql/src/frame/server_event_type.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ use std::str::FromStr;
33

44
use super::frame_errors::CqlEventParseError;
55

6+
// Check triggers because all variants end with "Change".
7+
// TODO(2.0): Remove the "Change" postfix from variants.
8+
#[expect(clippy::enum_variant_names)]
69
pub enum EventType {
710
TopologyChange,
811
StatusChange,

scylla/src/cluster/metadata.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ impl std::str::FromStr for ColumnKind {
359359

360360
#[derive(Clone, Debug, PartialEq, Eq)]
361361
#[non_exhaustive]
362+
// Check triggers because all variants end with "Strategy".
363+
// TODO(2.0): Remove the "Strategy" postfix from variants.
364+
#[expect(clippy::enum_variant_names)]
362365
pub enum Strategy {
363366
SimpleStrategy {
364367
replication_factor: usize,

scylla/src/errors.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ pub enum PrepareError {
116116
/// An error that occurred during construction of [`QueryPager`][crate::client::pager::QueryPager].
117117
#[derive(Error, Debug, Clone)]
118118
#[non_exhaustive]
119+
// Check triggers because all variants end with "Error".
120+
// TODO(2.0): Remove the "Error" postfix from variants.
121+
#[expect(clippy::enum_variant_names)]
119122
pub enum PagerExecutionError {
120123
/// Failed to prepare the statement.
121124
#[error("Failed to prepare the statement to be used by the pager: {0}")]

scylla/src/routing/partitioner.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ use crate::statement::prepared::TokenCalculationError;
2121
pub enum PartitionerName {
2222
#[default]
2323
Murmur3,
24+
// Check triggers, because according to guidelines acronyms should be counted
25+
// as one word and written in UpperCamelCase. In this case the variant should
26+
// be Cdc.
27+
// TODO(2.0): Rename variant to Cdc.
28+
#[expect(clippy::upper_case_acronyms)]
2429
CDC,
2530
}
2631

@@ -53,6 +58,12 @@ impl Partitioner for PartitionerName {
5358
#[non_exhaustive]
5459
pub enum PartitionerHasherAny {
5560
Murmur3(Murmur3PartitionerHasher),
61+
// Check triggers, because according to guidelines acronyms should be counted
62+
// as one word and written in UpperCamelCase. In this case the variant should
63+
// be Cdc.
64+
// TODO(2.0): Rename variant to Cdc.
65+
// TODO(2.0): Rename CDCPartitionerHasher to CdcPartitionerHasher
66+
#[expect(clippy::upper_case_acronyms)]
5667
CDC(CDCPartitionerHasher),
5768
}
5869

0 commit comments

Comments
 (0)