Skip to content

Commit

Permalink
cargo fmt and alphabetical order in messages and detector enum
Browse files Browse the repository at this point in the history
  • Loading branch information
faculerena committed Nov 29, 2023
1 parent 81af193 commit 9dbf9c9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
22 changes: 12 additions & 10 deletions detectors/divide-before-multiply/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,13 @@ fn navigate_trough_basicblocks<'tcx>(
fn_span,
..
} => {
if let Operand::Constant(cst) = func &&
let Const::Val(_, ty) = cst.const_ &&
let TyKind::FnDef(id, _) = ty.kind() {
if def_ids.checked_div.is_some_and(|f|f == *id) ||
def_ids.saturating_div.is_some_and(|f|f == *id) {
if let Operand::Constant(cst) = func
&& let Const::Val(_, ty) = cst.const_
&& let TyKind::FnDef(id, _) = ty.kind()
{
if def_ids.checked_div.is_some_and(|f| f == *id)
|| def_ids.saturating_div.is_some_and(|f| f == *id)
{
tainted_places.push(*destination);
} else {
for arg in args {
Expand All @@ -198,14 +200,14 @@ fn navigate_trough_basicblocks<'tcx>(
if tainted_places.contains(place) {
tainted_places.push(*destination);

if def_ids.checked_mul.is_some_and(|f|f == *id) ||
def_ids.saturating_mul.is_some_and(|f|f == *id) {
if def_ids.checked_mul.is_some_and(|f| f == *id)
|| def_ids.saturating_mul.is_some_and(|f| f == *id)
{
spans.push(*fn_span);
}
}

},
_ => {},
}
_ => {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion scout-audit-internal/src/detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use strum::{Display, EnumIter};
#[strum(serialize_all = "kebab-case")]
pub enum Detector {
DivideBeforeMultiply,
UnsafeExpect,
OverflowCheck,
UnsafeExpect,
UnsafeUnwrap,
}

Expand Down
2 changes: 1 addition & 1 deletion scout-audit-internal/src/detector/lint_message.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub const DIVIDE_BEFORE_MULTIPLY_LINT_MESSAGE: &str =
"Division before multiplication might result in a loss of precision";
pub const UNSAFE_EXPECT_LINT_MESSAGE: &str = "Unsafe usage of `expect`";
pub const OVERFLOW_CHECK_LINT_MESSAGE: &str = "Use `overflow-checks = true` in Cargo.toml profile";
pub const UNSAFE_EXPECT_LINT_MESSAGE: &str = "Unsafe usage of `expect`";
pub const UNSAFE_UNWRAP_MESSAGE: &str = "Unsafe usage of `unwrap`";

0 comments on commit 9dbf9c9

Please sign in to comment.