started fixing clippy issues

This commit is contained in:
Thomas Eppers 2021-10-23 13:14:50 +02:00
parent c9a8c637c4
commit a718f6f8fb
4 changed files with 9 additions and 15 deletions

View File

@ -69,7 +69,7 @@ pub fn split_tag_from_repo(input: &str) -> Result<(&str, &str), Error> {
pub fn split_repo_without_tag(repo: &str) -> Result<Repo, Error> {
let repo = repo.trim();
let split_repo: Vec<&str> = repo.split("/").collect();
let split_repo: Vec<&str> = repo.split('/').collect();
match split_repo.len() {
1 => {
let regex = regex::Regex::new(r"[a-z0-9]+").unwrap();

View File

@ -129,7 +129,7 @@ impl Ui {
}
Ok(tag) => tag,
};
repo.push_str(":");
repo.push(':');
repo.push_str(&tag);
ui.services.change_current_line(repo);
}

View File

@ -104,10 +104,7 @@ impl ServiceSwitcher {
/// finds the next image tag in given file
pub fn find_next_match(&mut self) -> bool {
let current_line: usize = match self.state.selected() {
None => 0,
Some(i) => i,
};
let current_line: usize = self.state.selected().unwrap_or(0);
let mut i = (current_line + 1) % self.list.len();
loop {
@ -131,10 +128,7 @@ impl ServiceSwitcher {
/// finds the previous image tag in given file
pub fn find_previous_match(&mut self) -> bool {
let current_line: usize = match self.state.selected() {
None => 0,
Some(i) => i,
};
let current_line: usize = self.state.selected().unwrap_or(0);
let mut i: usize = if current_line == 0 {
self.list.len() - 1
@ -165,10 +159,10 @@ impl ServiceSwitcher {
/// return the repository from currently selected row
pub fn extract_repo(&self) -> Result<String, Error> {
match self.state.selected() {
None => return Err(Error::NoneSelected),
None => Err(Error::NoneSelected),
Some(i) => match repo::match_yaml_image(&self.list[i]) {
Err(_) => return Err(Error::Parsing(String::from("Nothing found"))),
Ok((_, repo)) => return Ok(repo.to_string()),
Err(_) => Err(Error::Parsing(String::from("Nothing found"))),
Ok((_, repo)) => Ok(repo.to_string()),
},
}
}

View File

@ -163,7 +163,7 @@ impl TagList {
/// select next tag
fn next(&mut self) {
match self.state.selected() {
None if self.lines.len() > 0 => self.state.select(Some(0)),
None if !self.lines.is_empty() => self.state.select(Some(0)),
None => (),
Some(i) if i == self.lines.len() - 1 => self.state.select(Some(0)),
Some(i) => self.state.select(Some(i + 1)),
@ -173,7 +173,7 @@ impl TagList {
/// select previous tag
fn previous(&mut self) {
match self.state.selected() {
None if self.lines.len() > 0 => self.state.select(Some(self.lines.len())),
None if !self.lines.is_empty() => self.state.select(Some(self.lines.len())),
None => (),
Some(i) if i == 0 => self.state.select(Some(self.lines.len() - 1)),
Some(i) => self.state.select(Some(i - 1)),