mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-06-01 19:43:03 +08:00
Merge pull request #4026 from stacks-network/ci/enable-clippy
Enable clippy in CI
This commit is contained in:
6
.github/workflows/clippy.yml
vendored
6
.github/workflows/clippy.yml
vendored
@@ -1,5 +1,3 @@
|
||||
# Disabled - this workflow needs more work so it's not incredibly chatty
|
||||
##
|
||||
## Perform Clippy checks - currently set to defaults
|
||||
## https://github.com/rust-lang/rust-clippy#usage
|
||||
## https://rust-lang.github.io/rust-clippy/master/index.html
|
||||
@@ -17,10 +15,10 @@ on:
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
- synchronize
|
||||
|
||||
jobs:
|
||||
clippy_check:
|
||||
if: ${{ false }}
|
||||
name: Clippy Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -41,4 +39,4 @@ jobs:
|
||||
uses: actions-rs/clippy-check@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: --all-features
|
||||
args: -p clarity -p libstackerdb -p pox-locking -p stacks-common --no-deps --tests --all-features -- -D warnings
|
||||
|
||||
@@ -216,7 +216,7 @@ impl CheckError {
|
||||
|
||||
pub fn set_expressions(&mut self, exprs: &[SymbolicExpression]) {
|
||||
self.diagnostic.spans = exprs.iter().map(|e| e.span().clone()).collect();
|
||||
self.expressions.replace(exprs.clone().to_vec());
|
||||
self.expressions.replace(exprs.to_vec());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1441,7 +1441,7 @@ fn test_response_inference() {
|
||||
fn test_function_arg_names() {
|
||||
use crate::vm::analysis::type_check;
|
||||
|
||||
let functions = vec![
|
||||
let functions = [
|
||||
"(define-private (test (x int)) (ok 0))
|
||||
(define-public (test-pub (x int)) (ok 0))
|
||||
(define-read-only (test-ro (x int)) (ok 0))",
|
||||
|
||||
@@ -2239,7 +2239,7 @@ fn test_response_inference(#[case] version: ClarityVersion, #[case] epoch: Stack
|
||||
fn test_function_arg_names() {
|
||||
use crate::vm::analysis::type_check;
|
||||
|
||||
let functions = vec![
|
||||
let functions = [
|
||||
"(define-private (test (x int)) (ok 0))
|
||||
(define-public (test-pub (x int)) (ok 0))
|
||||
(define-read-only (test-ro (x int)) (ok 0))",
|
||||
|
||||
@@ -44,7 +44,7 @@ use crate::vm::types::QualifiedContractIdentifier;
|
||||
use crate::vm::ClarityVersion;
|
||||
|
||||
/// Legacy function
|
||||
#[cfg(any(test, features = "testing"))]
|
||||
#[cfg(any(test, feature = "testing"))]
|
||||
pub fn parse(
|
||||
contract_identifier: &QualifiedContractIdentifier,
|
||||
source_code: &str,
|
||||
|
||||
@@ -132,11 +132,11 @@ lazy_static! {
|
||||
|
||||
static ref lex_matchers: Vec<LexMatcher> = vec![
|
||||
LexMatcher::new(
|
||||
r##"u"(?P<value>((\\")|([[ -~]&&[^"]]))*)""##,
|
||||
r#"u"(?P<value>((\\")|([[ -~]&&[^"]]))*)""#,
|
||||
TokenType::StringUTF8Literal,
|
||||
),
|
||||
LexMatcher::new(
|
||||
r##""(?P<value>((\\")|([[ -~]&&[^"]]))*)""##,
|
||||
r#""(?P<value>((\\")|([[ -~]&&[^"]]))*)""#,
|
||||
TokenType::StringASCIILiteral,
|
||||
),
|
||||
LexMatcher::new(";;[ -~]*", TokenType::Whitespace), // ;; comments.
|
||||
|
||||
@@ -236,7 +236,7 @@ impl<'a> Parser<'a> {
|
||||
Token::Rparen => {
|
||||
span.end_line = token.span.end_line;
|
||||
span.end_column = token.span.end_column;
|
||||
let out_nodes: Vec<_> = nodes.drain(..).collect();
|
||||
let out_nodes: Vec<_> = std::mem::take(nodes);
|
||||
let mut e = PreSymbolicExpression::list(out_nodes.into_boxed_slice());
|
||||
e.copy_span(span);
|
||||
Ok(Some(e))
|
||||
@@ -253,7 +253,7 @@ impl<'a> Parser<'a> {
|
||||
)?;
|
||||
span.end_line = token.span.end_line;
|
||||
span.end_column = token.span.end_column;
|
||||
let out_nodes: Vec<_> = nodes.drain(..).collect();
|
||||
let out_nodes: Vec<_> = std::mem::take(nodes);
|
||||
let mut e = PreSymbolicExpression::list(out_nodes.into_boxed_slice());
|
||||
e.copy_span(span);
|
||||
Ok(Some(e))
|
||||
|
||||
@@ -107,9 +107,7 @@ impl PeerAddress {
|
||||
/// order. Return None if this is not an IPv4 address.
|
||||
pub fn ipv4_bits(&self) -> Option<u32> {
|
||||
let octets_opt = self.ipv4_octets();
|
||||
if octets_opt.is_none() {
|
||||
return None;
|
||||
}
|
||||
octets_opt?;
|
||||
|
||||
let octets = octets_opt.unwrap();
|
||||
Some(
|
||||
@@ -291,8 +289,8 @@ impl FromStr for PeerHost {
|
||||
// try as DNS-name:port
|
||||
let host;
|
||||
let port;
|
||||
let parts: Vec<&str> = header.split(":").collect();
|
||||
if parts.len() == 0 {
|
||||
let parts: Vec<&str> = header.split(':').collect();
|
||||
if parts.is_empty() {
|
||||
return Err(Error::DecodeError(
|
||||
"Failed to parse PeerHost: no parts".to_string(),
|
||||
));
|
||||
@@ -305,7 +303,7 @@ impl FromStr for PeerHost {
|
||||
if parts[np - 1].chars().all(char::is_numeric) {
|
||||
// ends in :port
|
||||
let host_str = parts[0..np - 1].join(":");
|
||||
if host_str.len() == 0 {
|
||||
if host_str.is_empty() {
|
||||
return Err(Error::DecodeError("Empty host".to_string()));
|
||||
}
|
||||
host = Some(host_str);
|
||||
|
||||
@@ -605,20 +605,15 @@ pub fn hex_bytes(s: &str) -> Result<Vec<u8>, HexError> {
|
||||
let mut v = vec![];
|
||||
let mut iter = s.chars().pair();
|
||||
// Do the parsing
|
||||
iter.by_ref().fold(Ok(()), |e, (f, s)| {
|
||||
if e.is_err() {
|
||||
e
|
||||
} else {
|
||||
match (f.to_digit(16), s.to_digit(16)) {
|
||||
(None, _) => Err(HexError::BadCharacter(f)),
|
||||
(_, None) => Err(HexError::BadCharacter(s)),
|
||||
(Some(f), Some(s)) => {
|
||||
v.push((f * 0x10 + s) as u8);
|
||||
Ok(())
|
||||
}
|
||||
iter.by_ref()
|
||||
.try_fold((), |_, (f, s)| match (f.to_digit(16), s.to_digit(16)) {
|
||||
(None, _) => Err(HexError::BadCharacter(f)),
|
||||
(_, None) => Err(HexError::BadCharacter(s)),
|
||||
(Some(f), Some(s)) => {
|
||||
v.push((f * 0x10 + s) as u8);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
})?;
|
||||
})?;
|
||||
// Check that there was no remainder
|
||||
match iter.remainder() {
|
||||
Some(_) => Err(HexError::BadLength(s.len())),
|
||||
|
||||
@@ -238,8 +238,7 @@ fn make_logger() -> Logger {
|
||||
let plain = slog_term::PlainSyncDecorator::new(slog_term::TestStdoutWriter);
|
||||
let isatty = isatty(Stream::Stdout);
|
||||
let drain = TermFormat::new(plain, false, debug, isatty);
|
||||
let logger = Logger::root(drain.ignore_res(), o!());
|
||||
logger
|
||||
Logger::root(drain.ignore_res(), o!())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -355,11 +355,10 @@ macro_rules! impl_array_newtype {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "clippy", allow(expl_impl_clone_on_copy))] // we don't define the `struct`, we have to explicitly impl
|
||||
impl Clone for $thing {
|
||||
#[inline]
|
||||
fn clone(&self) -> $thing {
|
||||
$thing::from(&self[..])
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -402,8 +402,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_connection_pipe_producer_consumer() {
|
||||
let mut buf = Vec::new();
|
||||
buf.resize(1048576, 0);
|
||||
let mut buf = vec![0; 1048576];
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
rng.fill_bytes(&mut buf);
|
||||
|
||||
Reference in New Issue
Block a user