Skip to content

Commit

Permalink
Merge pull request #276 from CoinFabrik/clippy-wrappers
Browse files Browse the repository at this point in the history
 Moved to scout-audit-clippy-wrappers.
  • Loading branch information
tenuki committed Aug 8, 2024
2 parents 329d387 + 51f7420 commit 01a2539
Show file tree
Hide file tree
Showing 69 changed files with 85 additions and 60 deletions.
3 changes: 2 additions & 1 deletion detectors/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[workspace]
exclude = [".cargo", "target"]
exclude = [".cargo", "target", ".vscode"]
members = ["*"]

[workspace.dependencies]
clippy_utils = { git = "https://github.com/rust-lang/rust-clippy", rev = "99c7838" }
clippy_wrappers = { package = "scout-audit-clippy-wrappers-ink", git = "https://github.com/CoinFabrik/scout-audit/", rev = "e68a1bcccd0c3c65c8bbe3d6e7aa76f75abe8f92" }
if_chain = "=1.0.2"
itertools = { version = "=0.13" }
scout-audit-dylint-linting = { git = "https://github.com/CoinFabrik/scout-audit", rev = "e03ede4" }
1 change: 1 addition & 0 deletions detectors/assert-violation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion detectors/assert-violation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn check_macro_call(cx: &EarlyContext, span: Span, mac: &P<MacCall>) {
.iter()
.any(|sym| &mac.path == sym)
{
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
ASSERT_VIOLATION,
span,
Expand Down
1 change: 1 addition & 0 deletions detectors/avoid-autokey-upgradable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
itertools = { workspace = true }
scout-audit-dylint-linting = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion detectors/avoid-autokey-upgradable/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern crate rustc_error_messages;
extern crate rustc_hir;
extern crate rustc_span;

use clippy_wrappers::span_lint_and_note;
use itertools::Itertools;
use rustc_error_messages::MultiSpan;
use rustc_hir::GenericArg;
Expand All @@ -14,7 +15,6 @@ use rustc_hir::{
};
use rustc_lint::{LateContext, LateLintPass};
use rustc_span::Span;
use clippy_utils::diagnostics::span_lint_and_note;

scout_audit_dylint_linting::impl_late_lint! {
pub AVOID_AUTOKEY_UPGRADABLE,
Expand Down
1 change: 1 addition & 0 deletions detectors/avoid-core-mem-forget/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion detectors/avoid-core-mem-forget/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl EarlyLintPass for AvoidStdCoreMemForget {
if path.segments[1].ident.name.to_string() == "mem";
if path.segments[2].ident.name.to_string() == "forget";
then {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
AVOID_STD_CORE_MEM_FORGET,
expr.span,
Expand Down
1 change: 1 addition & 0 deletions detectors/avoid-format-string/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

Expand Down
4 changes: 2 additions & 2 deletions detectors/avoid-format-string/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
extern crate rustc_ast;
extern crate rustc_span;

use clippy_utils::sym;
use if_chain::if_chain;
use rustc_ast::{
tokenstream::{TokenStream, TokenTree},
AttrArgs, AttrKind, Expr, ExprKind, Item,
};
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_span::{sym, Span};
use clippy_utils::sym;

const LINT_MESSAGE: &str = "The format! macro should not be used.";

Expand Down Expand Up @@ -93,7 +93,7 @@ impl EarlyLintPass for AvoidFormatString {
if mac.path == sym!(format);

then {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
AVOID_FORMAT_STRING,
expr.span,
Expand Down
1 change: 1 addition & 0 deletions detectors/avoid-unsafe-block/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion detectors/avoid-unsafe-block/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
extern crate rustc_ast;
extern crate rustc_span;

use clippy_wrappers::span_lint;
use rustc_ast::{BlockCheckMode, Expr, ExprKind, UnsafeSource};
use rustc_lint::{EarlyContext, EarlyLintPass};
use clippy_utils::diagnostics::span_lint;

const LINT_MESSAGE: &str = "Avoid using unsafe blocks as it may lead to undefined behavior.";
scout_audit_dylint_linting::impl_pre_expansion_lint! {
Expand Down
1 change: 1 addition & 0 deletions detectors/buffering-unsized-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion detectors/buffering-unsized-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ extern crate rustc_hir;
extern crate rustc_span;
use std::collections::HashMap;

use clippy_wrappers::span_lint_and_help;
use rustc_hir::{
intravisit::{walk_expr, Visitor},
Expr, ExprKind, GenericArg, QPath, Ty, TyKind,
};
use rustc_lint::{LateContext, LateLintPass};
use rustc_span::symbol::Ident;
use rustc_span::Span;
use clippy_utils::diagnostics::span_lint_and_help;
const LINT_MESSAGE: &str = "Do not use these method with an unsized (dynamically sized) type.";
scout_audit_dylint_linting::impl_late_lint! {
pub BUFFERING_UNSIZED_TYPES,
Expand Down
1 change: 1 addition & 0 deletions detectors/delegate-call/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion detectors/delegate-call/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl<'tcx> LateLintPass<'tcx> for DelegateCall {
walk_expr(&mut delegate_storage, body.value);

if delegate_storage.has_vulnerable_delegate {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
DELEGATE_CALL,
delegate_storage.span.unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion detectors/divide-before-multiply/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ crate-type = ["cdylib"]
[dependencies]
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

clippy_wrappers = { workspace = true }
clippy_utils = { workspace = true }

[package.metadata.rust-analyzer]
Expand Down
4 changes: 2 additions & 2 deletions detectors/divide-before-multiply/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ impl<'tcx> LateLintPass<'tcx> for DivideBeforeMultiply {
);

for span in spans {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
DIVIDE_BEFORE_MULTIPLY,
span,
Expand All @@ -382,7 +382,7 @@ impl<'tcx> LateLintPass<'tcx> for DivideBeforeMultiply {
if BinOpKind::Mul == op.node;
then{
for division in get_divisions_inside_expr(expr) {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
DIVIDE_BEFORE_MULTIPLY,
division,
Expand Down
1 change: 1 addition & 0 deletions detectors/dont-use-instantiate-contract-v1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion detectors/dont-use-instantiate-contract-v1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<'tcx> LateLintPass<'tcx> for DontUseInstantiateContractV1 {

visitor.has_instantiate_contract_v1_span.iter().for_each(|span| {
if let Some(span) = span {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
DONT_USE_INSTANTIATE_CONTRACT_V1,
*span,
Expand Down
1 change: 1 addition & 0 deletions detectors/dont-use-invoke-contract-v1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion detectors/dont-use-invoke-contract-v1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<'tcx> LateLintPass<'tcx> for DontUseInvokeContractV1 {

visitor.has_invoke_contract_v1_span.iter().for_each(|span| {
if let Some(span) = span {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
DONT_USE_INVOKE_CONTRACT_V1,
*span,
Expand Down
2 changes: 1 addition & 1 deletion detectors/dos-unbounded-operation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ crate-type = ["cdylib"]
[dependencies]
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

clippy_wrappers = { workspace = true }
clippy_utils = { workspace = true }

[package.metadata.rust-analyzer]
Expand Down
2 changes: 1 addition & 1 deletion detectors/dos-unbounded-operation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<'tcx> LateLintPass<'tcx> for DosUnboundedOperation {
walk_expr(&mut visitor, body.value);

for span in visitor.span_constant {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
DOS_UNBOUNDED_OPERATION,
span,
Expand Down
1 change: 1 addition & 0 deletions detectors/dos-unexpected-revert-with-vector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

Expand Down
7 changes: 1 addition & 6 deletions detectors/dos-unexpected-revert-with-vector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,7 @@ impl<'tcx> LateLintPass<'tcx> for UnexpectedRevertWarn {
&mut HashSet::<BasicBlock>::default(),
);
for place in unchecked_places {
clippy_utils::diagnostics::span_lint(
cx,
UNEXPECTED_REVERT_WARN,
place.1,
LINT_MESSAGE,
);
clippy_wrappers::span_lint(cx, UNEXPECTED_REVERT_WARN, place.1, LINT_MESSAGE);
}
}

Expand Down
1 change: 1 addition & 0 deletions detectors/incorrect-exponentiation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion detectors/incorrect-exponentiation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
extern crate rustc_hir;
extern crate rustc_span;

use clippy_wrappers::span_lint_and_help;
use rustc_hir::def_id::LocalDefId;
use rustc_hir::intravisit::Visitor;
use rustc_hir::intravisit::{walk_expr, FnKind};
use rustc_hir::{Body, FnDecl};
use rustc_hir::{Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_span::Span;
use clippy_utils::diagnostics::span_lint_and_help;

const LINT_MESSAGE: &str = "'^' It is not an exponential operator. It is a bitwise XOR.";
const LINT_HELP: &str = "If you want to use XOR, use bitxor(). If you want to raise a number use .checked_pow() or .pow() ";
Expand Down
1 change: 1 addition & 0 deletions detectors/ink-version/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }
semver = "1.0.4"
Expand Down
2 changes: 1 addition & 1 deletion detectors/ink-version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl EarlyLintPass for CheckInkVersion {
let ink_version = VersionReq::parse(&ink_version.replace('\"', "")).unwrap();

if !ink_version.matches(&req) {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
CHECK_INK_VERSION,
rustc_span::DUMMY_SP,
Expand Down
1 change: 1 addition & 0 deletions detectors/insufficiently-random-values/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion detectors/insufficiently-random-values/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'tcx> LateLintPass<'tcx> for InsufficientlyRandomValues {
if path.ident.as_str() == "block_timestamp" ||
path.ident.as_str() == "block_number";
then {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
INSUFFICIENTLY_RANDOM_VALUES,
expr.span,
Expand Down
1 change: 1 addition & 0 deletions detectors/integer-overflow-or-underflow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

Expand Down
12 changes: 6 additions & 6 deletions detectors/integer-overflow-or-underflow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
extern crate rustc_hir;
extern crate rustc_span;

use clippy_utils::consts::constant_simple;
use clippy_utils::is_integer_literal;
use rustc_hir::{self as hir, Body, Expr, ExprKind, UnOp};
use rustc_lint::LateContext;
use rustc_lint::LateLintPass;
use rustc_span::Span;
use clippy_utils::consts::constant_simple;
use clippy_utils::is_integer_literal;

pub const LINT_MESSAGE: &str = "Potential for integer arithmetic overflow/underflow. Consider checked, wrapping or saturating arithmetic.";

Expand Down Expand Up @@ -138,7 +138,7 @@ impl ArithmeticContext {
hir::ExprKind::Lit(_lit) => (),
hir::ExprKind::Unary(hir::UnOp::Neg, expr) => {
if is_integer_literal(expr, 1) {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
INTEGER_OVERFLOW_UNDERFLOW,
expr.span,
Expand All @@ -150,7 +150,7 @@ impl ArithmeticContext {
}
}
_ => {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
INTEGER_OVERFLOW_UNDERFLOW,
expr.span,
Expand All @@ -162,7 +162,7 @@ impl ArithmeticContext {
}
},
_ => {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
INTEGER_OVERFLOW_UNDERFLOW,
expr.span,
Expand All @@ -187,7 +187,7 @@ impl ArithmeticContext {
}
let ty = cx.typeck_results().expr_ty(arg);
if constant_simple(cx, cx.typeck_results(), expr).is_none() && ty.is_integral() {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
INTEGER_OVERFLOW_UNDERFLOW,
expr.span,
Expand Down
1 change: 1 addition & 0 deletions detectors/iterators-over-indexing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { workspace = true }
clippy_wrappers = { workspace = true }
if_chain = { workspace = true }
scout-audit-dylint-linting = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion detectors/iterators-over-indexing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<'tcx> LateLintPass<'tcx> for IteratorOverIndexing {
walk_expr(&mut visitor, body.value);

for span in visitor.span_constant {
clippy_utils::diagnostics::span_lint_and_help(
clippy_wrappers::span_lint_and_help(
cx,
ITERATOR_OVER_INDEXING,
span,
Expand Down
Loading

0 comments on commit 01a2539

Please sign in to comment.