Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Clippy lints 1.57.0 #1144

Merged
merged 2 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions relay-cabi/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ pub extern "C" fn relay_init() {
/// If there is no error, 0 is returned.
#[no_mangle]
pub extern "C" fn relay_err_get_last_code() -> RelayErrorCode {
relay_ffi::with_last_error(|err| RelayErrorCode::from_error(err))
.unwrap_or(RelayErrorCode::NoError)
relay_ffi::with_last_error(RelayErrorCode::from_error).unwrap_or(RelayErrorCode::NoError)
}

/// Returns the last error message.
Expand Down
13 changes: 1 addition & 12 deletions relay-common/src/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lazy_static! {
}

/// Controls the options of the globber.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct GlobOptions {
/// When enabled `**` matches over path separators and `*` does not.
pub double_star: bool,
Expand All @@ -24,17 +24,6 @@ pub struct GlobOptions {
pub allow_newline: bool,
}

impl Default for GlobOptions {
fn default() -> GlobOptions {
GlobOptions {
double_star: false,
case_insensitive: false,
path_normalize: false,
allow_newline: false,
}
}
}

fn translate_pattern(pat: &str, options: GlobOptions) -> Option<Regex> {
let mut builder = GlobBuilder::new(pat);
builder.case_insensitive(options.case_insensitive);
Expand Down
1 change: 1 addition & 0 deletions relay-crash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod native {
/// Internally, this uses the Breakpad client to capture crash signals and send minidumps to Sentry.
/// If no DSN is configured, the crash handler is not initialized.
#[derive(Debug, Default)]
#[cfg_attr(not(unix), allow(dead_code))]
pub struct CrashHandler<'a> {
dsn: &'a str,
database: &'a str,
Expand Down
1 change: 1 addition & 0 deletions relay-general/src/pii/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ impl<'a> PiiProcessor<'a> {

for (selector, rules) in self.compiled_config.applications.iter() {
if state.path().matches_selector(selector) {
#[allow(clippy::needless_option_as_deref)]
for rule in rules {
let reborrowed_value = value.as_deref_mut();
apply_rule_to_value(meta, rule, state.path().key(), reborrowed_value)?;
Expand Down
7 changes: 3 additions & 4 deletions relay-general/src/protocol/security_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,8 @@ impl CspRaw {
}

self.violated_directive
.splitn(2, ' ')
.next()
.and_then(|v| v.parse().ok())
.split_once(' ')
.and_then(|(v, _)| v.parse().ok())
.ok_or(InvalidSecurityError)
}

Expand Down Expand Up @@ -364,7 +363,7 @@ impl CspRaw {
None => "",
};

match original_uri.splitn(2, ':').next().unwrap_or_default() {
match original_uri.split_once(':').unwrap_or_default().0 {
"http" | "https" => Cow::Borrowed(value),
scheme => Cow::Owned(unsplit_uri(scheme, value)),
}
Expand Down
2 changes: 1 addition & 1 deletion relay-quotas/src/quota.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ impl Quota {
/// - The quota only applies to `Unknown` data categories.
/// - The quota is counted (not limit `0`) but specifies categories with different units.
pub fn is_valid(&self) -> bool {
let mut units = self.categories.iter().filter_map(|c| CategoryUnit::from(c));
let mut units = self.categories.iter().filter_map(CategoryUnit::from);

match units.next() {
// There are only unknown categories, which is always invalid
Expand Down
14 changes: 9 additions & 5 deletions tools/generate-schema/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ struct Cli {

impl Cli {
pub fn run(self) -> Result<()> {
let schema = relay_general::protocol::event_json_schema();

match self.output {
Some(path) => serde_json::to_writer_pretty(File::create(path)?, &schema)?,
None => serde_json::to_writer_pretty(io::stdout(), &schema)?,
match self.format {
SchemaFormat::JsonSchema => {
let schema = relay_general::protocol::event_json_schema();

match self.output {
Some(path) => serde_json::to_writer_pretty(File::create(path)?, &schema)?,
None => serde_json::to_writer_pretty(io::stdout(), &schema)?,
}
}
}

Ok(())
Expand Down