-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Clippy fixes v2 #10124
Clippy fixes v2 #10124
Conversation
Which will be optimized away by the compiler
using panic! instead with a string message
Coming from old test_case crate warning: unneeded unit expression --> src/bittorrent_dht/parser.rs:590:5 | 590 | / #[test_case( 591 | | b"", 592 | | "Error: discovered Dict but expected EOF" ; 593 | | "test parse bittorrent dht packet err 1" 594 | | )] | |______^
warning: this is a decimal constant --> src/mqtt/parser.rs:888:19 | 888 | 0x00, 06, /* Topic Length: 6 */ | ^^ |
warning: calls to `push` immediately after creation --> src/pgsql/parser.rs:1179:9 | 1179 | / let mut database_param: Vec<PgsqlParameter> = Vec::new(); 1180 | | database_param.push(database); | |______________________________________^ help: consider using the `vec![]` macro: `let database_param: Vec<PgsqlParameter> = vec![..];`
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> src/http2/parser.rs:882:17 | 882 | / match ctx.value { 883 | | Some(_) => { 884 | | panic!("Unexpected value"); 885 | | } 886 | | None => {} 887 | | } | |_________________^
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #10124 +/- ##
==========================================
+ Coverage 82.15% 82.16% +0.01%
==========================================
Files 974 974
Lines 271925 271856 -69
==========================================
- Hits 223394 223373 -21
+ Misses 48531 48483 -48
Flags with carried forward coverage won't be shown. Click here to find out more. |
if let Some(txp) = parse_tftp_request(&READ_REQUEST[..]) { | ||
assert_eq!(tx, txp); | ||
} else { | ||
panic!("Result should not be None"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In tests I prefer:
let txp = parse_tftp_request(&READ_REQUEST[..]).unwrap();
assert_eq!(tx, txp);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
if let Ok((_, val)) = parse_bytemath("bytes 4, offset 3933, oper +, rvalue myrvalue, result foo, string hex") { | ||
assert_eq!(val, bmd); | ||
} else { | ||
panic!("Result shoud be ok"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, could just unwrap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed
if parser::parse_dcerpc_udp_header(request).is_ok() { | ||
panic!("Result shoud not be ok"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert!(parser::parser_dcerpc_udp_header(request).is_err());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to see this ints being fixed up, but I think we should opt for asserts and even unwraps/expects before conditional panics.
Information: QA ran without warnings. Pipeline 17375 |
Replaces by #10129, thanks Jason for the review |
Link to redmine ticket:
None
Describe changes:
@jasonish why do I get these and CI is not red ?
Is this because the lint level to deny warnings does not apply to test code ?
#10113 rebased and more commits
Only 19 match_single_binding warnings remaining