Skip to content

Commit

Permalink
clippy cleanup and use workspace lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Grokmoo committed May 9, 2024
1 parent 148320c commit 4727d74
Show file tree
Hide file tree
Showing 21 changed files with 32 additions and 27 deletions.
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ members = [
"sulis_view",
]

[workspace.lints.clippy]
assigning_clones = "allow"
type_complexity = "allow"
map_clone = "allow"
collapsible_else_if = "allow"
collapsible_if = "allow"
manual_range_contains = "allow"

[workspace.dependencies]
base64 = "0.21"
chrono = "0.4"
Expand Down
3 changes: 3 additions & 0 deletions sulis_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "1.0.0"
authors = ["Jared Stephen <grok_moo@yahoo.com>"]
edition = "2021"

[lints]
workspace = true

[dependencies]
home = { workspace = true }
flexi_logger = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion sulis_core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ impl Config {
};

for key in RawClick::iter() {
if config.input.click_actions.get(key).is_none() {
if !config.input.click_actions.contains_key(key) {
return Err(Error::new(
ErrorKind::InvalidData,
"Must specify an action for each of Left, Right & Middle Click",
Expand Down
2 changes: 1 addition & 1 deletion sulis_core/src/io/glium_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl<'a> GliumRenderer<'a> {
}

fn create_texture_if_missing(&mut self, texture_id: &str, draw_list: &DrawList) {
if self.display.textures.get(texture_id).is_some() {
if self.display.textures.contains_key(texture_id) {
return;
}

Expand Down
2 changes: 0 additions & 2 deletions sulis_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Sulis. If not, see <http://www.gnu.org/licenses/>

#![allow(clippy::type_complexity)]

pub extern crate serde;
pub extern crate serde_json;
pub extern crate serde_yaml;
Expand Down
1 change: 0 additions & 1 deletion sulis_core/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ pub fn all_resources<V: ?Sized>(map: &HashMap<String, Rc<V>>) -> Vec<Rc<V>> {
}

pub fn get_resource<V: ?Sized>(id: &str, map: &HashMap<String, Rc<V>>) -> Option<Rc<V>> {
#[allow(clippy::map_clone)]
map.get(id).map(Rc::clone)
}

Expand Down
3 changes: 3 additions & 0 deletions sulis_editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "1.0.0"
authors = ["Jared Stephen <grok_moo@yahoo.com>"]
edition = "2021"

[lints]
workspace = true

[dependencies]
sulis_core = { path = "../sulis_core" }
sulis_module = { path = "../sulis_module" }
Expand Down
3 changes: 0 additions & 3 deletions sulis_editor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Sulis. If not, see <http://www.gnu.org/licenses/>

#![allow(clippy::type_complexity)]
#![allow(clippy::manual_range_contains)]

mod actor_picker;
use crate::actor_picker::ActorPicker;

Expand Down
3 changes: 3 additions & 0 deletions sulis_module/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "1.0.0"
authors = ["Jared Stephen <grok_moo@yahoo.com>"]
edition = "2021"

[lints]
workspace = true

[dependencies]
sulis_core = { path = "../sulis_core" }

Expand Down
1 change: 0 additions & 1 deletion sulis_module/src/generator/encounter_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ impl EncounterParams {
module: &Module,
) -> Result<EncounterParams, Error> {
EncounterParams::build(builder, |id| {
#[allow(clippy::map_clone)]
module.encounters.get(id).map(Rc::clone)
})
}
Expand Down
3 changes: 0 additions & 3 deletions sulis_module/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Sulis. If not, see <http://www.gnu.org/licenses/>

#![allow(clippy::manual_range_contains)]
#![allow(clippy::map_clone)]

#[macro_use]
extern crate log;

Expand Down
6 changes: 3 additions & 3 deletions sulis_module/src/loot_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl LootList {
id: String,
entry_in: EntryBuilder,
) -> Result<Entry, Error> {
if module.items.get(&id).is_none() {
if !module.items.contains_key(&id) {
warn!("Unable to find item '{}'", id);
return unable_to_create_error("loot_list", builder_id);
}
Expand All @@ -159,7 +159,7 @@ impl LootList {
if id == "none" {
continue;
}
if module.item_adjectives.get(&id).is_none() {
if !module.item_adjectives.contains_key(&id) {
warn!("Unable to find item adjective '{}'", id);
return unable_to_create_error("loot_list", builder_id);
}
Expand All @@ -173,7 +173,7 @@ impl LootList {
if id == "none" {
continue;
}
if module.item_adjectives.get(&id).is_none() {
if !module.item_adjectives.contains_key(&id) {
warn!("Unable to find item adjective '{}'", id);
return unable_to_create_error("loot_list", builder_id);
}
Expand Down
3 changes: 3 additions & 0 deletions sulis_state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "1.0.0"
authors = ["Jared Stephen <grok_moo@yahoo.com>"]
edition = "2021"

[lints]
workspace = true

[dependencies]
sulis_core = { path = "../sulis_core" }
sulis_module = { path = "../sulis_module" }
Expand Down
1 change: 0 additions & 1 deletion sulis_state/src/game_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,6 @@ impl GameState {
}

pub fn get_area_state(id: &str) -> Option<Rc<RefCell<AreaState>>> {
#[allow(clippy::map_clone)]
STATE.with(|s| s.borrow().as_ref().unwrap().areas.get(id).map(Rc::clone))
}

Expand Down
4 changes: 2 additions & 2 deletions sulis_state/src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,13 @@ impl Inventory {
if to_remove_primary.is_some() {
primary_count += 1;
}
if self.equipped.get(&slot).is_some() {
if self.equipped.contains_key(&slot) {
primary_count += 1;
}
if to_remove_alt.is_some() {
alt_count += 1;
}
if self.equipped.get(&alt_slot).is_some() {
if self.equipped.contains_key(&alt_slot) {
alt_count += 1;
}

Expand Down
3 changes: 0 additions & 3 deletions sulis_state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Sulis. If not, see <http://www.gnu.org/licenses/>

#![allow(clippy::type_complexity)]
#![allow(clippy::map_clone)]

#[macro_use]
extern crate log;

Expand Down
1 change: 0 additions & 1 deletion sulis_state/src/los_calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ fn cast_ray(
end_y: i32,
src_elev: u8,
) -> bool {
#[allow(clippy::collapsible_else_if)] // this block is logically easier to read when not collapsed
if (end_y - start_y).abs() < (end_x - start_x).abs() {
if start_x > end_x {
cast_low(
Expand Down
2 changes: 0 additions & 2 deletions sulis_state/src/script/area_targeter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ impl Shape {
points
}

#[allow(clippy::collapsible_if)]
fn get_points_line_internal(
&self,
start: Point,
Expand All @@ -445,7 +444,6 @@ impl Shape {
Some(size) => size,
};

#[allow(clippy::collapsible_else_if)] // this block is logically easier to read when not collapsed
let (points, concat) = if (end.y - start.y).abs() < (end.x - start.x).abs() {
if start.x > end.x {
let mut p = cast_low(end, start);
Expand Down
4 changes: 2 additions & 2 deletions sulis_state/src/script/script_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ impl CallbackData {
}

fn exec_surface_script(&self, kind: FuncKind, target: Option<usize>) {
if self.funcs.get(&kind).is_none() {
if !self.funcs.contains_key(&kind) {
return;
}

Expand Down Expand Up @@ -611,7 +611,7 @@ impl ScriptCallback for CallbackData {
fn on_exited_surface(&self, target: usize) {
// since it is called after the surface has been removed in some cases
// we cannot preserve the surface info for on_exited_surface scripts
if self.funcs.get(&FuncKind::OnExitedSurface).is_none() {
if !self.funcs.contains_key(&FuncKind::OnExitedSurface) {
return;
}

Expand Down
1 change: 0 additions & 1 deletion sulis_state/src/script/script_entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,6 @@ impl UserData for ScriptEntity {
Ok(())
});

#[allow(clippy::type_complexity)]
methods.add_method(
"special_attack",
|_,
Expand Down
3 changes: 3 additions & 0 deletions sulis_view/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "1.0.0"
authors = ["Jared Stephen <grok_moo@yahoo.com>"]
edition = "2021"

[lints]
workspace = true

[dependencies]
sulis_core = { path = "../sulis_core" }
sulis_module = { path = "../sulis_module" }
Expand Down

0 comments on commit 4727d74

Please sign in to comment.