fix: address `clippy::pedantic` lints
This commit is contained in:
parent
2df4fb2efe
commit
d23ef5f6bd
|
@ -9,7 +9,7 @@ const LOCALHOST_ADDRS: &[&str] = &[
|
|||
"broadcasthost",
|
||||
];
|
||||
|
||||
pub fn format_to_unbound(raw_hosts: String, ipv4_addr: &str, ipv6_addr: &str) -> Vec<String> {
|
||||
pub fn format_to_unbound(raw_hosts: &str, ipv4_addr: &str, ipv6_addr: &str) -> Vec<String> {
|
||||
let mut output: Vec<String> = vec![String::from("server:")];
|
||||
let re = Regex::new(REGEX_PATTERN).unwrap();
|
||||
for line in raw_hosts.lines() {
|
||||
|
@ -27,7 +27,7 @@ pub fn format_to_unbound(raw_hosts: String, ipv4_addr: &str, ipv6_addr: &str) ->
|
|||
output
|
||||
}
|
||||
|
||||
pub fn format_to_dnsmasq_server(raw_hosts: String) -> Vec<String> {
|
||||
pub fn format_to_dnsmasq_server(raw_hosts: &str) -> Vec<String> {
|
||||
let mut output: Vec<String> = vec![];
|
||||
let re = Regex::new(REGEX_PATTERN).unwrap();
|
||||
for line in raw_hosts.lines() {
|
||||
|
@ -43,7 +43,7 @@ pub fn format_to_dnsmasq_server(raw_hosts: String) -> Vec<String> {
|
|||
output
|
||||
}
|
||||
|
||||
pub fn format_to_dnsmasq(raw_hosts: String, ipv4_addr: &str, ipv6_addr: &str) -> Vec<String> {
|
||||
pub fn format_to_dnsmasq(raw_hosts: &str, ipv4_addr: &str, ipv6_addr: &str) -> Vec<String> {
|
||||
let mut output: Vec<String> = vec![];
|
||||
let re = Regex::new(REGEX_PATTERN).unwrap();
|
||||
for line in raw_hosts.lines() {
|
||||
|
@ -69,7 +69,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_dnsmasq_formatter() {
|
||||
let results = format_to_dnsmasq(emit_hosts_file(), "127.0.0.1", "::1");
|
||||
let results = format_to_dnsmasq(&emit_hosts_file(), "127.0.0.1", "::1");
|
||||
assert!(results.contains(&String::from("address=/adserver.abv.bg/127.0.0.1")));
|
||||
assert!(results.contains(&String::from("address=/adserver.abv.bg/::1")));
|
||||
assert!(!results.contains(&String::from("# Leading comment test 0.0.0.0 fr.a2dfp.net")));
|
||||
|
@ -79,7 +79,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_dnsmasq_server_formatter() {
|
||||
let results = format_to_dnsmasq_server(emit_hosts_file());
|
||||
let results = format_to_dnsmasq_server(&emit_hosts_file());
|
||||
assert!(results.contains(&String::from("server=/adserver.abv.bg/")));
|
||||
assert!(results.contains(&String::from("server=/adserver.abv.bg/")));
|
||||
assert!(!results.contains(&String::from("# Leading comment test 0.0.0.0 fr.a2dfp.net")));
|
||||
|
@ -89,7 +89,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_unbound_formatter() {
|
||||
let results = format_to_unbound(emit_hosts_file(), "127.0.0.1", "::1");
|
||||
let results = format_to_unbound(&emit_hosts_file(), "127.0.0.1", "::1");
|
||||
assert!(results.contains(&String::from(" local-zone: adserver.abv.bg A 127.0.0.1")));
|
||||
assert!(results.contains(&String::from(" local-zone: adserver.abv.bg AAAA ::1")));
|
||||
assert!(!results.contains(&String::from(
|
||||
|
|
|
@ -55,8 +55,8 @@ fn parse_sources_config_file(filepath: &str) -> HashMap<String, Source> {
|
|||
if let Ok(file) = File::open(filepath) {
|
||||
BufReader::new(file)
|
||||
.lines()
|
||||
.filter(|result| result.is_ok())
|
||||
.map(|result| result.unwrap())
|
||||
.filter(std::result::Result::is_ok)
|
||||
.map(std::result::Result::unwrap)
|
||||
.for_each(|line| {
|
||||
let vec: Vec<&str> = line.split('|').collect();
|
||||
list.insert(
|
||||
|
|
|
@ -13,16 +13,16 @@ impl Source {
|
|||
|
||||
pub fn format_to_dnsmasq(&self, ipv4_addr: &str, ipv6_addr: &str) -> Vec<String> {
|
||||
let raw_hosts = self.download_to_string().unwrap();
|
||||
formatters::format_to_dnsmasq(raw_hosts, ipv4_addr, ipv6_addr)
|
||||
formatters::format_to_dnsmasq(&raw_hosts, ipv4_addr, ipv6_addr)
|
||||
}
|
||||
|
||||
pub fn format_to_dnsmasq_server(&self) -> Vec<String> {
|
||||
let raw_hosts = self.download_to_string().unwrap();
|
||||
formatters::format_to_dnsmasq_server(raw_hosts)
|
||||
formatters::format_to_dnsmasq_server(&raw_hosts)
|
||||
}
|
||||
|
||||
pub fn format_to_unbound(&self, ipv4_addr: &str, ipv6_addr: &str) -> Vec<String> {
|
||||
let raw_hosts = self.download_to_string().unwrap();
|
||||
formatters::format_to_unbound(raw_hosts, ipv4_addr, ipv6_addr)
|
||||
formatters::format_to_unbound(&raw_hosts, ipv4_addr, ipv6_addr)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue