fix cyclomatic complexity lint triggering because of short circuit operations

This commit is contained in:
Oliver Schneider
2016-03-08 15:10:02 +01:00
parent 08b7931b6b
commit bf20b40664
5 changed files with 45 additions and 27 deletions

View File

@@ -1,4 +1,3 @@
#![allow(cyclomatic_complexity)]
use rustc::lint::*;
use rustc_front::hir::*;
use utils::{span_lint};
@@ -38,12 +37,12 @@ impl LateLintPass for OverflowCheckConditional {
], {
if let BinOp_::BiLt = op.node {
if let BinOp_::BiAdd = op2.node {
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span, "You are trying to use classic C overflow conditons that will fail in Rust.");
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span, "You are trying to use classic C overflow conditions that will fail in Rust.");
}
}
if let BinOp_::BiGt = op.node {
if let BinOp_::BiSub = op2.node {
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span, "You are trying to use classic C underflow conditons that will fail in Rust.");
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span, "You are trying to use classic C underflow conditions that will fail in Rust.");
}
}
}}
@@ -60,12 +59,12 @@ impl LateLintPass for OverflowCheckConditional {
], {
if let BinOp_::BiGt = op.node {
if let BinOp_::BiAdd = op2.node {
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span, "You are trying to use classic C overflow conditons that will fail in Rust.");
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span, "You are trying to use classic C overflow conditions that will fail in Rust.");
}
}
if let BinOp_::BiLt = op.node {
if let BinOp_::BiSub = op2.node {
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span, "You are trying to use classic C underflow conditons that will fail in Rust.");
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span, "You are trying to use classic C underflow conditions that will fail in Rust.");
}
}
}}