Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings #347

Merged
merged 50 commits into from
Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ac1dad1
blocks: fix redundant_field_names
iceiix Jun 29, 2020
842b4d8
blocks: fix missing panic_params in TreeVariant
iceiix Jun 29, 2020
f69b27c
blocks: allow clippy::identity_op because 1 << 0 is self-documenting …
iceiix Jun 29, 2020
d9a7015
blocks: fix useless_format, use .as_string()
iceiix Jun 29, 2020
c255edd
blocks: allow clippy::collapsible_if, represents data flow
iceiix Jun 29, 2020
d64316e
blocks: fix clippy::precedence use + not |
iceiix Jun 29, 2020
af9aa0e
Merge branch 'master' into clippy
iceiix Jun 29, 2020
6747ae1
blocks: fix redundant_field_names in macro
iceiix Jun 29, 2020
9621b23
protocol: fix redundant imports, single_component_path_imports
iceiix Jun 29, 2020
853f76b
protocol: fix redundant_static_lifetimes
iceiix Jun 29, 2020
07fed44
protocol: fix redundant_field_names
iceiix Jun 29, 2020
77394f0
protocol: use and_then, ok_or_else; option_map_or_none and or_fun_call
iceiix Jun 29, 2020
2f1c7b3
protocol: fix redundant_clone in access token
iceiix Jun 29, 2020
72f0595
protocol: fix wildcard_in_or_patterns
iceiix Jun 29, 2020
783e437
protocol: fix manually copying, use clone_from_slice, thanks clippy! …
iceiix Jun 29, 2020
66a787a
protocol: change UUID from_str to implement FromStr trait (should_imp…
iceiix Jun 30, 2020
cb8681a
protocol: use mutable iterator populating Biomes3D (needless_range_loop)
iceiix Jun 30, 2020
6267509
resources: use writeln macro, fixing write_with_newline
iceiix Jun 30, 2020
c3038f8
Remove redundant imports (single_component_path_imports)
iceiix Jun 30, 2020
c2e3ddb
Fix write_with_newline, use writeln
iceiix Jun 30, 2020
132b40c
Fix collapsible_if in main game loop
iceiix Jun 30, 2020
fe5cb47
Fix redundant field names in struct initialization (redundant_field_n…
iceiix Jun 30, 2020
e8c066c
Clippy: allow too_many_arguments, many_single_char_names
iceiix Jun 30, 2020
55856cc
Allow TeleportFlag enum variant names Rel..., Rel..., as they are all…
iceiix Jun 30, 2020
9d88168
Fix collapsible_if in lighting update
iceiix Jun 30, 2020
8fb5491
Add missing default implementations (new_without_default)
iceiix Jun 30, 2020
98dff0b
Fix redundant clones
iceiix Jun 30, 2020
3aaa14e
steven_gl: suppress clippy warnings in gl-generated code
iceiix Jul 1, 2020
b4aa23e
Use if let instead of map, fixes option_map_unit_fn
iceiix Jul 1, 2020
d496eaf
Use is_*() instead of if let x(_), fixes redundant_pattern_matching
iceiix Jul 1, 2020
8a0936f
Disable clippy::let_and_return for now in src/render/mod.rs
iceiix Jul 1, 2020
c4690bb
Use add(x) instead of offset(x as isize), fixes ptr_offset_with_cast
iceiix Jul 1, 2020
bffb332
Allow float_cmp since we use it to check if floating point values cha…
iceiix Jul 1, 2020
07fd478
Use += to fix assign_op_pattern
iceiix Jul 1, 2020
0f9dcd2
Use unwrap_or_else to fix two or_fun_call and suppress one
iceiix Jul 1, 2020
c274257
Change set_float_multi_raw to unsafe because it dereferences a raw po…
iceiix Jul 2, 2020
35f2970
Use question mark operator idiom (question_mark)
iceiix Jul 2, 2020
9939eae
Use values_mut() to iterate map values (for_kv_map)
iceiix Jul 3, 2020
2e2c82e
Use if let pattern match to fix unnecessary_wrap
iceiix Jul 3, 2020
deb35db
Use more descriptive name to fix blacklisted_name 'bar' (as in foobar)
iceiix Jul 3, 2020
113abef
Fix unnecessary use of match with if let (single_match)
iceiix Jul 3, 2020
7f5ab06
Use !is_empty instead of length check (len_zero)
iceiix Jul 3, 2020
f88036e
Use byte literal b"" instead of as_bytes (string_lit_as_bytes)
iceiix Jul 3, 2020
0d1e86a
Box block update sign text to reduce enum size from 268 bytes (large_…
iceiix Jul 3, 2020
7ef1734
Suppress needless_range_loop in chunk loading for clarity -- it will …
iceiix Jul 3, 2020
5ce06c3
Suppress type_complexity, would not be clarified by using a type defi…
iceiix Jul 3, 2020
476d46c
Use into_*(self) convention, fixes wrong_self_convention
iceiix Jul 3, 2020
9cfb686
Use cmp match to replace if chain (comparison_chain)
iceiix Jul 3, 2020
337ee74
Allow verbose bit mask because this is in a performance-critical path…
iceiix Jul 3, 2020
bb6d856
Azure: fail on clippy all (deny)
iceiix Jul 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
displayName: "Install build dependencies"
condition: eq(variables['Agent.OS'], 'Linux')
minrust: 1.44.1
clippy: -A clippy::not_unsafe_ptr_arg_deref -A clippy::float_cmp
clippy: -D clippy::all

resources:
repositories:
Expand Down
88 changes: 45 additions & 43 deletions blocks/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![recursion_limit = "600"]
#![allow(clippy::identity_op)]
#![allow(clippy::collapsible_if)]

extern crate steven_shared as shared;

Expand Down Expand Up @@ -261,7 +263,7 @@ macro_rules! define_blocks {
return $update_state;
)?
Block::$name {
$($fname: $fname,)?
$($fname,)?
}
}
)+
Expand Down Expand Up @@ -376,7 +378,7 @@ macro_rules! define_blocks {
$($fname: $fname.next().unwrap(),)?
},
state: CombinationIterState {
$($fname: $fname,)?
$($fname,)?
}
}
}
Expand Down Expand Up @@ -570,9 +572,9 @@ define_blocks! {
}
},
update_state (world, pos) => if variant == DirtVariant::Podzol {
Block::Dirt{snowy: is_snowy(world, pos), variant: variant}
Block::Dirt{snowy: is_snowy(world, pos), variant}
} else {
Block::Dirt{snowy: snowy, variant: variant}
Block::Dirt{snowy, variant}
},
}
Cobblestone {
Expand Down Expand Up @@ -774,7 +776,7 @@ define_blocks! {
offset if check_decay {
None
} else {
Some(variant.offset() * (7 * 2) + ((distance as usize - 1) << 1) | (if decayable { 0 } else { 1 }))
Some(variant.offset() * (7 * 2) + ((distance as usize - 1) << 1) + (if decayable { 0 } else { 1 }))
},
material material::LEAVES,
model { ("minecraft", format!("{}_leaves", variant.as_string()) ) },
Expand Down Expand Up @@ -1337,7 +1339,7 @@ define_blocks! {
collision vec![],
update_state (world, pos) => {
Fire{
age: age,
age,
up: can_burn(world, pos.shift(Direction::Up)),
north: can_burn(world, pos.shift(Direction::North)),
south: can_burn(world, pos.shift(Direction::South)),
Expand Down Expand Up @@ -1438,7 +1440,7 @@ define_blocks! {
south: can_connect_redstone(world, pos, Direction::South),
west: can_connect_redstone(world, pos, Direction::West),
east: can_connect_redstone(world, pos, Direction::East),
power: power
power
},
multipart (key, val) => match key {
"north" => val.contains(north.as_string()),
Expand Down Expand Up @@ -1565,7 +1567,7 @@ define_blocks! {
collision door_collision(facing, hinge, open),
update_state (world, pos) => {
let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered);
Block::WoodenDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered}
Block::WoodenDoor{facing, half, hinge, open, powered}
},
}
Ladder {
Expand Down Expand Up @@ -1702,7 +1704,7 @@ define_blocks! {
collision door_collision(facing, hinge, open),
update_state (world, pos) => {
let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered);
Block::IronDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered}
Block::IronDoor{facing, half, hinge, open, powered}
},
}
WoodenPressurePlate {
Expand Down Expand Up @@ -2088,7 +2090,7 @@ define_blocks! {
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 1.0/8.0, 1.0)
)],
update_state (world, pos) => RepeaterPowered{delay: delay, facing: facing, locked: update_repeater_state(world, pos, facing)},
update_state (world, pos) => RepeaterPowered{delay, facing, locked: update_repeater_state(world, pos, facing)},
}
StainedGlass {
props {
Expand Down Expand Up @@ -2222,7 +2224,7 @@ define_blocks! {
data None::<usize>,
offset mushroom_block_offset(false, west, up, south, north, east, down),
model { ("minecraft", "mushroom_stem") },
variant format!("variant=all_stem"),
variant "variant=all_stem".to_string(),
}
IronBars {
props {
Expand Down Expand Up @@ -2380,7 +2382,7 @@ define_blocks! {
_ => Direction::Up,
};

Block::PumpkinStem{age: age, facing: facing}
Block::PumpkinStem{age, facing}
},
}
MelonStem {
Expand Down Expand Up @@ -2416,7 +2418,7 @@ define_blocks! {
_ => Direction::Up,
};

Block::MelonStem{age: age, facing: facing}
Block::MelonStem{age, facing}
},
}
Vine {
Expand Down Expand Up @@ -2448,7 +2450,7 @@ define_blocks! {
update_state (world, pos) => {
let mat = world.get_block(pos.shift(Direction::Up)).get_material();
let up = mat.renderable && (mat.should_cull_against || mat.never_cull /* Because leaves */);
Vine{up: up, south: south, west: west, north: north, east: east}
Vine{up, south, west, north, east}
},
}
FenceGate {
Expand All @@ -2470,10 +2472,10 @@ define_blocks! {
variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open),
collision fence_gate_collision(facing, in_wall, open),
update_state (world, pos) => Block::FenceGate{
facing: facing,
facing,
in_wall: fence_gate_update_state(world, pos, facing),
open: open,
powered: powered
open,
powered
},
}
BrickStairs {
Expand Down Expand Up @@ -2930,14 +2932,14 @@ define_blocks! {
};

Tripwire{
powered: powered,
attached: attached,
disarmed: disarmed,
powered,
attached,
disarmed,
north: f(Direction::North),
south: f(Direction::South),
west: f(Direction::West),
east: f(Direction::East),
mojang_cant_even: mojang_cant_even
mojang_cant_even
}
},
}
Expand Down Expand Up @@ -4206,10 +4208,10 @@ define_blocks! {
variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open),
collision fence_gate_collision(facing, in_wall, open),
update_state (world, pos) => Block::SpruceFenceGate{
facing: facing,
facing,
in_wall: fence_gate_update_state(world, pos, facing),
open: open,
powered: powered
open,
powered
},
}
BirchFenceGate {
Expand All @@ -4231,10 +4233,10 @@ define_blocks! {
variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open),
collision fence_gate_collision(facing, in_wall, open),
update_state (world, pos) => Block::BirchFenceGate{
facing: facing,
facing,
in_wall: fence_gate_update_state(world, pos, facing),
open: open,
powered: powered
open,
powered
},
}
JungleFenceGate {
Expand All @@ -4256,10 +4258,10 @@ define_blocks! {
variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open),
collision fence_gate_collision(facing, in_wall, open),
update_state (world, pos) => Block::JungleFenceGate{
facing: facing,
facing,
in_wall: fence_gate_update_state(world, pos, facing),
open: open,
powered: powered
open,
powered
},
}
DarkOakFenceGate {
Expand All @@ -4281,10 +4283,10 @@ define_blocks! {
variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open),
collision fence_gate_collision(facing, in_wall, open),
update_state (world, pos) => Block::DarkOakFenceGate{
facing: facing,
facing,
in_wall: fence_gate_update_state(world, pos, facing),
open: open,
powered: powered
open,
powered
},
}
AcaciaFenceGate {
Expand All @@ -4306,10 +4308,10 @@ define_blocks! {
variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open),
collision fence_gate_collision(facing, in_wall, open),
update_state (world, pos) => Block::AcaciaFenceGate{
facing: facing,
facing,
in_wall: fence_gate_update_state(world, pos, facing),
open: open,
powered: powered
open,
powered
},
}
SpruceFence {
Expand Down Expand Up @@ -4478,7 +4480,7 @@ define_blocks! {
collision door_collision(facing, hinge, open),
update_state (world, pos) => {
let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered);
Block::SpruceDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered}
Block::SpruceDoor{facing, half, hinge, open, powered}
},
}
BirchDoor {
Expand All @@ -4502,7 +4504,7 @@ define_blocks! {
collision door_collision(facing, hinge, open),
update_state (world, pos) => {
let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered);
Block::BirchDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered}
Block::BirchDoor{facing, half, hinge, open, powered}
},
}
JungleDoor {
Expand All @@ -4526,7 +4528,7 @@ define_blocks! {
collision door_collision(facing, hinge, open),
update_state (world, pos) => {
let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered);
Block::JungleDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered}
Block::JungleDoor{facing, half, hinge, open, powered}
},
}
AcaciaDoor {
Expand All @@ -4550,7 +4552,7 @@ define_blocks! {
collision door_collision(facing, hinge, open),
update_state (world, pos) => {
let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered);
Block::AcaciaDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered}
Block::AcaciaDoor{facing, half, hinge, open, powered}
},
}
DarkOakDoor {
Expand All @@ -4574,7 +4576,7 @@ define_blocks! {
collision door_collision(facing, hinge, open),
update_state (world, pos) => {
let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered);
Block::DarkOakDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered}
Block::DarkOakDoor{facing, half, hinge, open, powered}
},
}
EndRod {
Expand Down Expand Up @@ -7264,7 +7266,7 @@ impl TreeVariant {
TreeVariant::Spruce | TreeVariant::DarkOak => 1,
TreeVariant::Birch => 2,
TreeVariant::Jungle => 3,
_ => panic!("TreeVariant {:?} has no data (1.13+ only)"),
_ => panic!("TreeVariant {:?} has no data (1.13+ only)", self),
}
}

Expand Down Expand Up @@ -7293,7 +7295,7 @@ impl TreeVariant {
TreeVariant::Jungle => 3,
TreeVariant::Acacia => 4,
TreeVariant::DarkOak => 5,
_ => panic!("TreeVariant {:?} has no plank data (1.13+ only)"),
_ => panic!("TreeVariant {:?} has no plank data (1.13+ only)", self),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions gl/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
#![allow(clippy::unused_unit)]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::too_many_arguments)]
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
16 changes: 8 additions & 8 deletions protocol/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use serde_json;
use std::fmt;
use std::mem;

Expand Down Expand Up @@ -96,14 +95,14 @@ pub struct Modifier {
impl Modifier {
pub fn from_value(v: &serde_json::Value) -> Self {
let mut m = Modifier {
bold: v.get("bold").map_or(Option::None, |v| v.as_bool()),
italic: v.get("italic").map_or(Option::None, |v| v.as_bool()),
underlined: v.get("underlined").map_or(Option::None, |v| v.as_bool()),
strikethrough: v.get("strikethrough").map_or(Option::None, |v| v.as_bool()),
obfuscated: v.get("obfuscated").map_or(Option::None, |v| v.as_bool()),
bold: v.get("bold").and_then(|v| v.as_bool()),
italic: v.get("italic").and_then(|v| v.as_bool()),
underlined: v.get("underlined").and_then(|v| v.as_bool()),
strikethrough: v.get("strikethrough").and_then(|v| v.as_bool()),
obfuscated: v.get("obfuscated").and_then(|v| v.as_bool()),
color: v
.get("color")
.map_or(Option::None, |v| v.as_str())
.and_then(|v| v.as_str())
.map(|v| Color::from_string(&v.to_owned())),
extra: Option::None,
};
Expand Down Expand Up @@ -246,7 +245,8 @@ impl Color {
};
Color::RGB(r, g, b)
}
"white" | _ => Color::White,
"white" => Color::White,
_ => Color::White,
}
}

Expand Down
4 changes: 2 additions & 2 deletions protocol/src/protocol/forge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ impl Serializable for ModIdMapping {
}
}

pub static BLOCK_NAMESPACE: &'static str = "\u{1}";
pub static ITEM_NAMESPACE: &'static str = "\u{2}";
pub static BLOCK_NAMESPACE: &str = "\u{1}";
pub static ITEM_NAMESPACE: &str = "\u{2}";

#[derive(Debug)]
pub enum FmlHs {
Expand Down
Loading