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

@ -30,7 +30,7 @@ impl GleamExtension {
}
zed::set_language_server_installation_status(
&language_server_id,
language_server_id,
&zed::LanguageServerInstallationStatus::CheckingForUpdate,
);
let release = zed::latest_github_release(
@ -68,7 +68,7 @@ impl GleamExtension {
if !fs::metadata(&binary_path).map_or(false, |stat| stat.is_file()) {
zed::set_language_server_installation_status(
&language_server_id,
language_server_id,
&zed::LanguageServerInstallationStatus::Downloading,
);
@ -84,7 +84,7 @@ impl GleamExtension {
for entry in entries {
let entry = entry.map_err(|e| format!("failed to load directory entry {e}"))?;
if entry.file_name().to_str() != Some(&version_dir) {
fs::remove_dir_all(&entry.path()).ok();
fs::remove_dir_all(entry.path()).ok();
}
}
}
@ -157,12 +157,12 @@ impl zed::Extension for GleamExtension {
) -> Result<SlashCommandOutput, String> {
match command.name.as_str() {
"gleam-project" => {
let worktree = worktree.ok_or_else(|| "no worktree")?;
let worktree = worktree.ok_or("no worktree")?;
let mut text = String::new();
text.push_str("You are in a Gleam project.\n");
if let Some(gleam_toml) = worktree.read_text_file("gleam.toml").ok() {
if let Ok(gleam_toml) = worktree.read_text_file("gleam.toml") {
text.push_str("The `gleam.toml` is as follows:\n");
text.push_str(&gleam_toml);
}
@ -244,6 +244,6 @@ mod tests {
let detail = "fn(\n Method,\n List(#(String, String)),\n a,\n Scheme,\n String,\n Option(Int),\n String,\n Option(String),\n) -> Request(a)";
let expected = "fn(Method, List(#(String, String)), a, Scheme, String, Option(Int), String, Option(String)) -> Request(a)";
assert_eq!(strip_newlines_from_detail(&detail), expected);
assert_eq!(strip_newlines_from_detail(detail), expected);
}
}

View file

@ -130,10 +130,10 @@ pub struct GleamChromeRemover;
impl HandleTag for GleamChromeRemover {
fn should_handle(&self, tag: &str) -> bool {
match tag {
"head" | "script" | "style" | "svg" | "header" | "footer" | "a" => true,
_ => false,
}
matches!(
tag,
"head" | "script" | "style" | "svg" | "header" | "footer" | "a"
)
}
fn handle_tag_start(
@ -188,10 +188,7 @@ impl GleamModuleCollector {
impl HandleTag for GleamModuleCollector {
fn should_handle(&self, tag: &str) -> bool {
match tag {
"h2" | "a" => true,
_ => false,
}
matches!(tag, "h2" | "a")
}
fn handle_tag_start(
@ -199,15 +196,10 @@ impl HandleTag for GleamModuleCollector {
tag: &HtmlElement,
writer: &mut MarkdownWriter,
) -> StartTagOutcome {
match tag.tag() {
"a" => {
if self.has_seen_modules_header && writer.is_inside("li") {
if let Some(module_name) = Self::parse_module(tag) {
self.modules.insert(module_name);
}
}
if tag.tag() == "a" && self.has_seen_modules_header && writer.is_inside("li") {
if let Some(module_name) = Self::parse_module(tag) {
self.modules.insert(module_name);
}
_ => {}
}
StartTagOutcome::Continue