simplify clippy configuration

This commit is contained in:
Josh Junon 2024-03-25 17:58:18 +01:00
parent 4163ad23ff
commit 5b9fcc21ce
No known key found for this signature in database
12 changed files with 40 additions and 105 deletions

View File

@ -19,83 +19,3 @@ codegen-units = 1 # Compile crates one after another so the compiler can optimiz
lto = true # Enables link to optimizations
opt-level = "s" # Optimize for binary size
debug = true # Enable debug symbols, for sentry
[workspace.lints.rust]
unsafe_code = "forbid"
[workspace.lints.clippy]
all = "deny"
perf = "deny"
correctness = "deny"
complexity = "deny"
style = "deny"
pedantic = "deny"
# selection from clippy::restriction (see https://rust-lang.github.io/rust-clippy/master/index.html#/?groups=restriction)
as_underscore = "deny"
assertions_on_result_states = "deny"
clone_on_ref_ptr = "deny"
create_dir = "deny"
dbg_macro = "deny"
decimal_literal_representation = "deny"
default_numeric_fallback = "deny"
empty_drop = "deny"
empty_structs_with_brackets = "deny"
exit = "deny"
filetype_is_file = "deny"
float_cmp_const = "deny"
fn_to_numeric_cast_any = "deny"
format_push_string = "deny"
get_unwrap = "deny"
integer_division = "deny"
lossy_float_literal = "deny"
mem_forget = "deny"
mixed_read_write_in_expression = "deny"
mutex_atomic = "deny"
needless_raw_strings = "deny"
non_ascii_literal = "deny"
panic = "deny"
print_stderr = "deny"
pub_without_shorthand = "deny"
rc_buffer = "deny"
rc_mutex = "deny"
redundant_type_annotations = "deny"
ref_patterns = "deny"
rest_pat_in_fully_bound_structs = "deny"
same_name_method = "deny"
string_add = "deny"
string_lit_chars_any = "deny"
string_slice = "deny"
string_to_string = "deny"
suspicious_xor_used_as_pow = "deny"
todo = "deny"
try_err = "deny"
unimplemented = "deny"
unnecessary_self_imports = "deny"
unneeded_field_pattern = "deny"
unseparated_literal_suffix = "deny"
if_then_some_else_none = "deny"
use_debug = "deny"
mod_module_files = "deny"
self_named_module_files = "allow"
# TODO
# partial_pub_fields = "deny"
# print_stdout = "deny"
# unwrap_used = "deny"
# unwrap_in_result = "deny"
# noise and or false-positives
missing_errors_doc = { level = "allow", priority = 1 }
used_underscore_binding = { level = "allow", priority = 1 }
must_use_candidate = { level = "allow", priority = 1 }
module_name_repetitions = { level = "allow", priority = 1 }
missing_panics_doc = { level = "allow", priority = 1 }
too_many_lines = { level = "allow", priority = 1 }
implicit_hasher = { level = "allow", priority = 1 }
if_not_else = { level = "allow", priority = 1 }
return_self_not_must_use = { level = "allow", priority = 1 }
inconsistent_struct_constructor = { level = "allow", priority = 1 }
match_wildcard_for_single_variants = { level = "allow", priority = 1 }
unnested_or_patterns = { level = "allow", priority = 1 }
similar_names = { level = "allow", priority = 1 }
struct_field_names = { level = "allow", priority = 1 }

View File

@ -76,6 +76,13 @@ zip = "0.6.5"
tempfile = "3.10"
gitbutler-git = { path = "../gitbutler-git" }
[lints.clippy]
all = "deny"
perf = "deny"
correctness = "deny"
pedantic = "deny"
[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is a URL
@ -88,6 +95,3 @@ custom-protocol = ["tauri/custom-protocol"]
sentry = ["dep:sentry", "error-context"]
error-context = ["dep:backtrace", "sentry/backtrace"]
[lints]
workspace = true

View File

@ -80,8 +80,8 @@ impl Database {
.parse()
.context("Failed to parse timestamp_ms as u64")?;
let delta = delta::Delta {
timestamp_ms,
operations,
timestamp_ms,
};
if let Some(deltas_for_file_path) = deltas.get_mut(&file_path) {
deltas_for_file_path.push(delta);

View File

@ -13,7 +13,7 @@ pub struct DeltasWriter<'writer> {
impl<'writer> DeltasWriter<'writer> {
pub fn new(repository: &'writer gb_repository::Repository) -> Result<Self, std::io::Error> {
writer::DirWriter::open(repository.root()).map(|writer| Self { writer, repository })
writer::DirWriter::open(repository.root()).map(|writer| Self { repository, writer })
}
pub fn write<P: AsRef<std::path::Path>>(&self, path: P, deltas: &Vec<Delta>) -> Result<()> {

View File

@ -19,10 +19,10 @@ pub fn to_https_url(url: &Url) -> Result<Url, ConvertError> {
scheme: Scheme::Https,
user: None,
serialize_alternative_form: true,
path: if !url.path.starts_with(&[b'/']) {
format!("/{}", url.path.to_str().unwrap()).into()
} else {
path: if url.path.starts_with(&[b'/']) {
url.path.clone()
} else {
format!("/{}", url.path.to_str().unwrap()).into()
},
..url.clone()
}),

View File

@ -4,6 +4,14 @@
all(windows, not(test), not(debug_assertions)),
windows_subsystem = "windows"
)]
// FIXME(qix-): Stuff we want to fix but don't have a lot of time for.
// FIXME(qix-): PRs welcome!
#![allow(
clippy::used_underscore_binding,
clippy::module_name_repetitions,
clippy::struct_field_names,
clippy::too_many_lines
)]
pub(crate) mod analytics;
pub(crate) mod app;
@ -52,6 +60,7 @@ use tauri::{generate_context, Manager, Wry};
use tauri_plugin_log::LogTarget;
use tauri_plugin_store::{with_store, JsonValue, StoreCollection};
#[allow(clippy::too_many_lines)]
fn main() {
let tauri_context = generate_context!();

View File

@ -112,10 +112,10 @@ impl Hunk {
Err(anyhow!("invalid range: {}-{}", start, end))
} else {
Ok(Hunk {
start,
end,
hash,
timestamp_ms,
start,
end,
})
}
}

View File

@ -48,14 +48,7 @@ pub fn update_gitbutler_integration(
let mut prev_head = head.name().unwrap().to_string();
let mut prev_sha = head.target().unwrap().to_string();
let integration_file = repo.path().join("integration");
if prev_head != GITBUTLER_INTEGRATION_REFERENCE.to_string() {
// we are moving from a regular branch to our gitbutler integration branch, save the original
// write a file to .git/integration with the previous head and name
let mut file = std::fs::File::create(integration_file)?;
prev_head.push(':');
prev_head.push_str(&prev_sha);
file.write_all(prev_head.as_bytes())?;
} else {
if prev_head == GITBUTLER_INTEGRATION_REFERENCE.to_string() {
// read the .git/integration file
if let Ok(mut integration_file) = std::fs::File::open(integration_file) {
let mut prev_data = String::new();
@ -65,6 +58,13 @@ pub fn update_gitbutler_integration(
prev_head = parts[0].to_string();
prev_sha = parts[1].to_string();
}
} else {
// we are moving from a regular branch to our gitbutler integration branch, save the original
// write a file to .git/integration with the previous head and name
let mut file = std::fs::File::create(integration_file)?;
prev_head.push(':');
prev_head.push_str(&prev_sha);
file.write_all(prev_head.as_bytes())?;
}
// commit index to temp head for the merge

View File

@ -863,17 +863,17 @@ pub fn list_virtual_branches(
.context(format!("failed to get log for branch {}", branch.name))?
.iter()
.map(|commit| {
is_remote = if !is_remote {
pushed_commits.contains_key(&commit.id())
} else {
is_remote = if is_remote {
is_remote
} else {
pushed_commits.contains_key(&commit.id())
};
// only check for integration if we haven't already found an integration
is_integrated = if !is_integrated {
is_commit_integrated(project_repository, &default_target, commit)?
} else {
is_integrated = if is_integrated {
is_integrated
} else {
is_commit_integrated(project_repository, &default_target, commit)?
};
commit_to_vbranch_commit(

View File

@ -109,7 +109,7 @@ impl InnerHandler {
gb_repo.fetch(user.as_ref()).map_err(|err| {
match err {
gb_repository::RemoteError::Network => backoff::Error::permanent(err),
err => {
err @ gb_repository::RemoteError::Other(_) => {
tracing::warn!(%project_id, ?err, will_retry = true, "failed to fetch project data");
backoff::Error::transient(err)
}

View File

@ -1,3 +1,4 @@
#![allow(clippy::used_underscore_binding)]
use std::path;
use tauri::{AppHandle, Manager};

View File

@ -9,6 +9,7 @@ pub struct Controller {
local_data_dir: path::PathBuf,
logs_dir: path::PathBuf,
zipper: Zipper,
#[allow(clippy::struct_field_names)]
projects_controller: projects::Controller,
}