Skip to content

Commit

Permalink
feat(libmake): 🎨 additional lints in Cargo
Browse files Browse the repository at this point in the history
e incorporated a wide range of lint rules from both the Rust compiler and Clippy to enforce strict code quality standards
  • Loading branch information
sebastienrousseau committed Mar 15, 2024
1 parent cf3d8df commit 2d25256
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 75 deletions.
146 changes: 132 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,31 @@ path = "benches/criterion.rs"
debug = true

[dependencies]
anyhow = "1.0.77"
assert_cmd = "2.0.12"
clap = "4.4.12"
anyhow = "1.0.81"
assert_cmd = "2.0.14"
clap = "4.5.3"
csv = "1.3.0"
dtt = "0.0.5"
env_logger = "0.10.1"
env_logger = "0.11.3"
figlet-rs = "0.1.5"
openssl = { version = "0.10.62", features = ["vendored"] }
reqwest = { version = "0.11.23", features = ["blocking"] }
rlg = "0.0.2"
serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0.108"
serde_yaml = "0.9.29"
tempfile = "3.9.0"
toml = "0.8.8"
vrd = "0.0.5"
reqwest = { version = "0.11.26", features = ["blocking"] }
rlg = "0.0.3"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
serde_yaml = "0.9.32"
tempfile = "3.10.1"
toml = "0.8.11"
vrd = "0.0.6"
xtasks = "0.0.2"

# Unix platforms use OpenSSL for now to provide SSL functionality
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
openssl = { version = "0.10.64", features = ["vendored"] }


[dev-dependencies]
criterion = "0.5.1"
predicates = "3.0.4"
predicates = "3.1.0"

[lib]
crate-type = ["lib"]
Expand All @@ -83,6 +87,111 @@ required-features = []
[features]
default = []

# Linting config
[lints.rust]

## Forbid
missing_debug_implementations = "forbid"
missing_docs = "forbid"
non_ascii_idents = "forbid"
unreachable_pub = "forbid"
unsafe_code = "forbid"

## Deny
dead_code = "deny"
deprecated_in_future = "deny"
ellipsis_inclusive_range_patterns = "deny"
explicit_outlives_requirements = "deny"
future_incompatible = "deny"
keyword_idents = "deny"
macro_use_extern_crate = "deny"
meta_variable_misuse = "deny"
missing_fragment_specifier = "deny"
noop_method_call = "deny"
pointer_structural_match = "deny"
rust_2018_idioms = "deny"
rust_2021_compatibility = "deny"
single_use_lifetimes = "deny"
trivial_casts = "deny"
trivial_numeric_casts = "deny"
unused = "deny"
# unused_crate_dependencies = "deny"
# unused_extern_crates = "deny"
unused_features = "deny"
unused_import_braces = "deny"
unused_labels = "deny"
unused_lifetimes = "deny"
unused_macro_rules = "deny"
unused_qualifications = "deny"
variant_size_differences = "deny"

[lints.clippy]
## Allow
blocks_in_conditions = "allow"
cognitive_complexity = "allow"
field_reassign_with_default = "allow"
missing_errors_doc = "allow"
missing_panics_doc = "allow"
module_name_repetitions = "allow"
must_use_candidate = "allow"
needless_pass_by_value = "allow"
too_many_arguments = "allow"
type_complexity = "allow"

## Deny
all = "deny"
clone_on_ref_ptr = "deny"
create_dir = "deny"
dbg_macro = "deny"
default_numeric_fallback = "deny"
enum_glob_use = "deny"
expect_used = "deny"
float_cmp_const = "deny"
if_then_some_else_none = "deny"
inline_asm_x86_att_syntax = "deny"
inline_asm_x86_intel_syntax = "deny"
iter_not_returning_iterator = "deny"
large_stack_arrays = "deny"
let_underscore_must_use = "deny"
mem_forget = "deny"
mut_mut = "deny"
mutex_integer = "deny"
nonstandard_macro_braces = "deny"
nursery = "deny"
option_if_let_else = "deny"
panic = "deny"
pedantic = "deny"
print_stderr = "deny"
print_stdout = "deny"
range_minus_one = "deny"
rc_buffer = "deny"
rc_mutex = "deny"
rest_pat_in_fully_bound_structs = "deny"
same_name_method = "deny"
self_named_module_files = "deny"
string_add = "deny"
string_add_assign = "deny"
suspicious_operation_groupings = "deny"
todo = "deny"
trailing_empty_array = "deny"
transmute_ptr_to_ptr = "deny"
unimplemented = "deny"
unnecessary_wraps = "deny"
unneeded_field_pattern = "deny"
unreachable = "deny"
unused_unit = "deny"
unwrap_used = "deny"
use_debug = "deny"
use_self = "deny"
used_underscore_binding = "deny"
useless_conversion = "deny"
vec_init_then_push = "deny"
verbose_file_reads = "deny"
wildcard_dependencies = "deny"
wildcard_imports = "deny"
wrong_pub_self_convention = "deny"
wrong_self_convention = "deny"

[profile.dev]
codegen-units = 256
debug = true
Expand All @@ -107,6 +216,15 @@ panic = "abort"
rpath = false
strip = "symbols"

[profile.release-low]
codegen-units = 16
debug = false
debug-assertions = false
incremental = false
inherits = "release"
lto = "thin"
strip = "symbols"

[profile.test]
codegen-units = 256
debug = true
Expand Down
23 changes: 3 additions & 20 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,33 +62,21 @@
//! [`serde`]: https://github.com/serde-rs/serde
//! [0]: https://minifunctions.com/libmake "Mini Functions"
//!
#![allow(clippy::must_use_candidate)]
#![cfg_attr(feature = "bench", feature(test))]
#![deny(dead_code)]
#![deny(rustc::existing_doc_keyword)]
#![doc(
html_favicon_url = "https://kura.pro/libmake/images/favicon.ico",
html_logo_url = "https://kura.pro/libmake/images/logos/libmake.svg",
html_root_url = "https://docs.rs/libmake"
)]
#![forbid(missing_debug_implementations)]
#![forbid(missing_docs)]
#![forbid(unreachable_pub)]
#![forbid(unsafe_code)]
#![crate_name = "libmake"]
#![crate_type = "lib"]

// Import necessary dependencies
use crate::args::process_arguments;
use crate::ascii::generate_ascii_art;
use crate::cli::build;
use crate::loggers::init_logger;
use crate::{ascii::generate_ascii_art, cli::build};
use dtt::DateTime;
use rlg::{macro_log, LogFormat, LogLevel};
use std::error::Error;
use std::fs::File;
use std::io::Write;

use rlg::{log_format::LogFormat, log_level::LogLevel, macro_log};
use std::{error::Error, fs::File, io::Write};
/// The `args` module contains functions for processing command-line
/// arguments.
pub mod args;
Expand All @@ -103,8 +91,6 @@ pub mod generator;
/// The `interface` module contains functions for displaying the
/// interface.
pub mod interface;
/// The `loggers` module contains the loggers for the library.
pub mod loggers;
/// The `macros` module contains functions for generating macros.
pub mod macros;
/// The `utils` module contains a function for reading a CSV file at the
Expand Down Expand Up @@ -136,9 +122,6 @@ pub fn run() -> Result<(), Box<dyn Error>> {
let date = DateTime::new();
let iso = date.iso_8601;

// Initialize the logger using the `env_logger` crate
init_logger(None)?;

// Open the log file for appending
let mut log_file = File::create("./ssg.log")?;

Expand Down
41 changes: 0 additions & 41 deletions src/loggers.rs

This file was deleted.

0 comments on commit 2d25256

Please sign in to comment.