Skip to content

Commit

Permalink
Update forbid script (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Sep 4, 2024
1 parent 7a0a5f1 commit dcd421e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ jobs:
- name: Clippy
run: cargo clippy --all-targets --all-features

- name: Lint
- name: Check for Forbidden Words
if: matrix.target == 'x86_64-apple-darwin'
run: |
brew install ripgrep
./bin/lint
./bin/forbid
- name: Check Formatting
run: cargo fmt --all -- --check
Expand Down
11 changes: 11 additions & 0 deletions bin/forbid
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -euxo pipefail

which rg

! rg \
--glob !bin/forbid \
--glob !CHANGELOG.md \
--ignore-case \
'dbg!|fixme|todo|xxx'
8 changes: 0 additions & 8 deletions bin/lint

This file was deleted.

6 changes: 3 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ clippy:
fmt:
cargo +nightly fmt --all

lint:
./bin/lint
forbid:
./bin/forbid

preview-readme:
grip -b README.md
Expand All @@ -64,7 +64,7 @@ gen:
check-minimal-versions:
./bin/check-minimal-versions

check: test clippy lint check-minimal-versions gen
check: test clippy forbid check-minimal-versions gen
git diff --no-ext-diff --quiet --exit-code
cargo +nightly fmt --all -- --check

Expand Down
2 changes: 1 addition & 1 deletion src/peer/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Message {
//
// where prefix is the network byte order encoding of `x + 1` into a u32.
pub(crate) fn serialize(&self) -> Result<Vec<u8>> {
// TODO: find a way to test this without blowing the stack.
// find a way to test this without blowing the stack.
let message_length = self.len().try_into().context(error::PeerMessagePayload)?;
let mut buf: Vec<u8> = u32::to_be_bytes(message_length).to_vec();
buf.push(self.flavour.into());
Expand Down
2 changes: 1 addition & 1 deletion src/peer/message/extended/ut_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ mod tests {
let mut msg = bendy::serde::ser::to_bytes(&req).unwrap();
let benc = b"d8:msg_typei1e5:piecei1ee";
assert_eq!(benc, &*msg);
msg.extend_from_slice(b"piece data goes here xxxx...");
msg.extend_from_slice(b"piece data goes here...");
let req2 = bendy::serde::de::from_bytes(&msg).unwrap();
assert_eq!(req, req2);
}
Expand Down
4 changes: 2 additions & 2 deletions src/tracker/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ impl Client {

pub fn connect<A: ToSocketAddrs>(address: A) -> Result<Self> {
let addrs = address
.to_socket_addrs() // XXX: this may cause DNS look-ups!
.to_socket_addrs() // this may cause DNS look-ups!
.context(error::TrackerSocketAddrs)?;

for tracker_addr in addrs {
let Ok(sock) = Self::new_udp_socket(tracker_addr) else {
continue; // TODO: log these as warnings
continue; // log these as warnings
};
let mut client = Client {
peer_id: rand::thread_rng().gen(),
Expand Down

0 comments on commit dcd421e

Please sign in to comment.