chore: Fix several style lints (#17488)

It's not comprehensive enough to start linting on `style` group, but
hey, it's a start.

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-09-06 11:58:39 +02:00 committed by GitHub
parent 93249fc82b
commit e6c1c51b37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
361 changed files with 3530 additions and 3587 deletions

View file

@ -32,7 +32,7 @@ impl Blame {
remote_url: Option<String>,
provider_registry: Arc<GitHostingProviderRegistry>,
) -> Result<Self> {
let output = run_git_blame(git_binary, working_directory, path, &content)?;
let output = run_git_blame(git_binary, working_directory, path, content)?;
let mut entries = parse_git_blame(&output)?;
entries.sort_unstable_by(|a, b| a.range.start.cmp(&b.range.start));
@ -60,7 +60,7 @@ impl Blame {
let shas = unique_shas.into_iter().collect::<Vec<_>>();
let messages =
get_messages(&working_directory, &shas).context("failed to get commit messages")?;
get_messages(working_directory, &shas).context("failed to get commit messages")?;
Ok(Self {
entries,
@ -71,8 +71,8 @@ impl Blame {
}
}
const GIT_BLAME_NO_COMMIT_ERROR: &'static str = "fatal: no such ref: HEAD";
const GIT_BLAME_NO_PATH: &'static str = "fatal: no such path";
const GIT_BLAME_NO_COMMIT_ERROR: &str = "fatal: no such ref: HEAD";
const GIT_BLAME_NO_PATH: &str = "fatal: no such path";
fn run_git_blame(
git_binary: &Path,

View file

@ -12,7 +12,7 @@ pub fn get_messages(working_directory: &Path, shas: &[Oid]) -> Result<HashMap<Oi
return Ok(HashMap::default());
}
const MARKER: &'static str = "<MARKER>";
const MARKER: &str = "<MARKER>";
let mut command = Command::new("git");

View file

@ -63,6 +63,12 @@ pub struct BufferDiff {
tree: SumTree<DiffHunk<Anchor>>,
}
impl Default for BufferDiff {
fn default() -> Self {
Self::new()
}
}
impl BufferDiff {
pub fn new() -> BufferDiff {
BufferDiff {

View file

@ -49,7 +49,7 @@ impl FromStr for Oid {
fn from_str(s: &str) -> std::prelude::v1::Result<Self, Self::Err> {
libgit::Oid::from_str(s)
.map_err(|error| anyhow!("failed to parse git oid: {}", error))
.map(|oid| Self(oid))
.map(Self)
}
}

View file

@ -171,7 +171,7 @@ pub fn parse_git_remote_url(
.into_iter()
.find_map(|provider| {
provider
.parse_remote_url(&url)
.parse_remote_url(url)
.map(|parsed_remote| (provider, parsed_remote))
})
}