Skip to content

Commit 3672547

Browse files
authored
Merge pull request #14 from internet2-org/lints
Fixing all lints
2 parents 3d76d01 + 6c96252 commit 3672547

31 files changed

+452
-470
lines changed

.github/workflows/lint.yml

+32-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,44 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v2
17-
- name: Install latest nightly
17+
- name: Install rustc nightly
1818
uses: actions-rs/toolchain@v1
1919
with:
2020
toolchain: nightly
2121
override: true
2222
components: rustfmt
2323
- uses: actions-rs/cargo@v1
24-
name: Lints
24+
name: Formatting
2525
with:
2626
command: fmt
2727
args: --all -- --check
28+
clippy:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v2
32+
- name: Install rustc stable
33+
uses: actions-rs/toolchain@v1
34+
with:
35+
toolchain: stable
36+
override: true
37+
components: clippy
38+
- uses: actions-rs/cargo@v1
39+
name: Clippy
40+
with:
41+
command: clippy
42+
args: --workspace --all-features
43+
doc:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v2
47+
- name: Install rustc nightly
48+
uses: actions-rs/toolchain@v1
49+
with:
50+
toolchain: nightly
51+
override: true
52+
components: rust-docs
53+
- uses: actions-rs/cargo@v1
54+
name: Clippy
55+
with:
56+
command: doc
57+
args: --workspace --all-features

.rustfmt.toml

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
max_width = 80
2-
wrap_comments = true
32
format_code_in_doc_comments = true
3+
fn_single_line = true
4+
format_macro_matchers = true
5+
format_strings = true
6+
merge_derives = false
7+
imports_granularity = "Module"
8+
overflow_delimited_expr = true
9+
group_imports = "StdExternalCrate"
10+
use_field_init_shorthand = true
11+
use_try_shorthand = true
12+
wrap_comments = true
13+
comment_width = 80
14+
unstable_features = true

Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ name = "internet2"
1717
path = "src/lib.rs"
1818
crate-type = ["rlib", "staticlib"]
1919

20+
[[test]]
21+
name = "noise_xk"
22+
path = "tests/noise_xk.rs"
23+
required-features = ["keygen"]
24+
2025
# Dependencies
2126
# ============
2227
[dependencies]

addr/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Internet2 addresses crate
22

3-
Internet2 addresses with support for Tor v2, v3.
3+
Internet2 addresses with support for Tor v3.

addr/src/encoding.rs

+14-32
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Internet2 addresses with support for Tor v2, v3
1+
// Internet2 addresses with support for Tor v3
22
//
3-
// Written in 2019-2020 by
3+
// Written in 2019-2021 by
44
// Dr. Maxim Orlovsky <[email protected]>
55
// Martin Habovstiak <[email protected]>
66
//
@@ -14,12 +14,12 @@
1414
// If not, see <https://opensource.org/licenses/MIT>.
1515

1616
use std::net::{Ipv4Addr, Ipv6Addr};
17-
#[cfg(feature = "tor")]
18-
use torut::onion::{TorPublicKeyV3, TORV3_PUBLIC_KEY_LENGTH};
1917

2018
use strict_encoding::net::{
2119
AddrFormat, DecodeError, RawAddr, Transport, Uniform, UniformAddr, ADDR_LEN,
2220
};
21+
#[cfg(feature = "tor")]
22+
use torut::onion::{TorPublicKeyV3, TORV3_PUBLIC_KEY_LENGTH};
2323

2424
use crate::{InetAddr, InetSocketAddr, InetSocketAddrExt};
2525

@@ -61,14 +61,10 @@ impl Uniform for InetAddr {
6161
}
6262

6363
#[inline]
64-
fn port(&self) -> Option<u16> {
65-
None
66-
}
64+
fn port(&self) -> Option<u16> { None }
6765

6866
#[inline]
69-
fn transport(&self) -> Option<Transport> {
70-
None
71-
}
67+
fn transport(&self) -> Option<Transport> { None }
7268

7369
#[inline]
7470
fn from_uniform_addr(addr: UniformAddr) -> Result<Self, DecodeError>
@@ -95,31 +91,23 @@ impl Uniform for InetAddr {
9591
}
9692
#[cfg(feature = "tor")]
9793
AddrFormat::OnionV3 => InetAddr::Tor(tor_from_raw_addr(addr.addr)?),
98-
_ => Err(DecodeError::UnsupportedAddrFormat)?,
94+
_ => return Err(DecodeError::UnsupportedAddrFormat),
9995
})
10096
}
10197
}
10298

10399
impl Uniform for InetSocketAddr {
104100
#[inline]
105-
fn addr_format(&self) -> AddrFormat {
106-
self.address.addr_format()
107-
}
101+
fn addr_format(&self) -> AddrFormat { self.address.addr_format() }
108102

109103
#[inline]
110-
fn addr(&self) -> RawAddr {
111-
self.address.addr()
112-
}
104+
fn addr(&self) -> RawAddr { self.address.addr() }
113105

114106
#[inline]
115-
fn port(&self) -> Option<u16> {
116-
Some(self.port)
117-
}
107+
fn port(&self) -> Option<u16> { Some(self.port) }
118108

119109
#[inline]
120-
fn transport(&self) -> Option<Transport> {
121-
None
122-
}
110+
fn transport(&self) -> Option<Transport> { None }
123111

124112
#[inline]
125113
fn from_uniform_addr(addr: UniformAddr) -> Result<Self, DecodeError>
@@ -148,19 +136,13 @@ impl Uniform for InetSocketAddr {
148136

149137
impl Uniform for InetSocketAddrExt {
150138
#[inline]
151-
fn addr_format(&self) -> AddrFormat {
152-
self.1.addr_format()
153-
}
139+
fn addr_format(&self) -> AddrFormat { self.1.addr_format() }
154140

155141
#[inline]
156-
fn addr(&self) -> RawAddr {
157-
self.1.addr()
158-
}
142+
fn addr(&self) -> RawAddr { self.1.addr() }
159143

160144
#[inline]
161-
fn port(&self) -> Option<u16> {
162-
Some(self.1.port)
163-
}
145+
fn port(&self) -> Option<u16> { Some(self.1.port) }
164146

165147
#[inline]
166148
fn transport(&self) -> Option<Transport> {

0 commit comments

Comments
 (0)