Deny various rustc and clippy lints in Node.js wrapper

This commit is contained in:
Oliver Hamlet
2025-04-23 00:16:09 +01:00
parent b93a83aa3d
commit e0d890ab1a
4 changed files with 159 additions and 60 deletions
+17 -17
View File
@@ -22,7 +22,7 @@ impl Database {
pub fn load_masterlist(&self, path: String) -> Result<(), VerboseError> {
self.0
.write()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.load_masterlist(Path::new(&path))
.map_err(Into::into)
}
@@ -35,7 +35,7 @@ impl Database {
) -> Result<(), VerboseError> {
self.0
.write()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.load_masterlist_with_prelude(Path::new(&masterlist_path), Path::new(&prelude_path))
.map_err(Into::into)
}
@@ -44,7 +44,7 @@ impl Database {
pub fn load_userlist(&self, path: String) -> Result<(), VerboseError> {
self.0
.write()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.load_userlist(Path::new(&path))
.map_err(Into::into)
}
@@ -63,7 +63,7 @@ impl Database {
self.0
.read()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.write_user_metadata(Path::new(&output_path), write_mode)
.map_err(Into::into)
}
@@ -82,7 +82,7 @@ impl Database {
self.0
.read()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.write_minimal_list(Path::new(&output_path), write_mode)
.map_err(Into::into)
}
@@ -91,7 +91,7 @@ impl Database {
pub fn evaluate(&self, condition: String) -> Result<bool, VerboseError> {
self.0
.read()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.evaluate(&condition)
.map_err(Into::into)
}
@@ -101,7 +101,7 @@ impl Database {
Ok(self
.0
.read()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.known_bash_tags())
}
@@ -112,7 +112,7 @@ impl Database {
) -> Result<Vec<Message>, VerboseError> {
self.0
.write()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.general_messages(evaluate_conditions)
.map(|v| v.into_iter().map(Into::into).collect())
.map_err(Into::into)
@@ -123,7 +123,7 @@ impl Database {
Ok(self
.0
.read()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.groups(include_user_metadata)
.into_iter()
.map(Into::into)
@@ -135,7 +135,7 @@ impl Database {
Ok(self
.0
.read()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.user_groups()
.iter()
.cloned()
@@ -148,7 +148,7 @@ impl Database {
let groups = groups.into_iter().cloned().map(Into::into).collect();
self.0
.write()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.set_user_groups(groups);
Ok(())
}
@@ -161,7 +161,7 @@ impl Database {
) -> Result<Vec<Vertex>, VerboseError> {
self.0
.read()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.groups_path(&from_group_name, &to_group_name)
.map(|v| v.into_iter().map(Into::into).collect())
.map_err(Into::into)
@@ -176,7 +176,7 @@ impl Database {
) -> Result<Option<PluginMetadata>, VerboseError> {
self.0
.read()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.plugin_metadata(&plugin_name, include_user_metadata, evaluate_conditions)
.map(|p| p.map(Into::into))
.map_err(Into::into)
@@ -190,7 +190,7 @@ impl Database {
) -> Result<Option<PluginMetadata>, VerboseError> {
self.0
.read()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.plugin_user_metadata(&plugin_name, evaluate_conditions)
.map(|p| p.map(Into::into))
.map_err(Into::into)
@@ -203,7 +203,7 @@ impl Database {
) -> Result<(), VerboseError> {
self.0
.write()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.set_plugin_user_metadata(plugin_metadata.clone().into());
Ok(())
}
@@ -212,7 +212,7 @@ impl Database {
pub fn discard_plugin_user_metadata(&self, plugin: String) -> Result<(), VerboseError> {
self.0
.write()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.discard_plugin_user_metadata(&plugin);
Ok(())
}
@@ -221,7 +221,7 @@ impl Database {
pub fn discard_all_user_metadata(&self) -> Result<(), VerboseError> {
self.0
.write()
.map_err(|_| DatabaseLockPoisonError)?
.map_err(DatabaseLockPoisonError::from)?
.discard_all_user_metadata();
Ok(())
}
+33 -34
View File
@@ -5,21 +5,20 @@ use napi_derive::napi;
use crate::{database::Database, error::VerboseError, plugin::Plugin};
#[allow(non_camel_case_types)]
#[napi]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum GameType {
tes4,
tes5,
fo3,
fonv,
fo4,
tes5se,
fo4vr,
tes5vr,
tes3,
starfield,
openmw,
Oblivion,
Skyrim,
Fallout3,
FalloutNV,
Fallout4,
SkyrimSE,
Fallout4VR,
SkyrimVR,
Morrowind,
Starfield,
OpenMW,
}
impl TryFrom<libloot::GameType> for GameType {
@@ -27,17 +26,17 @@ impl TryFrom<libloot::GameType> for GameType {
fn try_from(value: libloot::GameType) -> Result<Self, Self::Error> {
match value {
libloot::GameType::TES4 => Ok(GameType::tes4),
libloot::GameType::TES5 => Ok(GameType::tes5),
libloot::GameType::FO3 => Ok(GameType::fo3),
libloot::GameType::FONV => Ok(GameType::fonv),
libloot::GameType::FO4 => Ok(GameType::fo4),
libloot::GameType::TES5SE => Ok(GameType::tes5se),
libloot::GameType::FO4VR => Ok(GameType::fo4vr),
libloot::GameType::TES5VR => Ok(GameType::tes5vr),
libloot::GameType::TES3 => Ok(GameType::tes3),
libloot::GameType::Starfield => Ok(GameType::starfield),
libloot::GameType::OpenMW => Ok(GameType::openmw),
libloot::GameType::TES4 => Ok(GameType::Oblivion),
libloot::GameType::TES5 => Ok(GameType::Skyrim),
libloot::GameType::FO3 => Ok(GameType::Fallout3),
libloot::GameType::FONV => Ok(GameType::FalloutNV),
libloot::GameType::FO4 => Ok(GameType::Fallout4),
libloot::GameType::TES5SE => Ok(GameType::SkyrimSE),
libloot::GameType::FO4VR => Ok(GameType::Fallout4VR),
libloot::GameType::TES5VR => Ok(GameType::SkyrimVR),
libloot::GameType::TES3 => Ok(GameType::Morrowind),
libloot::GameType::Starfield => Ok(GameType::Starfield),
libloot::GameType::OpenMW => Ok(GameType::OpenMW),
_ => Err(UnsupportedEnumValueError),
}
}
@@ -46,17 +45,17 @@ impl TryFrom<libloot::GameType> for GameType {
impl From<GameType> for libloot::GameType {
fn from(value: GameType) -> Self {
match value {
GameType::tes4 => libloot::GameType::TES4,
GameType::tes5 => libloot::GameType::TES5,
GameType::fo3 => libloot::GameType::FO3,
GameType::fonv => libloot::GameType::FONV,
GameType::fo4 => libloot::GameType::FO4,
GameType::tes5se => libloot::GameType::TES5SE,
GameType::fo4vr => libloot::GameType::FO4VR,
GameType::tes5vr => libloot::GameType::TES5VR,
GameType::tes3 => libloot::GameType::TES3,
GameType::starfield => libloot::GameType::Starfield,
GameType::openmw => libloot::GameType::OpenMW,
GameType::Oblivion => libloot::GameType::TES4,
GameType::Skyrim => libloot::GameType::TES5,
GameType::Fallout3 => libloot::GameType::FO3,
GameType::FalloutNV => libloot::GameType::FONV,
GameType::Fallout4 => libloot::GameType::FO4,
GameType::SkyrimSE => libloot::GameType::TES5SE,
GameType::Fallout4VR => libloot::GameType::FO4VR,
GameType::SkyrimVR => libloot::GameType::TES5VR,
GameType::Morrowind => libloot::GameType::TES3,
GameType::Starfield => libloot::GameType::Starfield,
GameType::OpenMW => libloot::GameType::OpenMW,
}
}
}
+98 -1
View File
@@ -1,4 +1,100 @@
#![deny(clippy::all)]
// Deny some rustc lints that are allow-by-default.
#![deny(
ambiguous_negative_literals,
impl_trait_overcaptures,
let_underscore_drop,
missing_copy_implementations,
missing_debug_implementations,
non_ascii_idents,
redundant_imports,
redundant_lifetimes,
trivial_casts,
trivial_numeric_casts,
unit_bindings,
unreachable_pub,
unsafe_code
)]
#![deny(clippy::pedantic)]
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::must_use_candidate)]
#![allow(clippy::needless_pass_by_value)]
// Selectively deny clippy restriction lints.
#![deny(
clippy::allow_attributes,
clippy::as_conversions,
clippy::as_underscore,
clippy::assertions_on_result_states,
clippy::big_endian_bytes,
clippy::clone_on_ref_ptr,
clippy::create_dir,
clippy::dbg_macro,
clippy::decimal_literal_representation,
clippy::default_numeric_fallback,
clippy::doc_include_without_cfg,
clippy::empty_drop,
clippy::error_impl_error,
clippy::exit,
// clippy::exhaustive_enums,
clippy::expect_used,
clippy::filetype_is_file,
clippy::float_cmp_const,
clippy::fn_to_numeric_cast_any,
clippy::get_unwrap,
clippy::host_endian_bytes,
clippy::if_then_some_else_none,
clippy::indexing_slicing,
clippy::infinite_loop,
clippy::integer_division,
clippy::integer_division_remainder_used,
clippy::iter_over_hash_type,
clippy::let_underscore_must_use,
clippy::lossy_float_literal,
clippy::map_err_ignore,
clippy::map_with_unused_argument_over_ranges,
clippy::mem_forget,
clippy::missing_assert_message,
clippy::missing_asserts_for_indexing,
clippy::missing_asserts_for_indexing,
clippy::mixed_read_write_in_expression,
clippy::multiple_inherent_impl,
clippy::multiple_unsafe_ops_per_block,
clippy::mutex_atomic,
clippy::mutex_integer,
clippy::needless_raw_strings,
clippy::non_ascii_literal,
clippy::non_zero_suggestions,
clippy::panic,
clippy::panic_in_result_fn,
clippy::partial_pub_fields,
clippy::pathbuf_init_then_push,
clippy::precedence_bits,
clippy::print_stderr,
clippy::print_stdout,
clippy::rc_buffer,
clippy::rc_mutex,
clippy::redundant_type_annotations,
clippy::ref_patterns,
clippy::rest_pat_in_fully_bound_structs,
clippy::str_to_string,
clippy::string_lit_chars_any,
clippy::string_slice,
clippy::string_to_string,
clippy::suspicious_xor_used_as_pow,
clippy::tests_outside_test_module,
clippy::todo,
clippy::try_err,
clippy::undocumented_unsafe_blocks,
clippy::unimplemented,
clippy::unnecessary_safety_comment,
clippy::unneeded_field_pattern,
clippy::unreachable,
clippy::unused_result_ok,
clippy::unwrap_in_result,
clippy::unwrap_used,
clippy::use_debug,
clippy::verbose_file_reads,
clippy::wildcard_enum_match_arm
)]
mod database;
mod error;
@@ -39,6 +135,7 @@ pub const LIBLOOT_VERSION_MINOR: u32 = libloot::LIBLOOT_VERSION_MINOR;
pub const LIBLOOT_VERSION_PATCH: u32 = libloot::LIBLOOT_VERSION_PATCH;
#[napi]
#[derive(Debug)]
pub enum LogLevel {
Trace,
Debug,
+11 -8
View File
@@ -4,7 +4,7 @@ use napi_derive::napi;
use crate::error::VerboseError;
#[napi]
#[derive(Clone)]
#[derive(Clone, Debug)]
#[repr(transparent)]
pub struct Group(libloot::metadata::Group);
@@ -73,7 +73,7 @@ impl From<Group> for libloot::metadata::Group {
}
#[napi]
#[derive(Clone)]
#[derive(Clone, Debug)]
#[repr(transparent)]
pub struct MessageContent(libloot::metadata::MessageContent);
@@ -135,6 +135,7 @@ pub fn select_message_content(
}
#[napi]
#[derive(Debug)]
pub enum MessageType {
Say,
Warn,
@@ -162,7 +163,7 @@ impl From<MessageType> for libloot::metadata::MessageType {
}
#[napi]
#[derive(Clone)]
#[derive(Clone, Debug)]
#[repr(transparent)]
pub struct Message(libloot::metadata::Message);
@@ -223,7 +224,7 @@ impl From<Message> for libloot::metadata::Message {
}
#[napi]
#[derive(Clone)]
#[derive(Clone, Debug)]
#[repr(transparent)]
pub struct File(libloot::metadata::File);
@@ -320,6 +321,7 @@ impl From<File> for libloot::metadata::File {
}
#[napi]
#[derive(Debug)]
#[repr(transparent)]
pub struct Filename(libloot::metadata::Filename);
@@ -343,7 +345,7 @@ impl From<libloot::metadata::Filename> for Filename {
}
#[napi]
#[derive(Clone)]
#[derive(Clone, Debug)]
#[repr(transparent)]
pub struct PluginCleaningData(libloot::metadata::PluginCleaningData);
@@ -446,6 +448,7 @@ impl From<PluginCleaningData> for libloot::metadata::PluginCleaningData {
}
#[napi]
#[derive(Debug)]
pub enum TagSuggestion {
Addition,
Removal,
@@ -461,7 +464,7 @@ impl From<TagSuggestion> for libloot::metadata::TagSuggestion {
}
#[napi]
#[derive(Clone)]
#[derive(Clone, Debug)]
#[repr(transparent)]
pub struct Tag(libloot::metadata::Tag);
@@ -512,7 +515,7 @@ impl From<Tag> for libloot::metadata::Tag {
}
#[napi]
#[derive(Clone)]
#[derive(Clone, Debug)]
#[repr(transparent)]
pub struct Location(libloot::metadata::Location);
@@ -558,7 +561,7 @@ impl From<Location> for libloot::metadata::Location {
}
#[napi]
#[derive(Clone)]
#[derive(Clone, Debug)]
#[repr(transparent)]
pub struct PluginMetadata(libloot::metadata::PluginMetadata);