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 new clippy lints #2096

Merged
merged 4 commits into from
Jul 4, 2024
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
1,633 changes: 817 additions & 816 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/api/data_types/chunking/upload/options.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dead_code)] // `hash_algorithm` is never used

use serde::Deserialize;

use super::{ChunkCompression, ChunkHashAlgorithm, ChunkUploadCapability};
Expand Down
2 changes: 2 additions & 0 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dead_code)] // a ton of fields might be unused

//! This module implements the API access to the Sentry API as well
//! as some other APIs we interact with. In particular it can talk
//! to the GitHub API to figure out if there are new releases of the
Expand Down
2 changes: 1 addition & 1 deletion src/commands/events/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {

let max_rows = std::cmp::min(
events.len(),
*matches.get_one("max_rows").unwrap_or(&std::usize::MAX),
*matches.get_one("max_rows").unwrap_or(&usize::MAX),
);

if let Some(events) = events.get(..max_rows) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/issues/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {

let max_rows = std::cmp::min(
issues.len(),
*matches.get_one("max_rows").unwrap_or(&std::usize::MAX),
*matches.get_one("max_rows").unwrap_or(&usize::MAX),
);

if let Some(issues) = issues.get(..max_rows) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/organizations/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn execute(_matches: &ArgMatches) -> Result<()> {
.add(&organization.id)
.add(&organization.name)
.add(&organization.slug)
.add(&organization.date_created.format("%F"))
.add(organization.date_created.format("%F"))
.add(organization.is_early_adopter)
.add(organization.require_2fa);
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/dif_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ fn collect_object_dif<'a>(
// We retain the buffer and the borrowed object in a new SelfCell. This is
// incredibly unsafe, but in our case it is fine, since the SelfCell owns the same
// buffer that was used to retrieve the object.
#[allow(clippy::missing_transmute_annotations)]
let cell = unsafe {
SelfCell::from_raw(
buffer.clone(),
Expand Down
2 changes: 1 addition & 1 deletion src/utils/file_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ mod tests {
let hash = Sha1::from(buf);
assert_eq!(
hash.digest().to_string(),
"d38fb9915de70eec2aa2d0c380b344d89ef540f0"
"f0e25ae149b711c510148e022ebc883ad62c7c4c"
);
}
}
21 changes: 7 additions & 14 deletions src/utils/sourcemaps/inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ lazy_static! {
// 2. a block of line comments, block comments, and empty lines,
// 3. and an optional `"use strict";` statement.`
static ref PRE_INJECT_RE: Regex = Regex::new(
r#"^(#!.*[\n\r])?(?:\s*|/\*(?:.|\r|\n)*?\*/|//.*[\n\r])*(?:"[^"]*";|'[^']*';[\n\r]?)?"#
r#"^(#!.*[\n\r])?(?:\s+|/\*(?:.|\r|\n)*?\*/|//.*[\n\r])*(?:"[^"]*";|'[^']*';[\n\r]?)?"#
)
.unwrap();
}
Expand Down Expand Up @@ -109,11 +109,9 @@ impl fmt::Display for InjectReport {
/// Fixes up a minified JS source file with a debug id.
///
/// This changes the source file in several ways:
/// 1. The source code snippet
/// `<CODE_SNIPPET>[<debug_id>]`
/// is inserted at the earliest possible position, which is after an
/// optional hashbang, followed by a
/// block of comments, empty lines, and an optional `"use […]";` or `'use […]';` pragma.
/// 1. The source code snippet `<CODE_SNIPPET>[<debug_id>]` is inserted at the earliest possible position,
/// which is after an optional hashbang, followed by a block of comments, empty lines,
/// and an optional `"use […]";` or `'use […]';` pragma.
/// 2. A comment of the form `//# debugId=<debug_id>` is appended to the file.
///
/// This function returns a [`SourceMap`] that maps locations in the injected file
Expand Down Expand Up @@ -160,12 +158,10 @@ pub fn fixup_js_file(js_contents: &mut Vec<u8>, debug_id: DebugId) -> Result<Sou
/// Fixes up a minified JS source file with a debug id without messing with mappings.
///
/// This changes the source file in several ways:
/// 1. The source code snippet
/// `<CODE_SNIPPET>[<debug_id>]` is appended to the file.
/// 1. The source code snippet `<CODE_SNIPPET>[<debug_id>]` is appended to the file.
/// 2. A comment of the form `//# debugId=<debug_id>` is appended to the file.
/// 3. The last source mapping comment (a comment starting with
/// `//# sourceMappingURL=` or `//@ sourceMappingURL=`) is moved to
/// the very end of the file, after the debug id comment from 2.
/// 3. The last source mapping comment (a comment starting with `//# sourceMappingURL=` or `//@ sourceMappingURL=`)
/// is moved to the very end of the file, after the debug id comment from 2.
///
/// This function is useful in cases where a source file's corresponding sourcemap is
/// not available. In such a case, [`fixup_js_file`] might mess up the mappings by inserting
Expand Down Expand Up @@ -327,7 +323,6 @@ some line
something else"#;

let debug_id = DebugId::default();

let mut source = Vec::from(source);

fixup_js_file(&mut source, debug_id).unwrap();
Expand Down Expand Up @@ -426,7 +421,6 @@ some line
something else"#;

let debug_id = DebugId::default();

let mut source = Vec::from(source);

fixup_js_file(&mut source, debug_id).unwrap();
Expand Down Expand Up @@ -463,7 +457,6 @@ some line
something else"#;

let debug_id = DebugId::default();

let mut source = Vec::from(source);

fixup_js_file(&mut source, debug_id).unwrap();
Expand Down
8 changes: 3 additions & 5 deletions src/utils/update.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dead_code)] // a ton of functions/fields might be unused based on the `managed` feature

use std::env;
use std::fs;
use std::io;
Expand Down Expand Up @@ -169,11 +171,7 @@ impl SentryCliUpdateInfo {
pub fn get_latest_sentrycli_release() -> Result<SentryCliUpdateInfo> {
let api = Api::current();
Ok(SentryCliUpdateInfo {
latest_release: if let Ok(release) = api.get_latest_sentrycli_release() {
release
} else {
None
},
latest_release: api.get_latest_sentrycli_release().unwrap_or_default(),
})
}

Expand Down
15 changes: 5 additions & 10 deletions tests/integration/_cases/send_metric/send_metric-help.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ transmission errors by passing --log-level=debug or setting `SENTRY_LOG_LEVEL=de
Usage: sentry-cli[EXE] send-metric [OPTIONS] [COMMAND]

Commands:
increment
Increment a counter metric
distribution
Update a distribution metric with the provided value
gauge
Update a gauge metric with the provided value
set
Update a set metric with the provided value
help
Print this message or the help of the given subcommand(s)
increment Increment a counter metric
distribution Update a distribution metric with the provided value
gauge Update a gauge metric with the provided value
set Update a set metric with the provided value
help Print this message or the help of the given subcommand(s)

Options:
--header <KEY:VALUE>
Expand Down
Loading