@@ -575,14 +575,14 @@ impl LimitStack {
|
|||||||
|
|
||||||
fn parse_attrs<F: FnMut(u64)>(sess: &Session, attrs: &[ast::Attribute], name: &'static str, mut f: F) {
|
fn parse_attrs<F: FnMut(u64)>(sess: &Session, attrs: &[ast::Attribute], name: &'static str, mut f: F) {
|
||||||
for attr in attrs {
|
for attr in attrs {
|
||||||
let attr = &attr.node;
|
if attr.node.is_sugared_doc {
|
||||||
if attr.is_sugared_doc {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let ast::MetaItemKind::NameValue(ref key, ref value) = attr.value.node {
|
if let ast::MetaItemKind::NameValue(ref key, ref value) = attr.node.value.node {
|
||||||
if *key == name {
|
if *key == name {
|
||||||
if let LitKind::Str(ref s, _) = value.node {
|
if let LitKind::Str(ref s, _) = value.node {
|
||||||
if let Ok(value) = FromStr::from_str(s) {
|
if let Ok(value) = FromStr::from_str(s) {
|
||||||
|
attr::mark_used(attr);
|
||||||
f(value)
|
f(value)
|
||||||
} else {
|
} else {
|
||||||
sess.span_err(value.span, "not a number");
|
sess.span_err(value.span, "not a number");
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#![deny(cyclomatic_complexity)]
|
#![deny(cyclomatic_complexity)]
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
|
|
||||||
|
|
||||||
fn main() { //~ERROR the function has a cyclomatic complexity of 28
|
fn main() { //~ERROR the function has a cyclomatic complexity of 28
|
||||||
if true {
|
if true {
|
||||||
println!("a");
|
println!("a");
|
||||||
|
|||||||
17
tests/compile-fail/cyclomatic_complexity_attr_used.rs
Normal file
17
tests/compile-fail/cyclomatic_complexity_attr_used.rs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#![feature(plugin, custom_attribute)]
|
||||||
|
#![plugin(clippy)]
|
||||||
|
#![deny(cyclomatic_complexity)]
|
||||||
|
#![deny(unused)]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
kaboom();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cyclomatic_complexity = "0"]
|
||||||
|
fn kaboom() { //~ ERROR: the function has a cyclomatic complexity of 3
|
||||||
|
if 42 == 43 {
|
||||||
|
panic!();
|
||||||
|
} else if "cake" == "lie" {
|
||||||
|
println!("what?");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user