Skip to content

Commit

Permalink
clippy: Add more restrictive lint directives
Browse files Browse the repository at this point in the history
  • Loading branch information
uklotzde committed Jan 29, 2022
1 parent ea8a272 commit 4985c83
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 10 deletions.
22 changes: 21 additions & 1 deletion .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
push:
branches:
- master
- '*'

env:
CARGO_TERM_COLOR: always
Expand All @@ -28,6 +28,11 @@ jobs:
profile: minimal
components: rustfmt, clippy

- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile

- name: Detect code style issues (push)
uses: pre-commit/[email protected]
if: github.event_name == 'push'
Expand All @@ -37,3 +42,18 @@ jobs:
if: github.event_name == 'pull_request'
env:
SKIP: no-commit-to-branch

- name: Generate patch file
if: failure()
run: |
git diff-index -p HEAD > "${PATCH_FILE}"
[ -s "${PATCH_FILE}" ] && echo "UPLOAD_PATCH_FILE=${PATCH_FILE}" >> "${GITHUB_ENV}"
env:
PATCH_FILE: pre-commit.patch

- name: Upload patch artifact
if: failure() && env.UPLOAD_PATCH_FILE != null
uses: actions/upload-artifact@v2
with:
name: ${{ env.UPLOAD_PATCH_FILE }}
path: ${{ env.UPLOAD_PATCH_FILE }}
1 change: 0 additions & 1 deletion .github/workflows/security_audit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
# schedule:
# - cron: '0 0 * * *'

Expand Down
4 changes: 2 additions & 2 deletions src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl From<ResponsePdu> for Result<Response, ExceptionResponse> {
}

impl fmt::Display for Exception {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.description())
}
}
Expand All @@ -248,7 +248,7 @@ impl error::Error for Exception {
}

impl fmt::Display for ExceptionResponse {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Modbus function {}: {}", self.function, self.exception)
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,23 @@
//! - [MODBUS over serial line specification and implementation guide v1.02 (PDF)](http://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf)
//! - [MODBUS Messaging on TCP/IP Implementation Guide v1.0b (PDF)](http://modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf)
#![deny(rust_2018_idioms)]
#![deny(rust_2021_compatibility)]
#![deny(missing_debug_implementations)]
// TODO: Add missing documentation
//#![deny(missing_docs)]
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(clippy::all)]
#![deny(clippy::explicit_deref_methods)]
#![deny(clippy::explicit_into_iter_loop)]
#![deny(clippy::explicit_iter_loop)]
// TODO (v0.6): Decorate functions with #[must_use]
//#![deny(clippy::must_use_candidate)]
#![cfg_attr(not(test), warn(unsafe_code))]
#![cfg_attr(not(test), deny(clippy::panic_in_result_fn))]
#![cfg_attr(not(debug_assertions), deny(warnings))]
#![cfg_attr(not(debug_assertions), deny(clippy::used_underscore_binding))]

pub mod prelude;

pub mod client;
Expand Down
1 change: 1 addition & 0 deletions src/server/rtu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::{io::Error, path::Path};
use tokio_serial::SerialStream;
use tokio_util::codec::Framed;

#[derive(Debug)]
pub struct Server {
serial: SerialStream,
}
Expand Down
14 changes: 9 additions & 5 deletions src/service/rtu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,27 @@ mod tests {
impl AsyncRead for MockTransport {
fn poll_read(
self: Pin<&mut Self>,
_: &mut Context,
_: &mut ReadBuf,
_: &mut Context<'_>,
_: &mut ReadBuf<'_>,
) -> Poll<Result<()>> {
Poll::Ready(Ok(()))
}
}

impl AsyncWrite for MockTransport {
fn poll_write(self: Pin<&mut Self>, _: &mut Context, _: &[u8]) -> Poll<Result<usize>> {
fn poll_write(
self: Pin<&mut Self>,
_: &mut Context<'_>,
_: &[u8],
) -> Poll<Result<usize>> {
Poll::Ready(Ok(2))
}

fn poll_flush(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<()>> {
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<()>> {
Poll::Ready(Ok(()))
}

fn poll_shutdown(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<()>> {
fn poll_shutdown(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<()>> {
unimplemented!()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/slave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl FromStr for Slave {
}

impl fmt::Display for Slave {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} (0x{:0>2X})", self.0, self.0)
}
}
Expand Down

0 comments on commit 4985c83

Please sign in to comment.