Skip to content

Commit

Permalink
chore(beta): Compile and test Relay with current beta (#3312)
Browse files Browse the repository at this point in the history
Make sure that Relay compiles with beta, and all the lint warnings and
errors are addressed.

This mostly done with `cargo fix` and plus some small manual deletions. 

There is no functional changes in this PR.
  • Loading branch information
olksdr authored Mar 25, 2024
1 parent 2c01c96 commit ec791fe
Show file tree
Hide file tree
Showing 57 changed files with 74 additions and 172 deletions.
1 change: 0 additions & 1 deletion relay-base-schema/src/data_category.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Defines the [`DataCategory`] type that classifies data Relay can handle.

use std::convert::TryInto;
use std::fmt;
use std::str::FromStr;

Expand Down
2 changes: 0 additions & 2 deletions relay-cardinality/src/redis/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ impl ScopedCache {

#[cfg(test)]
mod tests {
use std::time::Duration;

use relay_base_schema::project::ProjectId;

use crate::{CardinalityLimit, CardinalityScope, OrganizationId, Scoping, SlidingWindow};
Expand Down
2 changes: 0 additions & 2 deletions relay-cardinality/src/redis/limiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,11 @@ impl IntoIterator for CheckedLimits {
mod tests {
use std::collections::HashSet;
use std::sync::atomic::AtomicU64;
use std::time::Duration;

use relay_base_schema::metrics::MetricNamespace;
use relay_base_schema::project::ProjectId;
use relay_redis::{redis, RedisConfigOptions};

use crate::limiter::EntryId;
use crate::redis::{KEY_PREFIX, KEY_VERSION};
use crate::{CardinalityScope, SlidingWindow};

Expand Down
1 change: 0 additions & 1 deletion relay-config/src/byte_size.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::convert::TryInto;
use std::fmt;
use std::str::FromStr;

Expand Down
1 change: 0 additions & 1 deletion relay-config/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::{BTreeMap, HashMap};
use std::convert::TryInto;
use std::error::Error;
use std::io::Write;
use std::net::{IpAddr, SocketAddr, ToSocketAddrs};
Expand Down
14 changes: 4 additions & 10 deletions relay-event-normalization/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ pub fn normalize_ip_addresses(
if let Some(ref mut user) = user.value_mut() {
if let Some(ref mut user_ip) = user.ip_address.value_mut() {
if user_ip.is_auto() {
*user_ip = client_ip.to_owned();
client_ip.clone_into(user_ip)
}
}
}
Expand Down Expand Up @@ -1103,18 +1103,12 @@ mod tests {

use insta::assert_debug_snapshot;
use itertools::Itertools;
use relay_event_schema::protocol::{
Breadcrumb, Contexts, Csp, DebugMeta, DeviceContext, Event, Headers, IpAddr, Measurements,
Request, Tags, Values,
};
use relay_protocol::{get_value, Annotated, SerializableAnnotated};
use relay_event_schema::protocol::{Breadcrumb, Csp, DebugMeta, DeviceContext, Values};
use relay_protocol::{get_value, SerializableAnnotated};
use serde_json::json;

use super::*;
use crate::{
ClientHints, DynamicMeasurementsConfig, MeasurementsConfig, PerformanceScoreConfig,
RawUserAgentInfo,
};
use crate::{ClientHints, MeasurementsConfig};

const IOS_MOBILE_EVENT: &str = r#"
{
Expand Down
2 changes: 1 addition & 1 deletion relay-event-normalization/src/normalize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ mod tests {
Span, SpanId, Stacktrace, TagEntry, Tags, TraceId, User, Values,
};
use relay_protocol::{
assert_annotated_snapshot, get_path, get_value, ErrorKind, FromValue, SerializableAnnotated,
assert_annotated_snapshot, get_path, get_value, ErrorKind, SerializableAnnotated,
};
use serde_json::json;
use similar_asserts::assert_eq;
Expand Down
2 changes: 1 addition & 1 deletion relay-event-normalization/src/normalize/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pub fn normalize_request(request: &mut Request) {

#[cfg(test)]
mod tests {
use relay_event_schema::protocol::{Headers, PairList, Query};
use relay_event_schema::protocol::{Headers, PairList};
use relay_protocol::Object;
use similar_asserts::assert_eq;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl NormalizeVisitor {
if let Some(s) = filter {
match s {
sqlparser::ast::ShowStatementFilter::Like(s)
| sqlparser::ast::ShowStatementFilter::ILike(s) => *s = "%s".to_owned(),
| sqlparser::ast::ShowStatementFilter::ILike(s) => "%s".clone_into(s),
sqlparser::ast::ShowStatementFilter::Where(_) => {}
}
}
Expand Down Expand Up @@ -519,7 +519,7 @@ impl VisitorMut for NormalizeVisitor {
Statement::Truncate { .. } => {}
Statement::Msck { .. } => {}
Statement::Directory { path, .. } => {
*path = "%s".to_owned();
"%s".clone_into(path);
}
Statement::Call(_) => {}
Statement::Copy { source, values, .. } => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@ pub fn compute_span_exclusive_time(event: &mut Event) {
#[cfg(test)]
mod tests {
use chrono::{TimeZone, Utc};
use relay_event_schema::protocol::{
Contexts, Event, EventType, Span, SpanId, Timestamp, TraceContext, TraceId,
};
use relay_protocol::Annotated;
use relay_event_schema::protocol::{EventType, Timestamp, TraceId};
use similar_asserts::assert_eq;

use super::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,8 @@ fn get_event_start_type(event: &Event) -> Option<&'static str> {
#[cfg(test)]
mod tests {
use insta::assert_debug_snapshot;
use relay_event_schema::protocol::{Event, Request};
use relay_protocol::{get_value, Annotated};
use relay_event_schema::protocol::Request;
use relay_protocol::get_value;

use super::*;
use crate::span::description::{scrub_queries, Mode};
Expand Down
2 changes: 1 addition & 1 deletion relay-event-normalization/src/normalize/user_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ impl FromUserAgentInfo for OsContext {

#[cfg(test)]
mod tests {
use relay_event_schema::protocol::{Headers, PairList, Request};
use relay_event_schema::protocol::{PairList, Request};
use relay_protocol::assert_annotated_snapshot;

use super::*;
Expand Down
4 changes: 2 additions & 2 deletions relay-event-normalization/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ fn verify_value_characters(

#[cfg(test)]
mod tests {
use relay_event_schema::processor::{self, ProcessingState};
use relay_event_schema::processor;
use relay_event_schema::protocol::{
CError, ClientSdkInfo, Event, MachException, Mechanism, MechanismMeta, PosixSignal,
RawStacktrace, User,
};
use relay_protocol::{Annotated, ErrorKind};
use relay_protocol::Annotated;
use similar_asserts::assert_eq;

use super::*;
Expand Down
2 changes: 1 addition & 1 deletion relay-event-normalization/src/transactions/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ mod tests {
use itertools::Itertools;
use relay_common::glob2::LazyGlob;
use relay_event_schema::processor::process_value;
use relay_event_schema::protocol::{ClientSdkInfo, Contexts, Span, SpanId, TraceId};
use relay_event_schema::protocol::{ClientSdkInfo, Contexts, SpanId, TraceId};
use relay_protocol::{assert_annotated_snapshot, get_value};

use crate::{validate_transaction, RedactionRule, TransactionValidationConfig};
Expand Down
2 changes: 0 additions & 2 deletions relay-event-normalization/src/transactions/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ impl TransactionNameRule {

#[cfg(test)]
mod tests {
use chrono::{DateTime, Utc};

use super::*;

#[test]
Expand Down
8 changes: 2 additions & 6 deletions relay-event-normalization/src/trimming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,10 @@ fn slim_frame_data(frames: &mut Array<Frame>, frame_allowance: usize) {
mod tests {
use std::iter::repeat;

use relay_event_schema::processor::MaxChars;
use relay_event_schema::protocol::{
Breadcrumb, Context, Contexts, Event, Exception, ExtraValue, Frame, RawStacktrace,
TagEntry, Tags, Values,
};
use relay_protocol::{
Annotated, Map, Meta, Object, Remark, RemarkType, SerializableAnnotated, Value,
Breadcrumb, Context, Contexts, Event, Exception, ExtraValue, TagEntry, Tags, Values,
};
use relay_protocol::{Map, Remark, SerializableAnnotated};
use similar_asserts::assert_eq;

use super::*;
Expand Down
1 change: 0 additions & 1 deletion relay-event-schema/src/protocol/contexts/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ impl super::DefaultContext for DeviceContext {

#[cfg(test)]
mod tests {
use relay_protocol::{Annotated, Object, Value};
use uuid::uuid;

use super::*;
Expand Down
2 changes: 0 additions & 2 deletions relay-event-schema/src/protocol/contexts/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ impl super::DefaultContext for ResponseContext {

#[cfg(test)]
mod tests {
use relay_protocol::Annotated;

use super::*;
use crate::protocol::{Context, PairList};

Expand Down
2 changes: 0 additions & 2 deletions relay-event-schema/src/protocol/request.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::iter::{FromIterator, IntoIterator};

use cookie::Cookie;
#[cfg(feature = "jsonschema")]
use relay_jsonschema_derive::JsonSchema;
Expand Down
1 change: 0 additions & 1 deletion relay-event-schema/src/protocol/types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Common types of the protocol.
use std::borrow::Cow;
use std::cmp::Ordering;
use std::iter::{FromIterator, IntoIterator};
use std::ops::{Add, Sub};
use std::str::FromStr;
use std::{fmt, net};
Expand Down
1 change: 0 additions & 1 deletion relay-filter/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::borrow::Cow;
use std::convert::TryFrom;
use std::fmt;

use serde::Serialize;
Expand Down
5 changes: 1 addition & 4 deletions relay-filter/src/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,8 @@ mod tests {

use super::*;

use crate::generic::{should_filter, MAX_SUPPORTED_VERSION};
use crate::{FilterStatKey, GenericFilterConfig, GenericFiltersConfig};
use relay_event_schema::protocol::{Event, LenientString};
use relay_event_schema::protocol::LenientString;
use relay_protocol::Annotated;
use relay_protocol::RuleCondition;

fn mock_filters() -> GenericFiltersMap {
vec![
Expand Down
2 changes: 0 additions & 2 deletions relay-filter/src/legacy_browsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ mod tests {
const SAFARI_UA: &str = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.17.4; en-GB) AppleWebKit/605.1.5 (KHTML, like Gecko) Version/6.0 Safari/605.1.5";
const ANDROID_UA: &str = "Mozilla/5.0 (Linux; U; Android 3.2; nl-nl; GT-P6800 Build/HTJ85B) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13";

use std::collections::BTreeSet;

use super::*;
use crate::testutils;

Expand Down
2 changes: 1 addition & 1 deletion relay-filter/src/releases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn should_filter(event: &Event, config: &ReleasesFilterConfig) -> Result<(),
#[cfg(test)]
mod tests {
use relay_common::glob3::GlobPatterns;
use relay_event_schema::protocol::{Event, LenientString};
use relay_event_schema::protocol::LenientString;
use relay_protocol::Annotated;

use super::*;
Expand Down
1 change: 0 additions & 1 deletion relay-metrics/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::collections::hash_map::Entry;
use std::collections::{BTreeMap, HashMap};
use std::error::Error;
use std::hash::Hasher;
use std::iter::FromIterator;
use std::time::Duration;
use std::{fmt, mem};

Expand Down
3 changes: 1 addition & 2 deletions relay-metrics/src/aggregatorservice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,8 @@ mod tests {
use std::sync::{Arc, RwLock};

use relay_common::time::UnixTimestamp;
use relay_system::{FromMessage, Interface};

use crate::{BucketCountInquiry, BucketMetadata, BucketValue};
use crate::{BucketMetadata, BucketValue};

use super::*;

Expand Down
1 change: 0 additions & 1 deletion relay-metrics/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,6 @@ fn split_at(bucket: &BucketView<'_>, max_size: usize, min_split_size: usize) ->
#[cfg(test)]
mod tests {
use insta::assert_json_snapshot;
use relay_common::time::UnixTimestamp;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion relay-monitors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub enum ProcessCheckInError {
InvalidEnvironment,
}

///
/// Describes the status of the incoming CheckIn.
#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum CheckInStatus {
Expand Down
3 changes: 1 addition & 2 deletions relay-pii/src/attachments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,9 +947,8 @@ mod tests {
}

#[test]
#[allow(clippy::trivial_regex)]
fn test_get_wstr_match() {
#![allow(clippy::trivial_regex)]

let s = "hello there";
let mut b = Vec::from(&b"h\x00e\x00l\x00l\x00o\x00 \x00t\x00h\x00e\x00r\x00e\x00"[..]);
let w = WStr::from_utf16le_mut(b.as_mut_slice()).unwrap();
Expand Down
1 change: 0 additions & 1 deletion relay-pii/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ declare_builtin_rules! {
#[cfg(test)]
mod tests {
use std::borrow::Cow;
use std::collections::BTreeMap;

use relay_event_schema::processor::{
process_value, EnumSet, FieldAttrs, Pii, ProcessingState, ValueType,
Expand Down
1 change: 0 additions & 1 deletion relay-pii/src/minidumps.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Minidump scrubbing.

use std::borrow::Cow;
use std::convert::TryInto;
use std::num::TryFromIntError;
use std::ops::Range;
use std::str::Utf8Error;
Expand Down
8 changes: 3 additions & 5 deletions relay-pii/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<'a> Processor for PiiProcessor<'a> {
match self.process_string(value, meta, state) {
Ok(()) => value.push_str(&basename),
Err(ProcessingAction::DeleteValueHard) | Err(ProcessingAction::DeleteValueSoft) => {
*value = basename[1..].to_owned();
basename[1..].clone_into(value);
}
Err(ProcessingAction::InvalidTransaction(x)) => {
return Err(ProcessingAction::InvalidTransaction(x))
Expand Down Expand Up @@ -469,12 +469,10 @@ mod tests {
use insta::assert_debug_snapshot;
use relay_event_schema::processor::process_value;
use relay_event_schema::protocol::{
Addr, Breadcrumb, DebugImage, DebugMeta, Event, ExtraValue, Headers, LogEntry, Message,
Addr, Breadcrumb, DebugImage, DebugMeta, ExtraValue, Headers, LogEntry, Message,
NativeDebugImage, Request, Span, TagEntry, Tags, TraceContext,
};
use relay_protocol::{
assert_annotated_snapshot, get_value, Annotated, FromValue, Object, Value,
};
use relay_protocol::{assert_annotated_snapshot, get_value, FromValue, Object};
use serde_json::json;

use super::*;
Expand Down
4 changes: 3 additions & 1 deletion relay-pii/src/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ pub enum InvalidSelectorError {
InternalError,
}

#[allow(unknown_lints)]
#[allow(clippy::upper_case_acronyms)]
#[allow(clippy::empty_docs)]
mod parser {
#![allow(clippy::upper_case_acronyms)]
use pest_derive::Parser;

#[derive(Parser)]
Expand Down
Loading

0 comments on commit ec791fe

Please sign in to comment.