Skip to content

Commit

Permalink
Standardize lints across crates
Browse files Browse the repository at this point in the history
More clippy lints will be fixed later.
  • Loading branch information
rj00a committed Jun 9, 2024
1 parent db87e74 commit 3a98063
Show file tree
Hide file tree
Showing 70 changed files with 267 additions and 376 deletions.
111 changes: 111 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ keywords = ["minecraft", "gamedev", "server", "ecs"]
categories = ["game-engines"]
include = ["/src", "/benches", "/examples", "/README.md", "/LICENSE.txt"]

[lints]
workspace = true

[features]
default = [
"advancement",
Expand Down Expand Up @@ -207,3 +210,111 @@ valence_text = { path = "crates/valence_text", version = "0.2.0-alpha.1" }
valence_weather = { path = "crates/valence_weather", version = "0.2.0-alpha.1" }
valence_world_border = { path = "crates/valence_world_border", version = "0.2.0-alpha.1" }
zip = "0.6.3"

[workspace.lints.rust]
# missing_debug_implementations = "warn" # TODO: enable me.
# missing_docs = "warn"
nonstandard_style = "warn"
rust_2018_idioms = "warn"
elided_lifetimes_in_paths = "allow" # TODO: Remove me?
trivial_numeric_casts = "warn"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(unstable_doc)'] }
unreachable_pub = "warn"
unused_import_braces = "warn"
unused_lifetimes = "warn"

[workspace.lints.clippy]
alloc_instead_of_core = "warn"
as_ptr_cast_mut = "warn"
as_underscore = "warn"
bool_to_int_with_if = "warn"
case_sensitive_file_extension_comparisons = "warn"
cast_lossless = "warn"
checked_conversions = "warn"
cloned_instead_of_copied = "warn"
copy_iterator = "warn"
dbg_macro = "warn"
doc_link_with_quotes = "warn"
doc_markdown = "warn"
empty_enum_variants_with_brackets = "warn"
empty_structs_with_brackets = "warn"
explicit_deref_methods = "warn"
explicit_into_iter_loop = "warn"
explicit_iter_loop = "warn"
filter_map_next = "warn"
flat_map_option = "warn"
format_push_string = "warn"
from_iter_instead_of_collect = "warn"
get_unwrap = "warn"
if_then_some_else_none = "warn"
ignored_unit_patterns = "warn"
impl_trait_in_params = "warn"
implicit_clone = "warn"
inconsistent_struct_constructor = "warn"
inefficient_to_string = "warn"
infinite_loop = "warn"
into_iter_without_iter = "warn"
invalid_upcast_comparisons = "warn"
iter_filter_is_ok = "warn"
iter_filter_is_some = "warn"
iter_not_returning_iterator = "warn"
iter_over_hash_type = "warn"
iter_without_into_iter = "warn"
large_stack_arrays = "warn"
large_types_passed_by_value = "warn"
macro_use_imports = "warn"
manual_assert = "warn"
manual_instant_elapsed = "warn"
manual_is_variant_and = "warn"
manual_let_else = "warn"
manual_ok_or = "warn"
manual_string_new = "warn"
map_unwrap_or = "warn"
match_bool = "warn"
match_wildcard_for_single_variants = "warn"
mismatching_type_param_order = "warn"
missing_fields_in_debug = "warn"
mixed_read_write_in_expression = "warn"
mod_module_files = "warn"
multiple_inherent_impl = "warn"
mut_mut = "warn"
mutex_atomic = "warn"
needless_bitwise_bool = "warn"
needless_continue = "warn"
needless_for_each = "warn"
needless_raw_string_hashes = "warn"
needless_raw_strings = "warn"
negative_feature_names = "warn"
no_mangle_with_rust_abi = "warn"
option_as_ref_cloned = "warn"
pub_underscore_fields = "warn"
rc_buffer = "warn"
rc_mutex = "warn"
redundant_else = "warn"
redundant_feature_names = "warn"
ref_patterns = "warn"
rest_pat_in_fully_bound_structs = "warn"
semicolon_outside_block = "warn"
str_to_string = "warn"
string_lit_chars_any = "warn"
string_to_string = "warn"
struct_field_names = "warn"
tests_outside_test_module = "warn"
todo = "warn"
trivially_copy_pass_by_ref = "warn"
try_err = "warn"
# undocumented_unsafe_blocks = "warn"
uninlined_format_args = "warn"
unnecessary_join = "warn"
# unnecessary_safety_doc = "warn"
unnecessary_self_imports = "warn"
unneeded_field_pattern = "warn"
unnested_or_patterns = "warn"
unseparated_literal_suffix = "warn"
unused_self = "warn"
used_underscore_binding = "warn"
wildcard_dependencies = "warn"
zero_sized_map_values = "warn"

[workspace.lints.rustdoc]
unescaped_backticks = "warn"
3 changes: 3 additions & 0 deletions crates/java_string/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ repository.workspace = true
documentation.workspace = true
license.workspace = true

[lints]
workspace = true

[features]
serde = ["dep:serde"]

Expand Down
3 changes: 3 additions & 0 deletions crates/valence_advancement/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ repository.workspace = true
documentation.workspace = true
license.workspace = true

[lints]
workspace = true

[dependencies]
valence_server.workspace = true
bevy_app.workspace = true
Expand Down
1 change: 0 additions & 1 deletion crates/valence_advancement/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![doc = include_str!("../README.md")]
#![allow(clippy::type_complexity)]

pub mod event;

Expand Down
3 changes: 3 additions & 0 deletions crates/valence_anvil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ repository.workspace = true
documentation.workspace = true
license.workspace = true

[lints]
workspace = true

[features]
bevy_plugin = ["dep:bevy_app", "dep:bevy_ecs", "dep:flume", "parsing"]
parsing = ["dep:valence_server"]
Expand Down
17 changes: 0 additions & 17 deletions crates/valence_anvil/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
#![doc = include_str!("../README.md")]
#![deny(
rustdoc::broken_intra_doc_links,
rustdoc::private_intra_doc_links,
rustdoc::missing_crate_level_docs,
rustdoc::invalid_codeblock_attributes,
rustdoc::invalid_rust_codeblocks,
rustdoc::bare_urls,
rustdoc::invalid_html_tags
)]
#![warn(
trivial_casts,
trivial_numeric_casts,
unused_lifetimes,
unused_import_braces,
unreachable_pub,
clippy::dbg_macro
)]

use std::fs::{DirEntry, File};
use std::hash::Hash;
Expand Down
3 changes: 3 additions & 0 deletions crates/valence_boss_bar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ repository.workspace = true
documentation.workspace = true
license.workspace = true

[lints]
workspace = true

[dependencies]
valence_entity.workspace = true
valence_server.workspace = true
Expand Down
18 changes: 0 additions & 18 deletions crates/valence_boss_bar/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
#![doc = include_str!("../README.md")]
#![allow(clippy::type_complexity)]
#![deny(
rustdoc::broken_intra_doc_links,
rustdoc::private_intra_doc_links,
rustdoc::missing_crate_level_docs,
rustdoc::invalid_codeblock_attributes,
rustdoc::invalid_rust_codeblocks,
rustdoc::bare_urls,
rustdoc::invalid_html_tags
)]
#![warn(
trivial_casts,
trivial_numeric_casts,
unused_lifetimes,
unused_import_braces,
unreachable_pub,
clippy::dbg_macro
)]

use std::borrow::Cow;

Expand Down
3 changes: 3 additions & 0 deletions crates/valence_build_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ repository.workspace = true
documentation.workspace = true
license.workspace = true

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
syn.workspace = true
Expand Down
17 changes: 0 additions & 17 deletions crates/valence_build_utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
#![doc = include_str!("../README.md")]
#![deny(
rustdoc::broken_intra_doc_links,
rustdoc::private_intra_doc_links,
rustdoc::missing_crate_level_docs,
rustdoc::invalid_codeblock_attributes,
rustdoc::invalid_rust_codeblocks,
rustdoc::bare_urls,
rustdoc::invalid_html_tags
)]
#![warn(
trivial_casts,
trivial_numeric_casts,
unused_lifetimes,
unused_import_braces,
unreachable_pub,
clippy::dbg_macro
)]

use std::path::Path;
use std::process::Command;
Expand Down
3 changes: 3 additions & 0 deletions crates/valence_command/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ repository.workspace = true
documentation.workspace = true
license.workspace = true

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
bevy_app.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/valence_command/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct CommandResource<T: Command + Send + Sync> {
}

impl<T: Command + Send + Sync> CommandResource<T> {
pub fn new() -> Self {
fn new() -> Self {
CommandResource {
command: PhantomData,
executables: HashMap::new(),
Expand Down
3 changes: 3 additions & 0 deletions crates/valence_command_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ repository.workspace = true
documentation.workspace = true
license.workspace = true

[lints]
workspace = true

[lib]
proc-macro = true

Expand Down
3 changes: 3 additions & 0 deletions crates/valence_entity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ repository.workspace = true
documentation.workspace = true
license.workspace = true

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
bevy_app.workspace = true
Expand Down
8 changes: 4 additions & 4 deletions crates/valence_entity/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct BlockPos {
}

impl Value {
pub fn type_id(&self) -> u8 {
fn type_id(&self) -> u8 {
match self {
Value::Byte(_) => 0,
Value::Integer(_) => 1,
Expand Down Expand Up @@ -129,7 +129,7 @@ impl Value {
}
}

pub fn field_type(&self) -> TokenStream {
fn field_type(&self) -> TokenStream {
match self {
Value::Byte(_) => quote!(i8),
Value::Integer(_) => quote!(i32),
Expand Down Expand Up @@ -162,7 +162,7 @@ impl Value {
}
}

pub fn default_expr(&self) -> TokenStream {
fn default_expr(&self) -> TokenStream {
match self {
Value::Byte(b) => quote!(#b),
Value::Integer(i) => quote!(#i),
Expand Down Expand Up @@ -266,7 +266,7 @@ impl Value {
}
}

pub fn encodable_expr(&self, self_lvalue: TokenStream) -> TokenStream {
fn encodable_expr(&self, self_lvalue: TokenStream) -> TokenStream {
match self {
Value::Integer(_) => quote!(VarInt(#self_lvalue)),
Value::OptionalInt(_) => quote!(OptionalInt(#self_lvalue)),
Expand Down
18 changes: 0 additions & 18 deletions crates/valence_entity/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
#![doc = include_str!("../README.md")]
#![deny(
rustdoc::broken_intra_doc_links,
rustdoc::private_intra_doc_links,
rustdoc::missing_crate_level_docs,
rustdoc::invalid_codeblock_attributes,
rustdoc::invalid_rust_codeblocks,
rustdoc::bare_urls,
rustdoc::invalid_html_tags
)]
#![warn(
trivial_casts,
trivial_numeric_casts,
unused_lifetimes,
unused_import_braces,
unreachable_pub,
clippy::dbg_macro
)]
#![allow(clippy::type_complexity)]

pub mod active_status_effects;
pub mod attributes;
Expand Down
3 changes: 3 additions & 0 deletions crates/valence_generated/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ documentation.workspace = true
license.workspace = true
build = "build/main.rs"

[lints]
workspace = true

[dependencies]
valence_math.workspace = true
valence_ident.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/valence_generated/build/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct EntityAttribute {
max_value: f64,
}

pub fn build() -> anyhow::Result<TokenStream> {
pub(crate) fn build() -> anyhow::Result<TokenStream> {
rerun_if_changed(["extracted/attributes.json"]);

let entity_attributes: BTreeMap<String, EntityAttribute> =
Expand Down
6 changes: 3 additions & 3 deletions crates/valence_generated/build/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ struct Block {
}

impl Block {
pub fn min_state_id(&self) -> u16 {
pub(crate) fn min_state_id(&self) -> u16 {
self.states.iter().map(|s| s.id).min().unwrap()
}

pub fn max_state_id(&self) -> u16 {
pub(crate) fn max_state_id(&self) -> u16 {
self.states.iter().map(|s| s.id).max().unwrap()
}
}
Expand Down Expand Up @@ -69,7 +69,7 @@ struct Shape {
max_z: f64,
}

pub fn build() -> anyhow::Result<TokenStream> {
pub(crate) fn build() -> anyhow::Result<TokenStream> {
rerun_if_changed(["extracted/blocks.json"]);

let TopLevel {
Expand Down
2 changes: 1 addition & 1 deletion crates/valence_generated/build/chunk_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use quote::quote;
const MAX_VIEW_DIST: u8 = 32;
const EXTRA_VIEW_RADIUS: i32 = 2;

pub fn build() -> TokenStream {
pub(crate) fn build() -> TokenStream {
let entries = (0..=MAX_VIEW_DIST).map(|dist| {
let dist = dist as i32 + EXTRA_VIEW_RADIUS;

Expand Down
Loading

0 comments on commit 3a98063

Please sign in to comment.