Skip to content

Commit

Permalink
refactor: update lints to embark lints 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
DeanBDean committed Mar 20, 2021
1 parent ed5cc10 commit 9bd18e6
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 49 deletions.
56 changes: 37 additions & 19 deletions puffin-imgui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,58 @@
//! # fn slow_code(){}
//! ```
#![forbid(unsafe_code)]
// BEGIN - Embark standard lints v0.3
// do not change or add/remove here, but one can add exceptions after this section
// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
#![deny(unsafe_code)]
#![warn(
clippy::all,
clippy::doc_markdown,
clippy::await_holding_lock,
clippy::dbg_macro,
clippy::todo,
clippy::debug_assert_with_mut_call,
clippy::doc_markdown,
clippy::empty_enum,
clippy::enum_glob_use,
clippy::pub_enum_variant_names,
clippy::mem_forget,
//clippy::use_self, // disabled for now due to https://github.com/rust-lang/rust-clippy/issues/3410
clippy::exit,
clippy::explicit_into_iter_loop,
clippy::filter_map_next,
clippy::needless_continue,
clippy::needless_borrow,
clippy::match_wildcard_for_single_variants,
clippy::fn_params_excessive_bools,
clippy::if_let_mutex,
clippy::mismatched_target_os,
clippy::await_holding_lock,
clippy::match_on_vec_items,
clippy::imprecise_flops,
//clippy::suboptimal_flops,
clippy::lossy_float_literal,
clippy::rest_pat_in_fully_bound_structs,
clippy::fn_params_excessive_bools,
clippy::exit,
clippy::inefficient_to_string,
clippy::large_types_passed_by_value,
clippy::let_unit_value,
clippy::linkedlist,
clippy::lossy_float_literal,
clippy::macro_use_imports,
clippy::map_err_ignore,
clippy::map_flatten,
clippy::map_unwrap_or,
clippy::match_on_vec_items,
clippy::match_same_arms,
clippy::match_wildcard_for_single_variants,
clippy::mem_forget,
clippy::mismatched_target_os,
clippy::needless_borrow,
clippy::needless_continue,
clippy::option_option,
clippy::pub_enum_variant_names,
clippy::ref_option_ref,
clippy::rest_pat_in_fully_bound_structs,
clippy::string_add_assign,
clippy::string_add,
clippy::string_to_string,
clippy::suboptimal_flops,
clippy::todo,
clippy::unimplemented,
clippy::unnested_or_patterns,
clippy::unused_self,
clippy::verbose_file_reads,
rust_2018_idioms,
future_incompatible,
nonstandard_style
nonstandard_style,
rust_2018_idioms
)]
// END - Embark standard lints v0.3

mod ui;
pub use ui::*;
16 changes: 9 additions & 7 deletions puffin-imgui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ impl<'ui> Painter<'ui> {
}

fn pixel_from_ns(&self, options: &Options, ns: NanoSecond) -> f32 {
self.canvas_min.x
+ options.sideways_pan_in_pixels
+ ((ns - options.start_ns) as f32) * options.pixels_per_ns
((ns - options.start_ns) as f32).mul_add(
options.pixels_per_ns,
self.canvas_min.x + options.sideways_pan_in_pixels,
)
}
}

Expand Down Expand Up @@ -356,8 +357,9 @@ impl ProfilerUi {

self.options.pixels_per_ns *= zoom_factor;
let zoom_center = painter.mouse_pos.x - painter.canvas_min.x;
self.options.sideways_pan_in_pixels =
(self.options.sideways_pan_in_pixels - zoom_center) * zoom_factor + zoom_center;
self.options.sideways_pan_in_pixels = (self.options.sideways_pan_in_pixels
- zoom_center)
.mul_add(zoom_factor, zoom_center);
}
}
}
Expand Down Expand Up @@ -385,7 +387,7 @@ fn paint_timeline(
// We fade in lines as we zoom in:
let num_tiny_lines = canvas_width_ns / (grid_spacing_ns as f32);
let zoom_factor = remap_clamp(num_tiny_lines, (0.1 * max_lines)..=max_lines, 1.0..=0.0);
let zoom_factor = zoom_factor.powi(2);
let zoom_factor = zoom_factor * zoom_factor;
let big_alpha = remap_clamp(zoom_factor, 0.0..=1.0, 0.5..=1.0);
let medium_alpha = remap_clamp(zoom_factor, 0.0..=1.0, 0.1..=0.5);
let tiny_alpha = remap_clamp(zoom_factor, 0.0..=1.0, 0.0..=0.1);
Expand Down Expand Up @@ -526,7 +528,7 @@ fn paint_record(
painter.draw_list.add_text(
[
start_x + 4.0,
top_y + 0.5 * (options.rect_height - painter.font_size),
0.5f32.mul_add(options.rect_height - painter.font_size, top_y),
],
text_color,
text,
Expand Down
17 changes: 13 additions & 4 deletions puffin/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,11 @@ impl<'s> Reader<'s> {
/// and advance to the next sibling scope (if any).
fn parse_scope(&mut self) -> Result<Option<Scope<'s>>> {
match self.peek_u8() {
None => {
return Ok(None);
}
Some(SCOPE_BEGIN) => {
self.parse_u8()
.expect("swallowing already peeked SCOPE_BEGIN");
}
Some(_) => {
Some(_) | None => {
return Ok(None);
}
}
Expand Down Expand Up @@ -192,21 +189,33 @@ impl<'s> Reader<'s> {
value
}

#[allow(clippy::map_err_ignore)]
// Do not need to fix lint, because PrematureEnd has no means of
// capturing the original error
fn parse_u8(&mut self) -> Result<u8> {
self.0.read_u8().map_err(|_| Error::PrematureEnd)
}

#[allow(clippy::map_err_ignore)]
// Do not need to fix lint, because PrematureEnd has no means of
// capturing the original error
fn parse_nanos(&mut self) -> Result<NanoSecond> {
self.0.read_i64::<LE>().map_err(|_| Error::PrematureEnd)
}

#[allow(clippy::map_err_ignore)]
// Do not need to fix lint, because PrematureEnd has no means of
// capturing the original error
fn parse_scope_size(&mut self) -> Result<ScopeSize> {
self.0
.read_u64::<LE>()
.map_err(|_| Error::PrematureEnd)
.map(ScopeSize)
}

#[allow(clippy::map_err_ignore)]
// Do not need to fix lint, because PrematureEnd has no means of
// capturing the original error
fn parse_string(&mut self) -> Result<&'s str> {
let len = self.parse_u8().map_err(|_| Error::PrematureEnd)? as usize;
let data = self.0.get_ref();
Expand Down
55 changes: 36 additions & 19 deletions puffin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,56 @@
//! # fn slow_code(){}
//! ```
#![forbid(unsafe_code)]
// BEGIN - Embark standard lints v0.3
// do not change or add/remove here, but one can add exceptions after this section
// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
#![deny(unsafe_code)]
#![warn(
clippy::all,
clippy::doc_markdown,
clippy::await_holding_lock,
clippy::dbg_macro,
clippy::todo,
clippy::debug_assert_with_mut_call,
clippy::doc_markdown,
clippy::empty_enum,
clippy::enum_glob_use,
clippy::pub_enum_variant_names,
clippy::mem_forget,
//clippy::use_self, // disabled for now due to https://github.com/rust-lang/rust-clippy/issues/3410
clippy::exit,
clippy::explicit_into_iter_loop,
clippy::filter_map_next,
clippy::needless_continue,
clippy::needless_borrow,
clippy::match_wildcard_for_single_variants,
clippy::fn_params_excessive_bools,
clippy::if_let_mutex,
clippy::mismatched_target_os,
clippy::await_holding_lock,
clippy::match_on_vec_items,
clippy::imprecise_flops,
//clippy::suboptimal_flops,
clippy::lossy_float_literal,
clippy::rest_pat_in_fully_bound_structs,
clippy::fn_params_excessive_bools,
clippy::exit,
clippy::inefficient_to_string,
clippy::large_types_passed_by_value,
clippy::let_unit_value,
clippy::linkedlist,
clippy::lossy_float_literal,
clippy::macro_use_imports,
clippy::map_err_ignore,
clippy::map_flatten,
clippy::map_unwrap_or,
clippy::match_on_vec_items,
clippy::match_same_arms,
clippy::match_wildcard_for_single_variants,
clippy::mem_forget,
clippy::mismatched_target_os,
clippy::needless_borrow,
clippy::needless_continue,
clippy::option_option,
clippy::pub_enum_variant_names,
clippy::ref_option_ref,
clippy::rest_pat_in_fully_bound_structs,
clippy::string_add_assign,
clippy::string_add,
clippy::string_to_string,
clippy::suboptimal_flops,
clippy::todo,
clippy::unimplemented,
clippy::unnested_or_patterns,
clippy::unused_self,
clippy::verbose_file_reads,
rust_2018_idioms,
future_incompatible,
nonstandard_style
nonstandard_style,
rust_2018_idioms
)]

mod data;
Expand Down

0 comments on commit 9bd18e6

Please sign in to comment.