Add semicolon_if_nothing_returned clippy lint

This commit is contained in:
Fabrice Reix 2024-02-29 08:31:04 +01:00
parent 10861aa4bc
commit 84baecf464
No known key found for this signature in database
GPG Key ID: BF5213154B2E7155
43 changed files with 173 additions and 173 deletions

View File

@ -4,6 +4,6 @@ set -Eeuo pipefail
cargo clippy -- \
--deny warnings \
--deny clippy::empty_structs_with_brackets \
--deny clippy::manual_string_new
--deny clippy::manual_string_new \
--deny clippy::semicolon_if_nothing_returned

View File

@ -88,7 +88,7 @@ fn log_request(request: Request) {
for param in multipart_params {
match param {
MultipartParam::Param(value) => {
eprintln!("\r{}: {}", value.key, value.value)
eprintln!("\r{}: {}", value.key, value.value);
}
MultipartParam::FileParam(file_param) => {
let content_type =

View File

@ -131,6 +131,6 @@ mod tests {
assert_eq!(
parse_value("\"123").err().unwrap(),
OptionsError::Error("Value should end with a double quote".to_string())
)
);
}
}

View File

@ -51,7 +51,7 @@ mod tests {
),
];
for (input, output) in tests.iter() {
assert_eq!(html_escape(input), output.to_string())
assert_eq!(html_escape(input), output.to_string());
}
}
}

View File

@ -160,7 +160,7 @@ mod tests {
#[test]
fn test_html_unescape() {
fn check(text: &str, expected: &str) {
assert_eq!(html_unescape(text), expected.to_string())
assert_eq!(html_unescape(text), expected.to_string());
}
fn check_num(num: usize, expected: &str) {
@ -194,7 +194,7 @@ mod tests {
// Check incomplete entities at the end of the string
for x in ["&", "&#", "&#x", "&#X", "&#y", "&#xy", "&#Xy"].iter() {
check(x, x);
check(&format!("{x};"), &format!("{x};"))
check(&format!("{x};"), &format!("{x};"));
}
// Check several combinations of numeric character references,
@ -436,7 +436,7 @@ mod tests {
// Check invalid numbers
for (num, ch) in [(0x0d, "\r"), (0x80, "\u{20ac}"), (0x95, "\u{2022}")] {
check_num(num, ch)
check_num(num, ch);
}
// Check small numbers
@ -448,26 +448,26 @@ mod tests {
// Check that multiple trailing semicolons are handled correctly
for e in ["";", "";", "";", "";"] {
check(e, "\";")
check(e, "\";");
}
// Check that semicolons in the middle don't create problems
for e in [""quot;", ""quot;", ""quot;", ""quot;"] {
check(e, "\"quot;")
check(e, "\"quot;");
}
// Check triple adjacent charrefs
for e in ["&quot", "&#34", "&#x22", "&#X22"] {
// check(&e.repeat(3), "\"\"\"");
check(&format!("{e};").repeat(3), "\"\"\"")
check(&format!("{e};").repeat(3), "\"\"\"");
}
// Check that the case is respected
for e in ["&amp", "&", "&AMP", "&"] {
check(e, "&")
check(e, "&");
}
for e in ["&Amp", "&Amp;"] {
check(e, e)
check(e, e);
}
// Check that nonexistent named entities are returned unchanged
@ -499,6 +499,6 @@ mod tests {
"&EacutericÉric&alphacentauriαcentauri",
"ÉricÉric&alphacentauriαcentauri",
);
check("&co;", "&co;")
check("&co;", "&co;");
}
}

View File

@ -177,7 +177,7 @@ mod tests {
chrono::DateTime::parse_from_rfc2822("Tue, 10 Jan 2023 08:29:52 GMT")
.unwrap()
.with_timezone(&chrono::Utc)
)
);
}
#[test]
@ -200,7 +200,7 @@ mod tests {
assert_eq!(
parse_serial_number(&attributes).unwrap(),
"1e:e8:b1:7f:1b:64:d8:d6:b3:de:87:01:03:d2:a4:f5:33:53:5a:b0".to_string()
)
);
}
#[test]

View File

@ -237,7 +237,7 @@ impl Client {
if s.starts_with("HTTP/") {
status_lines.push(s);
} else {
response_headers.push(s)
response_headers.push(s);
}
}
true
@ -588,7 +588,7 @@ impl Client {
// from libcurl::FormError to HttpError
match param {
MultipartParam::Param(Param { name, value }) => {
form.part(name).contents(value.as_bytes()).add().unwrap()
form.part(name).contents(value.as_bytes()).add().unwrap();
}
MultipartParam::FileParam(FileParam {
name,

View File

@ -59,9 +59,9 @@ pub fn log_text(text: &str, debug: bool, logger: &Logger) {
} else {
let lines = text.split('\n');
if debug {
lines.for_each(|l| logger.debug(l))
lines.for_each(|l| logger.debug(l));
} else {
lines.for_each(|l| logger.info(l))
lines.for_each(|l| logger.info(l));
}
}
}
@ -82,6 +82,6 @@ pub fn log_bytes(bytes: &[u8], max: usize, debug: bool, logger: &Logger) {
if debug {
logger.debug(&log);
} else {
logger.info(&log)
logger.info(&log);
}
}

View File

@ -192,7 +192,7 @@ fn to_list(slist: *mut curl_slist) -> Vec<String> {
let ret = CStr::from_ptr((*cur).data).to_bytes();
let value = String::from_utf8_lossy(ret);
data.push(value.to_string());
cur = (*cur).next
cur = (*cur).next;
}
}
data

View File

@ -94,7 +94,7 @@ impl HeaderVec {
where
F: FnMut(&Header) -> bool,
{
self.headers.retain(|h| f(h))
self.headers.retain(|h| f(h));
}
/// Returns an iterator over all the headers.
@ -117,7 +117,7 @@ impl HeaderVec {
/// Push a new `header` into the headers list.
pub fn push(&mut self, header: Header) {
self.headers.push(header)
self.headers.push(header);
}
/// Returns all headers values.
@ -180,7 +180,7 @@ mod tests {
#[test]
fn test_iter() {
let data = vec![("foo", "xxx"), ("bar", "yyy0"), ("baz", "yyy1")];
let data = [("foo", "xxx"), ("bar", "yyy0"), ("baz", "yyy1")];
let mut headers = HeaderVec::new();
data.iter()
.for_each(|(name, value)| headers.push(Header::new(name, value)));
@ -188,7 +188,7 @@ mod tests {
// Test iter()
for (i, h) in headers.iter().enumerate() {
assert_eq!(h.name, data[i].0);
assert_eq!(h.value, data[i].1)
assert_eq!(h.value, data[i].1);
}
// Test into_iter()

View File

@ -187,7 +187,7 @@ impl ClientOptions {
}
if let Some(ref unix_socket) = self.unix_socket {
arguments.push("--unix-socket".to_string());
arguments.push(format!("'{unix_socket}'"))
arguments.push(format!("'{unix_socket}'"));
}
if let Some(ref user) = self.user {
arguments.push("--user".to_string());

View File

@ -191,7 +191,7 @@ mod tests {
value: "1,2,3".to_string(),
},
]
)
);
}
#[test]
@ -219,7 +219,7 @@ mod tests {
value: "value2".to_string(),
},
]
)
);
}
#[test]
@ -236,7 +236,7 @@ mod tests {
value: "value2".to_string(),
},
]
)
);
}
#[test]
@ -247,7 +247,7 @@ mod tests {
name: "cookie1".to_string(),
value: "value1".to_string(),
},
)
);
}
#[test]

View File

@ -49,15 +49,15 @@ impl RequestSpec {
match self.body {
Body::Text(_) => {
arguments.push("--header".to_string());
arguments.push(format!("'{}:'", CONTENT_TYPE))
arguments.push(format!("'{}:'", CONTENT_TYPE));
}
Body::Binary(_) => {
arguments.push("--header".to_string());
arguments.push(format!("'{}: application/octet-stream'", CONTENT_TYPE))
arguments.push(format!("'{}: application/octet-stream'", CONTENT_TYPE));
}
Body::File(_, _) => {
arguments.push("--header".to_string());
arguments.push(format!("'{}:'", CONTENT_TYPE))
arguments.push(format!("'{}:'", CONTENT_TYPE));
}
}
}

View File

@ -83,7 +83,7 @@ impl Response {
let encodings = self.headers.content_encoding()?;
let mut data = self.body.clone();
for encoding in &encodings {
data = encoding.decode(&data)?
data = encoding.decode(&data)?;
}
Ok(data)
}

View File

@ -137,7 +137,7 @@ impl Selector {
let mut values = vec![];
for index in indexes {
if let Some(value) = root.get(index) {
values.push(value.clone())
values.push(value.clone());
}
}
Some(JsonpathResult::Collection(values))

View File

@ -88,7 +88,7 @@ impl Reader {
None => return s,
Some(c) => {
if predicate(&c) {
s.push(self.read().unwrap())
s.push(self.read().unwrap());
} else {
return s;
}

View File

@ -93,7 +93,7 @@ impl Element {
/// Adds a `child` to this element.
pub fn add_child(&mut self, child: Element) {
self.children.push(child)
self.children.push(child);
}
/// Returns an iterator over these element's children.
@ -170,7 +170,7 @@ impl fmt::Display for Element {
}
fn push_attr(f: &mut String, key: &str, value: &str) {
f.push_str(&format!(" {key}=\"{value}\""))
f.push_str(&format!(" {key}=\"{value}\""));
}
/// SVG elements can be modified using attributes.

View File

@ -182,13 +182,13 @@ impl Mul<usize> for Pixel {
impl AddAssign for Pixel {
fn add_assign(&mut self, rhs: Pixel) {
*self = *self + rhs
*self = *self + rhs;
}
}
impl SubAssign for Pixel {
fn sub_assign(&mut self, rhs: Pixel) {
*self = *self - rhs
*self = *self - rhs;
}
}

View File

@ -175,7 +175,7 @@ fn new_vert_lines(
return;
}
let elt = svg::new_line(*x, 0.0, *x, pixels_y.end.0);
lines.add_child(elt)
lines.add_child(elt);
});
group.add_child(lines);

View File

@ -65,11 +65,11 @@ impl Testcase {
.attr("time", &time_in_seconds);
for failure in self.failures.iter() {
element = element.add_child(Element::new("failure").text(failure))
element = element.add_child(Element::new("failure").text(failure));
}
for error in self.errors.iter() {
element = element.add_child(Element::new("error").text(error))
element = element.add_child(Element::new("error").text(error));
}
element
}

View File

@ -399,6 +399,6 @@ mod tests {
))
)
)
)
);
}
}

View File

@ -168,7 +168,7 @@ not ok 3 - tests_ok/test.3.hurl
success: false
}
]
)
);
}
#[test]
@ -196,6 +196,6 @@ not ok 3 - tests_ok/test.3.hurl
success: false
}
]
)
);
}
}

View File

@ -169,7 +169,7 @@ pub mod tests {
.err()
.unwrap();
assert_eq!(error.source_info.start, Pos { line: 1, column: 7 });
assert_eq!(error.inner, RunnerError::QueryInvalidXpathEval)
assert_eq!(error.inner, RunnerError::QueryInvalidXpathEval);
}
#[test]

View File

@ -410,7 +410,7 @@ fn get_non_default_options(options: &RunnerOptions) -> Vec<(&'static str, String
if options.unix_socket != default_options.unix_socket {
if let Some(unix_socket) = &options.unix_socket {
non_default_options.push(("unix socket", unix_socket.to_string()))
non_default_options.push(("unix socket", unix_socket.to_string()));
}
}

View File

@ -111,7 +111,7 @@ mod tests {
body,
r#"{"query":"{\n human(id: \"1000\") {\n name\n height(unit: FOOT)\n }\n}"}"#
.to_string()
)
);
}
#[test]
@ -184,6 +184,6 @@ mod tests {
});
let body = eval_multiline(&multiline, &hurl_variables).unwrap();
assert_eq!(body, r#"{"query":"{\n human(id: \"1000\") {\n name\n height(unit: FOOT)\n }\n}","variables":{"episode":"JEDI","withFriends":false}}"#.to_string())
assert_eq!(body, r#"{"query":"{\n human(id: \"1000\") {\n name\n height(unit: FOOT)\n }\n}","variables":{"episode":"JEDI","withFriends":false}}"#.to_string());
}
}

View File

@ -51,31 +51,31 @@ pub fn get_entry_options(
match &option.kind {
OptionKind::AwsSigV4(value) => {
let value = eval_template(value, variables)?;
runner_options.aws_sigv4 = Some(value)
runner_options.aws_sigv4 = Some(value);
}
OptionKind::CaCertificate(filename) => {
let value = eval_template(filename, variables)?;
runner_options.cacert_file = Some(value)
runner_options.cacert_file = Some(value);
}
OptionKind::ClientCert(filename) => {
let value = eval_template(filename, variables)?;
runner_options.client_cert_file = Some(value)
runner_options.client_cert_file = Some(value);
}
OptionKind::ClientKey(filename) => {
let value = eval_template(filename, variables)?;
runner_options.client_key_file = Some(value)
runner_options.client_key_file = Some(value);
}
OptionKind::Compressed(value) => {
let value = eval_boolean_option(value, variables)?;
runner_options.compressed = value
runner_options.compressed = value;
}
OptionKind::ConnectTo(value) => {
let value = eval_template(value, variables)?;
runner_options.connects_to.push(value)
runner_options.connects_to.push(value);
}
OptionKind::Delay(value) => {
let value = eval_natural_option(value, variables)?;
runner_options.delay = Duration::from_millis(value)
runner_options.delay = Duration::from_millis(value);
}
// HTTP version options (such as http1.0, http1.1, http2 etc...) are activated
// through a flag. In an `[Options]` section, the signification of such a flag is:
@ -104,31 +104,31 @@ pub fn get_entry_options(
OptionKind::Http10(value) => {
let value = eval_boolean_option(value, variables)?;
if value {
runner_options.http_version = RequestedHttpVersion::Http10
runner_options.http_version = RequestedHttpVersion::Http10;
}
}
OptionKind::Http11(value) => {
let value = eval_boolean_option(value, variables)?;
if value {
runner_options.http_version = RequestedHttpVersion::Http11
runner_options.http_version = RequestedHttpVersion::Http11;
} else {
runner_options.http_version = RequestedHttpVersion::Http10
runner_options.http_version = RequestedHttpVersion::Http10;
}
}
OptionKind::Http2(value) => {
let value = eval_boolean_option(value, variables)?;
if value {
runner_options.http_version = RequestedHttpVersion::Http2
runner_options.http_version = RequestedHttpVersion::Http2;
} else {
runner_options.http_version = RequestedHttpVersion::Http11
runner_options.http_version = RequestedHttpVersion::Http11;
}
}
OptionKind::Http3(value) => {
let value = eval_boolean_option(value, variables)?;
if value {
runner_options.http_version = RequestedHttpVersion::Http3
runner_options.http_version = RequestedHttpVersion::Http3;
} else {
runner_options.http_version = RequestedHttpVersion::Http2
runner_options.http_version = RequestedHttpVersion::Http2;
}
}
OptionKind::FollowLocation(value) => {
@ -144,7 +144,7 @@ pub fn get_entry_options(
}
OptionKind::Insecure(value) => {
let value = eval_boolean_option(value, variables)?;
runner_options.insecure = value
runner_options.insecure = value;
}
OptionKind::IpV4(value) => {
let value = eval_boolean_option(value, variables)?;
@ -164,19 +164,19 @@ pub fn get_entry_options(
}
OptionKind::MaxRedirect(value) => {
let value = eval_natural_option(value, variables)?;
runner_options.max_redirect = Some(value as usize)
runner_options.max_redirect = Some(value as usize);
}
OptionKind::NetRc(value) => {
let value = eval_boolean_option(value, variables)?;
runner_options.netrc = value
runner_options.netrc = value;
}
OptionKind::NetRcFile(value) => {
let filename = eval_template(value, variables)?;
runner_options.netrc_file = Some(filename.to_string())
runner_options.netrc_file = Some(filename.to_string());
}
OptionKind::NetRcOptional(value) => {
let value = eval_boolean_option(value, variables)?;
runner_options.netrc_optional = value
runner_options.netrc_optional = value;
}
OptionKind::Output(output) => {
let filename = eval_template(output, variables)?;
@ -185,35 +185,35 @@ pub fn get_entry_options(
} else {
Output::File(filename)
};
runner_options.output = Some(output)
runner_options.output = Some(output);
}
OptionKind::PathAsIs(value) => {
let value = eval_boolean_option(value, variables)?;
runner_options.path_as_is = value
runner_options.path_as_is = value;
}
OptionKind::Proxy(value) => {
let value = eval_template(value, variables)?;
runner_options.proxy = Some(value.to_string())
runner_options.proxy = Some(value.to_string());
}
OptionKind::Resolve(value) => {
let value = eval_template(value, variables)?;
runner_options.resolves.push(value)
runner_options.resolves.push(value);
}
OptionKind::Retry(value) => {
let value = eval_retry_option(value, variables)?;
runner_options.retry = value
runner_options.retry = value;
}
OptionKind::RetryInterval(value) => {
let value = eval_natural_option(value, variables)?;
runner_options.retry_interval = Duration::from_millis(value)
runner_options.retry_interval = Duration::from_millis(value);
}
OptionKind::Skip(value) => {
let value = eval_boolean_option(value, variables)?;
runner_options.skip = value
runner_options.skip = value;
}
OptionKind::UnixSocket(value) => {
let value = eval_template(value, variables)?;
runner_options.unix_socket = Some(value.to_string())
runner_options.unix_socket = Some(value.to_string());
}
OptionKind::Variable(VariableDefinition { name, value, .. }) => {
let value = eval_variable_value(value, variables)?;

View File

@ -514,7 +514,7 @@ pub mod tests {
assert_eq!(
Value::from_json(&json_number),
Value::Number(Number::Float(1000000000000000000000.5f64))
)
);
}
#[test]

View File

@ -50,7 +50,7 @@ impl HurlResult {
if next.entry_index != entry.entry_index {
let new_errors =
entry.errors.iter().map(|error| (error, entry.source_info));
errors.extend(new_errors)
errors.extend(new_errors);
}
}
}

View File

@ -36,7 +36,7 @@ impl BaseLogger {
}
pub fn info(&self, message: &str) {
log_info(message)
log_info(message);
}
pub fn debug(&self, message: &str) {
@ -44,25 +44,25 @@ impl BaseLogger {
return;
}
if self.color {
log_debug(message)
log_debug(message);
} else {
log_debug_no_color(message)
log_debug_no_color(message);
}
}
pub fn warning(&self, message: &str) {
if self.color {
log_warning(message)
log_warning(message);
} else {
log_warning_no_color(message)
log_warning_no_color(message);
}
}
pub fn error(&self, message: &str) {
if self.color {
log_error(message)
log_error(message);
} else {
log_error_no_color(message)
log_error_no_color(message);
}
}
}
@ -204,7 +204,7 @@ impl Default for LoggerOptionsBuilder {
impl Logger {
pub fn info(&self, message: &str) {
log_info(message)
log_info(message);
}
pub fn debug(&self, message: &str) {
@ -212,9 +212,9 @@ impl Logger {
return;
}
if self.color {
log_debug(message)
log_debug(message);
} else {
log_debug_no_color(message)
log_debug_no_color(message);
}
}
@ -223,9 +223,9 @@ impl Logger {
return;
}
if self.color {
log_debug_curl(message)
log_debug_curl(message);
} else {
log_debug_curl_no_color(message)
log_debug_curl_no_color(message);
}
}
@ -234,9 +234,9 @@ impl Logger {
return;
}
if self.color {
log_debug_error(&self.filename, content, error, entry_src_info)
log_debug_error(&self.filename, content, error, entry_src_info);
} else {
log_debug_error_no_color(&self.filename, content, error, entry_src_info)
log_debug_error_no_color(&self.filename, content, error, entry_src_info);
}
}
@ -245,9 +245,9 @@ impl Logger {
return;
}
if self.color {
log_debug_header_in(name, value)
log_debug_header_in(name, value);
} else {
log_debug_header_in_no_color(name, value)
log_debug_header_in_no_color(name, value);
}
}
@ -256,9 +256,9 @@ impl Logger {
return;
}
if self.color {
log_debug_header_out(name, value)
log_debug_header_out(name, value);
} else {
log_debug_header_out_no_color(name, value)
log_debug_header_out_no_color(name, value);
}
}
@ -267,9 +267,9 @@ impl Logger {
return;
}
if self.color {
log_debug_important(message)
log_debug_important(message);
} else {
log_debug_no_color(message)
log_debug_no_color(message);
}
}
@ -278,33 +278,33 @@ impl Logger {
return;
}
if self.color {
log_debug_status_version_in(line)
log_debug_status_version_in(line);
} else {
log_debug_status_version_in_no_color(line)
log_debug_status_version_in_no_color(line);
}
}
pub fn warning(&self, message: &str) {
if self.color {
log_warning(message)
log_warning(message);
} else {
log_warning_no_color(message)
log_warning_no_color(message);
}
}
pub fn error(&self, message: &str) {
if self.color {
log_error(message)
log_error(message);
} else {
log_error_no_color(message)
log_error_no_color(message);
}
}
pub fn error_parsing_rich<E: Error>(&self, content: &str, error: &E) {
if self.color {
log_error_rich(&self.filename, content, error, None)
log_error_rich(&self.filename, content, error, None);
} else {
log_error_rich_no_color(&self.filename, content, error, None)
log_error_rich_no_color(&self.filename, content, error, None);
}
}
@ -315,9 +315,9 @@ impl Logger {
entry_src_info: SourceInfo,
) {
if self.color {
log_error_rich(&self.filename, content, error, Some(entry_src_info))
log_error_rich(&self.filename, content, error, Some(entry_src_info));
} else {
log_error_rich_no_color(&self.filename, content, error, Some(entry_src_info))
log_error_rich_no_color(&self.filename, content, error, Some(entry_src_info));
}
}
@ -326,9 +326,9 @@ impl Logger {
return;
}
if self.color {
log_debug_method_version_out(line)
log_debug_method_version_out(line);
} else {
log_debug_method_version_out_no_color(line)
log_debug_method_version_out_no_color(line);
}
}
@ -337,9 +337,9 @@ impl Logger {
return;
}
if self.color {
log_capture(name, value)
log_capture(name, value);
} else {
log_capture_no_color(name, value)
log_capture_no_color(name, value);
}
}
@ -348,9 +348,9 @@ impl Logger {
return;
}
if self.color {
log_test_running(&self.filename, current, total)
log_test_running(&self.filename, current, total);
} else {
log_test_running_no_color(&self.filename, current, total)
log_test_running_no_color(&self.filename, current, total);
}
}
@ -358,7 +358,7 @@ impl Logger {
if !self.progress_bar {
return;
}
log_test_progress(entry_index, count)
log_test_progress(entry_index, count);
}
pub fn test_completed(&self, result: &HurlResult) {
@ -366,9 +366,9 @@ impl Logger {
return;
}
if self.color {
log_test_completed(result, &self.filename)
log_test_completed(result, &self.filename);
} else {
log_test_completed_no_color(result, &self.filename)
log_test_completed_no_color(result, &self.filename);
}
}
@ -445,35 +445,35 @@ fn log_debug_error_no_color<E: Error>(
}
fn log_debug_header_in(name: &str, value: &str) {
eprintln!("< {}: {}", name.cyan().bold(), value)
eprintln!("< {}: {}", name.cyan().bold(), value);
}
fn log_debug_header_in_no_color(name: &str, value: &str) {
eprintln!("< {name}: {value}")
eprintln!("< {name}: {value}");
}
fn log_debug_header_out(name: &str, value: &str) {
eprintln!("> {}: {}", name.cyan().bold(), value)
eprintln!("> {}: {}", name.cyan().bold(), value);
}
fn log_debug_header_out_no_color(name: &str, value: &str) {
eprintln!("> {name}: {value}")
eprintln!("> {name}: {value}");
}
fn log_debug_method_version_out(line: &str) {
eprintln!("> {}", line.purple().bold())
eprintln!("> {}", line.purple().bold());
}
fn log_debug_method_version_out_no_color(line: &str) {
eprintln!("> {line}")
eprintln!("> {line}");
}
fn log_debug_status_version_in(line: &str) {
eprintln!("< {}", line.green().bold())
eprintln!("< {}", line.green().bold());
}
fn log_debug_status_version_in_no_color(line: &str) {
eprintln!("< {line}")
eprintln!("< {line}");
}
fn log_warning(message: &str) {
@ -499,7 +499,7 @@ fn log_error_rich<E: Error>(
entry_src_info: Option<SourceInfo>,
) {
let message = error_string(filename, content, error, entry_src_info, true);
eprintln!("{}: {}\n", "error".red().bold(), &message)
eprintln!("{}: {}\n", "error".red().bold(), &message);
}
fn log_error_rich_no_color<E: Error>(
@ -509,15 +509,15 @@ fn log_error_rich_no_color<E: Error>(
entry_src_info: Option<SourceInfo>,
) {
let message = error_string(filename, content, error, entry_src_info, false);
eprintln!("error: {}\n", &message)
eprintln!("error: {}\n", &message);
}
fn log_capture(name: &str, value: &Value) {
eprintln!("{} {}: {}", "*".blue().bold(), name.yellow().bold(), value)
eprintln!("{} {}: {}", "*".blue().bold(), name.yellow().bold(), value);
}
fn log_capture_no_color(name: &str, value: &Value) {
eprintln!("* {name}: {value}")
eprintln!("* {name}: {value}");
}
fn log_test_running(filename: &str, current: usize, total: usize) {
@ -527,11 +527,11 @@ fn log_test_running(filename: &str, current: usize, total: usize) {
"Running".cyan().bold(),
current,
total
)
);
}
fn log_test_running_no_color(filename: &str, current: usize, total: usize) {
eprintln!("{filename}: Running [{current}/{total}]")
eprintln!("{filename}: Running [{current}/{total}]");
}
fn log_test_progress(entry_index: usize, count: usize) {
@ -567,7 +567,7 @@ fn log_test_completed(result: &HurlResult, filename: &str) {
state,
count,
result.time_in_ms
)
);
}
fn log_test_completed_no_color(result: &HurlResult, filename: &str) {
@ -576,7 +576,7 @@ fn log_test_completed_no_color(result: &HurlResult, filename: &str) {
eprintln!(
"{}: {} ({} request(s) in {} ms)",
filename, state, count, result.time_in_ms
)
);
}
/// Returns the string representation of an `error`, given `lines` of content and a `filename`.
@ -786,7 +786,7 @@ pub mod tests {
assert_eq!(
add_line_prefix("line1\nline2\nline3", ">", false),
">line1\n>line2\n>line3"
)
);
}
#[test]
@ -806,7 +806,7 @@ pub mod tests {
1 | GET http://unknown
| ^^^^^^^^^^^^^^ (6) Could not resolve host: unknown
|"#
)
);
}
#[test]
@ -830,7 +830,7 @@ HTTP/1.0 200
2 | HTTP/1.0 200
| ^^^ actual value is <404>
|"#
)
);
}
#[test]
@ -858,7 +858,7 @@ xpath "strong(//head/title)" == "Hello"
4 | xpath "strong(//head/title)" == "Hello"
| ^^^^^^^^^^^^^^^^^^^^^^ the XPath expression is not valid
|"#
)
);
}
#[test]
@ -891,7 +891,7 @@ jsonpath "$.count" >= 5
| actual: int <2>
| expected: greater than int <5>
|"#
)
);
}
#[test]
@ -921,7 +921,7 @@ HTTP/1.0 200
>
|"#
)
);
}
#[test]
@ -941,7 +941,7 @@ HTTP/1.0 200
1 | GET abc
| ^ expecting http://, https:// or {{
|"#
)
);
}
#[rustfmt::skip]

View File

@ -193,12 +193,12 @@ impl Template {
fn encoded(&self) -> String {
let mut s = String::new();
if let Some(d) = self.delimiter {
s.push(d)
s.push(d);
}
let elements: Vec<String> = self.elements.iter().map(|e| e.encoded()).collect();
s.push_str(elements.join("").as_str());
if let Some(d) = self.delimiter {
s.push(d)
s.push(d);
}
s
}

View File

@ -177,17 +177,17 @@ impl HtmlFormatter {
SectionValue::QueryParams(items) => items.iter().for_each(|item| self.fmt_kv(item)),
SectionValue::BasicAuth(item) => {
if let Some(kv) = item {
self.fmt_kv(kv)
self.fmt_kv(kv);
}
}
SectionValue::FormParams(items) => items.iter().for_each(|item| self.fmt_kv(item)),
SectionValue::MultipartFormData(items) => {
items.iter().for_each(|item| self.fmt_multipart_param(item))
items.iter().for_each(|item| self.fmt_multipart_param(item));
}
SectionValue::Cookies(items) => items.iter().for_each(|item| self.fmt_cookie(item)),
SectionValue::Captures(items) => items.iter().for_each(|item| self.fmt_capture(item)),
SectionValue::Options(items) => {
items.iter().for_each(|item| self.fmt_entry_option(item))
items.iter().for_each(|item| self.fmt_entry_option(item));
}
}
}
@ -632,7 +632,7 @@ impl HtmlFormatter {
self.fmt_span("multiline", &tail);
// As we have added a span close, we must remove one to have the right number
// of span. The current span line will add a closing span.
pop_str(&mut self.buffer, "</span>")
pop_str(&mut self.buffer, "</span>");
}
}
@ -865,7 +865,7 @@ impl Template {
TemplateElement::String { encoded, .. } => encoded.to_string(),
TemplateElement::Expression(expr) => format!("{{{{{expr}}}}}"),
};
s.push_str(elem_str.as_str())
s.push_str(elem_str.as_str());
}
if let Some(d) = self.delimiter {
s.push(d);
@ -1065,7 +1065,7 @@ mod tests {
assert_eq!(
fmt.buffer,
"<span class=\"json\"><span class=\"line\">\"\\n\"</span></span>"
)
);
}
#[test]
@ -1076,7 +1076,7 @@ mod tests {
assert_eq!(
fmt.buffer,
"<span class=\"xml\"><span class=\"line\">&lt;?xml version=\"1.0\"?&gt;</span>\n<span class=\"line\">&lt;drink&gt;café&lt;/drink&gt;</span></span>"
)
);
}
#[test]

View File

@ -28,7 +28,7 @@ pub fn parse(reader: &mut Reader) -> ParseResult<Expr> {
let space1 = zero_or_more_spaces(reader)?;
if try_literal("}}}", reader).is_err() {
literal("}}", reader)?
literal("}}", reader)?;
}
Ok(Expr {

View File

@ -393,7 +393,7 @@ mod tests {
for text in datas.iter() {
let mut reader = Reader::new(text);
assert!(multiline_string(&mut reader).is_err())
assert!(multiline_string(&mut reader).is_err());
}
}
@ -692,7 +692,7 @@ variables {
}
})
})
)
);
}
#[test]
@ -713,7 +713,7 @@ variables
assert_eq!(
error,
Error::new(Pos::new(8, 10), false, ParseError::GraphQlVariables)
)
);
}
#[test]
@ -738,6 +738,6 @@ variables [
assert_eq!(
error,
Error::new(Pos::new(8, 11), false, ParseError::GraphQlVariables)
)
);
}
}

View File

@ -451,7 +451,7 @@ mod tests {
fn test_option_insecure_error() {
let mut reader = Reader::new("insecure: error");
let error = parse(&mut reader).err().unwrap();
assert!(!error.recoverable)
assert!(!error.recoverable);
}
#[test]
@ -534,7 +534,7 @@ mod tests {
fn test_option_cacert_error() {
let mut reader = Reader::new("cacert: ###");
let error = parse(&mut reader).err().unwrap();
assert!(!error.recoverable)
assert!(!error.recoverable);
}
#[test]

View File

@ -117,7 +117,7 @@ pub fn comment(reader: &mut Reader) -> ParseResult<Comment> {
_ => {
reader.state = save_state;
if let Some(c) = reader.read() {
value.push(c)
value.push(c);
}
}
}

View File

@ -105,7 +105,7 @@ impl Reader {
None => return s,
Some(c) => {
if predicate(&c) {
s.push(self.read().unwrap())
s.push(self.read().unwrap());
} else {
return s;
}
@ -124,12 +124,12 @@ impl Reader {
Some(c) => {
if escaped && c == ' ' {
escaped = false;
s.push(self.read().unwrap())
s.push(self.read().unwrap());
} else if c == '\\' {
escaped = true;
let _backslash = self.read().unwrap();
} else if predicate(&c) {
s.push(self.read().unwrap())
s.push(self.read().unwrap());
} else {
return s;
}

View File

@ -130,7 +130,7 @@ pub fn templatize(encoded_string: EncodedString) -> ParseResult<Vec<TemplateElem
}
if !value.is_empty() {
elements.push(TemplateElement::String { value, encoded })
elements.push(TemplateElement::String { value, encoded });
}
Ok(elements)
}

View File

@ -37,7 +37,7 @@ pub fn make_logger_parser_error(
filename: Option<PathBuf>,
) -> impl Fn(&parser::Error, bool) {
move |error: &parser::Error, warning: bool| {
log_error(lines.clone(), color, filename.clone(), error, warning)
log_error(lines.clone(), color, filename.clone(), error, warning);
}
}
@ -47,7 +47,7 @@ pub fn make_logger_linter_error(
filename: Option<PathBuf>,
) -> impl Fn(&linter::Error, bool) {
move |error: &linter::Error, warning: bool| {
log_error(lines.clone(), color, filename.clone(), error, warning)
log_error(lines.clone(), color, filename.clone(), error, warning);
}
}

View File

@ -62,7 +62,7 @@ pub fn headers(arg_matches: &ArgMatches) -> Vec<String> {
if !has_content_type(&headers) {
if let Some(data) = get_string(arg_matches, "data") {
if !data.starts_with('@') {
headers.push("Content-Type: application/x-www-form-urlencoded".to_string())
headers.push("Content-Type: application/x-www-form-urlencoded".to_string());
}
}
}

View File

@ -53,7 +53,7 @@ pub fn parse(s: &str) -> Result<String, String> {
let hurl_str = parse_line(line).map_err(|message| {
format!("Can not parse curl command at line {}: {message}", i + 1)
})?;
s.push_str(format!("{hurl_str}\n").as_str())
s.push_str(format!("{hurl_str}\n").as_str());
}
Ok(s)
}

View File

@ -99,7 +99,7 @@ impl ToJson for Response {
fn to_json(&self) -> JValue {
let mut attributes = vec![];
if let Some(v) = get_json_version(&self.version.value) {
attributes.push(("version".to_string(), JValue::String(v)))
attributes.push(("version".to_string(), JValue::String(v)));
}
if let StatusValue::Specific(n) = self.status.value {
attributes.push(("status".to_string(), JValue::Number(n.to_string())));
@ -123,7 +123,7 @@ impl ToJson for Response {
fn add_headers(attributes: &mut Vec<(String, JValue)>, headers: &[Header]) {
if !headers.is_empty() {
let headers = JValue::List(headers.iter().map(|h| h.to_json()).collect());
attributes.push(("headers".to_string(), headers))
attributes.push(("headers".to_string(), headers));
}
}
@ -488,7 +488,7 @@ impl ToJson for Predicate {
fn to_json(&self) -> JValue {
let mut attributes = vec![];
if self.not {
attributes.push(("not".to_string(), JValue::Boolean(true)))
attributes.push(("not".to_string(), JValue::Boolean(true)));
}
match self.predicate_func.value.clone() {
PredicateFuncValue::Equal { value, .. } => {

View File

@ -90,7 +90,7 @@ pub mod tests {
assert_eq!(format_char('a'), "a");
assert_eq!(format_char('"'), "\\\""); // \"
assert_eq!(format_char('\n'), "\\n");
assert_eq!(format_char('\x07'), "\\u0007")
assert_eq!(format_char('\x07'), "\\u0007");
}
#[test]

View File

@ -121,7 +121,7 @@ impl Tokenizable for Response {
tokens.append(&mut self.headers.iter().flat_map(|e| e.tokenize()).collect());
tokens.append(&mut self.sections.iter().flat_map(|e| e.tokenize()).collect());
if let Some(body) = self.clone().body {
tokens.append(&mut body.tokenize())
tokens.append(&mut body.tokenize());
}
tokens
}
@ -207,7 +207,7 @@ impl Tokenizable for SectionValue {
}
SectionValue::BasicAuth(item) => {
if let Some(kv) = item {
tokens.append(&mut kv.tokenize())
tokens.append(&mut kv.tokenize());
}
}
SectionValue::FormParams(items) => {