Skip to content
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

Introduce Clippy Github Actions #439

Merged
merged 19 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Clippy

on: [push, pull_request]

jobs:
linux-clippy:
name: Linux
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install Toolchain
uses: actions-rs/toolchain@v1
with:
components: clippy
override: true
profile: minimal
toolchain: 1.32.0
- name: Run `cargo clippy`
uses: actions-rs/cargo@v1
with:
command: clippy
args: --features "serde slog std v1 v3 v4 v5" -- -D warnings
windows-clippy:
name: Windows
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install Toolchain
uses: actions-rs/toolchain@v1
with:
components: clippy
override: true
profile: minimal
toolchain: 1.32.0
- name: Run `cargo clippy`
uses: actions-rs/cargo@v1
with:
command: clippy
args: --features "guid serde slog std v1 v3 v4 v5" -- -D warnings
kinggoesgaming marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ matrix:
- cargo web build --features "v5 wasm-bindgen"
- rust: stable
env:
- LABEL="clippy + wasm"
- LABEL="wasm"
before_script:
- rustup component add clippy-preview
- rustup target add wasm32-unknown-unknown
script:
- cargo clippy --features "v1 v3 v4 v5 slog"
- cargo build --target wasm32-unknown-unknown --features "v3 wasm-bindgen"
- cargo build --target wasm32-unknown-unknown --features "v4 wasm-bindgen"
- cargo build --target wasm32-unknown-unknown --features "v5 wasm-bindgen"
Expand Down
1 change: 1 addition & 0 deletions src/adapter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ const HYPHEN_POSITIONS: [usize; 4] = [8, 13, 18, 23];
/// The `start` parameter allows writing a prefix (such as
/// "urn:uuid:") to the buffer that's included in the final encoded
/// UUID.
#[allow(clippy::needless_range_loop)]
fn encode<'a>(
full_buffer: &'a mut [u8],
start: usize,
Expand Down
4 changes: 1 addition & 3 deletions src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,6 @@ impl Builder {
///
/// [`Uuid`]: struct.Uuid.html
pub fn build(&mut self) -> Uuid {
let uuid = Uuid::from_bytes(self.0);

uuid
Uuid::from_bytes(self.0)
}
}
1 change: 1 addition & 0 deletions src/parser/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::std::fmt;
///
/// [`Uuid`]: ../struct.Uuid.html
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[allow(clippy::enum_variant_names)]
pub(crate) enum Error {
/// Invalid character in the [`Uuid`] string.
///
Expand Down
2 changes: 1 addition & 1 deletion src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn len_matches_any(len: usize, crits: &[usize]) -> bool {
/// (inclusive).
#[allow(dead_code)]
fn len_matches_range(len: usize, min: usize, max: usize) -> bool {
for crit in min..(max + 1) {
for crit in min..=max {
if len == crit {
return true;
}
Expand Down
9 changes: 5 additions & 4 deletions src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ impl Timestamp {
let counter = context.generate_sequence(seconds, subsec_nanos);
let ticks = UUID_TICKS_BETWEEN_EPOCHS
+ seconds * 10_000_000
+ (subsec_nanos as u64 / 100);
+ u64::from(subsec_nanos) / 100;

Timestamp { ticks, counter }
}

Expand All @@ -99,10 +100,10 @@ impl Timestamp {
/// thus the maximum precision represented by the fractional nanoseconds
/// value is less than its unit size (100 ns vs. 1 ns).
pub const fn to_unix(&self) -> (u64, u32) {
let unix_ticks = self.ticks - UUID_TICKS_BETWEEN_EPOCHS;
(
unix_ticks / 10_000_000,
(unix_ticks % 10_000_000) as u32 * 100,
(self.ticks - UUID_TICKS_BETWEEN_EPOCHS) / 10_000_000,
((self.ticks - UUID_TICKS_BETWEEN_EPOCHS) % 10_000_000) as u32
* 100,
)
}

Expand Down