1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-24 13:47:38 +00:00

chore(clippy): fix new clippy lints (#3294)

This commit is contained in:
David Knaack 2021-12-03 07:54:56 +01:00 committed by GitHub
parent 76c7baac7b
commit 77182a9a22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 43 deletions

View File

@ -3,13 +3,7 @@ use crate::config::ModuleConfig;
use serde::Serialize;
use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)]
#[derive(Clone, ModuleConfig, Serialize, Default)]
pub struct LineBreakConfig {
pub disabled: bool,
}
impl<'a> Default for LineBreakConfig {
fn default() -> Self {
LineBreakConfig { disabled: false }
}
}

View File

@ -44,7 +44,7 @@ impl GcloudContext {
.skip(1)
.take_while(|line| !line.starts_with('['))
.find(|line| line.starts_with("account"))?;
let account = account_line.splitn(2, '=').nth(1)?.trim();
let account = account_line.split_once('=')?.1.trim();
let mut segments = account.splitn(2, '@');
Some((
segments.next().map(String::from)?,
@ -60,7 +60,7 @@ impl GcloudContext {
.skip(1)
.take_while(|line| !line.starts_with('['))
.find(|line| line.starts_with("project"))?;
let project = project_line.splitn(2, '=').nth(1)?.trim();
let project = project_line.split_once('=')?.1.trim();
Some(project.to_string())
}
@ -72,7 +72,7 @@ impl GcloudContext {
.skip(1)
.take_while(|line| !line.starts_with('['))
.find(|line| line.starts_with("region"))?;
let region = region_line.splitn(2, '=').nth(1)?.trim();
let region = region_line.split_once('=')?.1.trim();
Some(region.to_string())
}
}

View File

@ -242,8 +242,8 @@ mod tests {
"",
format!(
"branch: {} {} ",
Color::Blue.bold().paint("1337_hello_world").to_string(),
Color::Red.paint("THE COLORS").to_string()
Color::Blue.bold().paint("1337_hello_world"),
Color::Red.paint("THE COLORS")
),
)
}
@ -257,10 +257,7 @@ mod tests {
symbol = "git: "
style = "green"
"#,
format!(
"git: {}",
Color::Green.paint("1337_hello_world").to_string(),
),
format!("git: {}", Color::Green.paint("1337_hello_world"),),
)
}

View File

@ -146,10 +146,7 @@ mod tests {
let expected = Some(format!(
"{} ",
Color::Green
.bold()
.paint(format!("({})", expected_hash))
.to_string()
Color::Green.bold().paint(format!("({})", expected_hash))
));
assert_eq!(expected, actual);
@ -179,10 +176,7 @@ mod tests {
let expected = Some(format!(
"{} ",
Color::Green
.bold()
.paint(format!("({})", expected_hash))
.to_string()
Color::Green.bold().paint(format!("({})", expected_hash))
));
assert_eq!(expected, actual);
@ -226,10 +220,7 @@ mod tests {
let expected = Some(format!(
"{} ",
Color::Green
.bold()
.paint(format!("({})", expected_hash))
.to_string()
Color::Green.bold().paint(format!("({})", expected_hash))
));
assert_eq!(expected, actual);
@ -272,7 +263,6 @@ mod tests {
Color::Green
.bold()
.paint(format!("({})", expected_output.trim()))
.to_string()
));
assert_eq!(expected, actual);
@ -324,7 +314,6 @@ mod tests {
Color::Green
.bold()
.paint(format!("({})", expected_output.trim()))
.to_string()
));
assert_eq!(expected, actual);
@ -396,7 +385,6 @@ mod tests {
Color::Green
.bold()
.paint(format!("({})", expected_output.trim()))
.to_string()
));
assert_eq!(expected, actual);

View File

@ -62,10 +62,10 @@ fn parse_go_version(go_stdout: &str) -> Option<String> {
// go version go1.13.3 linux/amd64
let version = go_stdout
// split into ["", "1.12.4 linux/amd64"]
.splitn(2, "go version go")
// split into ("", "1.12.4 linux/amd64")
.split_once("go version go")?
// return "1.12.4 linux/amd64"
.nth(1)?
.1
// split into ["1.12.4", "linux/amd64"]
.split_whitespace()
// return "1.12.4"

View File

@ -66,10 +66,10 @@ fn parse_helm_version(helm_stdout: &str) -> Option<String> {
// `helm version --short --client` output looks like this for Helm 2:
// Client: v2.16.9+g8ad7037
let version = helm_stdout
// split into ["v3.1.1","gafe7058"] or ["Client: v3.1.1","gafe7058"]
.splitn(2, '+')
// split into ("v3.1.1","gafe7058") or ("Client: v3.1.1","gafe7058")
.split_once('+')
// return "v3.1.1" or "Client: v3.1.1"
.next()?
.map_or(helm_stdout, |x| x.0)
// return "v3.1.1" or " v3.1.1"
.trim_start_matches("Client: ")
// return "v3.1.1"

View File

@ -62,10 +62,10 @@ fn parse_julia_version(julia_stdout: &str) -> Option<String> {
// julia version 1.4.0
let version = julia_stdout
// split into ["", "1.4.0"]
.splitn(2, "julia version")
// split into ("", "1.4.0")
.split_once("julia version")?
// return "1.4.0"
.nth(1)?
.1
.split_whitespace()
.next()?;

View File

@ -149,10 +149,10 @@ fn format_exit_code<'a>(
.map(|variable| match variable {
"status" => Some(Ok(exit_code)),
"int" => Some(Ok(exit_code)),
"maybe_int" => Ok(maybe_exit_code_number.as_deref()).transpose(),
"common_meaning" => Ok(common_meaning.as_deref()).transpose(),
"maybe_int" => Ok(maybe_exit_code_number).transpose(),
"common_meaning" => Ok(common_meaning).transpose(),
"signal_number" => Ok(signal_number.as_deref()).transpose(),
"signal_name" => Ok(signal_name.as_deref()).transpose(),
"signal_name" => Ok(signal_name).transpose(),
"pipestatus" => {
let pipestatus = pipestatus.unwrap_or_else(|| {
// We might enter this case if pipestatus hasn't