Working MandelbrotModel singleton version #39
Annotations
1 error and 34 warnings
benchmark
No benchmark result was found in /home/runner/work/mandelbrot/mandelbrot/output.txt. Benchmark output was ''
|
unused import: `MandelbrotModel`:
src/main.rs#L3
warning: unused import: `MandelbrotModel`
--> src/main.rs:3:24
|
3 | use mandelbrot::{self, MandelbrotModel};
| ^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
|
this function has too many lines (106/100):
src/lib.rs#L366
warning: this function has too many lines (106/100)
--> src/lib.rs:366:1
|
366 | / pub fn run() -> Result<(), Box<dyn Error>> {
367 | | let mut mandelbrot_model = MandelbrotModel::get_instance();
368 | | //Coloring function
369 | | let mut coloring_function = COLORING_FUNCTION;
... |
491 | | Ok(())
492 | | }
| |_^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines
|
adding items after statements is confusing, since items exist from the start of the scope:
src/lib.rs#L315
warning: adding items after statements is confusing, since items exist from the start of the scope
--> src/lib.rs:315:5
|
315 | static RIGHT_MOUSE_RECORDER: MouseClickRecorder = MouseClickRecorder::new(MouseButton::Right);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
|
adding items after statements is confusing, since items exist from the start of the scope:
src/lib.rs#L314
warning: adding items after statements is confusing, since items exist from the start of the scope
--> src/lib.rs:314:5
|
314 | static LEFT_MOUSE_RECORDER: MouseClickRecorder = MouseClickRecorder::new(MouseButton::Left); //Static variable with interior mutabili...
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
= note: `#[warn(clippy::items_after_statements)]` implied by `#[warn(clippy::pedantic)]`
|
temporary with significant `Drop` can be early dropped:
src/lib.rs#L313
warning: temporary with significant `Drop` can be early dropped
--> src/lib.rs:313:9
|
312 | fn handle_mouse_events(window: &Window, coloring_function: ColoringFunction) {
| ______________________________________________________________________________-
313 | | let mandelbrot_model = MandelbrotModel::get_instance();
| | ^^^^^^^^^^^^^^^^
314 | | static LEFT_MOUSE_RECORDER: MouseClickRecorder = MouseClickRecorder::new(MouseButton::Left); //Static variable with interior mutabili...
315 | | static RIGHT_MOUSE_RECORDER: MouseClickRecorder = MouseClickRecorder::new(MouseButton::Right);
... |
327 | | }
328 | | }
| |_- temporary `mandelbrot_model` is currently being dropped at the end of its contained scope
|
= note: this might lead to unnecessary resource contention
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_tightening
help: merge the temporary construction with its single usage
|
313 ~
314 + MandelbrotModel::get_instance().;
|
help: remove separated single usage
|
320 - handle_left_mouse_clicked(x, y, &mandelbrot_model.c);
320 +
|
|
consider adding a `;` to the last statement for consistent formatting:
src/lib.rs#L306
warning: consider adding a `;` to the last statement for consistent formatting
--> src/lib.rs:306:13
|
306 | self.previous.store(current, Ordering::Relaxed)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `self.previous.store(current, Ordering::Relaxed);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
|
temporary with significant `Drop` can be early dropped:
src/lib.rs#L274
warning: temporary with significant `Drop` can be early dropped
--> src/lib.rs:274:13
|
273 | fn handle_right_mouse_clicked(x: f32, y: f32, coloring_function: ColoringFunction) {
| ____________________________________________________________________________________-
274 | | let mut mandelbrot_model = MandelbrotModel::get_instance();
| | ^^^^^^^^^^^^^^^^
275 | | println!("\nMouseButton::Right -> Move to ({x}, {y})");
276 | | let new_center = mandelbrot_model.c.complex_from_pixel_plane(x.into(), y.into());
... |
282 | | println!();
283 | | }
| |_- temporary `mandelbrot_model` is currently being dropped at the end of its contained scope
|
= note: this might lead to unnecessary resource contention
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_tightening
= note: `#[warn(clippy::significant_drop_tightening)]` implied by `#[warn(clippy::nursery)]`
help: drop the temporary after the end of its last usage
|
281 ~ mandelbrot_model.c.print();
282 + drop(mandelbrot_model);
|
|
consider adding a `;` to the last statement for consistent formatting:
src/lib.rs#L227
warning: consider adding a `;` to the last statement for consistent formatting
--> src/lib.rs:227:17
|
227 | println!("translation_amount: {}", mandelbrot_model.vars.translation_amount)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `println!("translation_amount: {}", mandelbrot_model.vars.translation_amount);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
|
consider adding a `;` to the last statement for consistent formatting:
src/lib.rs#L212
warning: consider adding a `;` to the last statement for consistent formatting
--> src/lib.rs:212:17
|
212 | / *coloring_function = pick_option(&[
213 | | ("HSV", TrueColor::new_from_hsv_colors),
214 | | ("Bernstein polynomials", TrueColor::new_from_bernstein_polynomials),
215 | | ])
| |__________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
help: add a `;` here
|
212 ~ *coloring_function = pick_option(&[
213 + ("HSV", TrueColor::new_from_hsv_colors),
214 + ("Bernstein polynomials", TrueColor::new_from_bernstein_polynomials),
215 + ]);
|
|
strict comparison of `f32` or `f64`:
src/lib.rs#L185
warning: strict comparison of `f32` or `f64`
--> src/lib.rs:185:20
|
185 | if mandelbrot_model.config.window_scale == 1.0 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(mandelbrot_model.config.window_scale - 1.0).abs() < error_margin`
|
= note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp
= note: `#[warn(clippy::float_cmp)]` implied by `#[warn(clippy::pedantic)]`
|
consider adding a `;` to the last statement for consistent formatting:
src/lib.rs#L165
warning: consider adding a `;` to the last statement for consistent formatting
--> src/lib.rs:165:17
|
165 | mandelbrot_model.c.scale(inverse_scaling_factor)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `mandelbrot_model.c.scale(inverse_scaling_factor);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
|
consider adding a `;` to the last statement for consistent formatting:
src/lib.rs#L161
warning: consider adding a `;` to the last statement for consistent formatting
--> src/lib.rs:161:17
|
161 | mandelbrot_model.c.scale(scaling_factor)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `mandelbrot_model.c.scale(scaling_factor);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
|
consider adding a `;` to the last statement for consistent formatting:
src/lib.rs#L152
warning: consider adding a `;` to the last statement for consistent formatting
--> src/lib.rs:152:17
|
152 | rendering::translate_and_render_efficiently(&mut mandelbrot_model, 0, columns, *coloring_function)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `rendering::translate_and_render_efficiently(&mut mandelbrot_model, 0, columns, *coloring_function);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
|
consider adding a `;` to the last statement for consistent formatting:
src/lib.rs#L148
warning: consider adding a `;` to the last statement for consistent formatting
--> src/lib.rs:148:17
|
148 | rendering::translate_and_render_efficiently(&mut mandelbrot_model, 0, columns, *coloring_function)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `rendering::translate_and_render_efficiently(&mut mandelbrot_model, 0, columns, *coloring_function);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
|
consider adding a `;` to the last statement for consistent formatting:
src/lib.rs#L144
warning: consider adding a `;` to the last statement for consistent formatting
--> src/lib.rs:144:17
|
144 | rendering::translate_and_render_efficiently(&mut mandelbrot_model, rows, 0, *coloring_function)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `rendering::translate_and_render_efficiently(&mut mandelbrot_model, rows, 0, *coloring_function);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
|
consider adding a `;` to the last statement for consistent formatting:
src/lib.rs#L140
warning: consider adding a `;` to the last statement for consistent formatting
--> src/lib.rs:140:17
|
140 | rendering::translate_and_render_efficiently(&mut mandelbrot_model, rows.into(), 0, *coloring_function)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `rendering::translate_and_render_efficiently(&mut mandelbrot_model, rows.into(), 0, *coloring_function);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
= note: `#[warn(clippy::semicolon_if_nothing_returned)]` implied by `#[warn(clippy::pedantic)]`
|
this function has too many lines (125/100):
src/lib.rs#L132
warning: this function has too many lines (125/100)
--> src/lib.rs:132:1
|
132 | / fn handle_key_events(window: &Window, k: &KeyBindings, coloring_function: &mut ColoringFunction) {
133 | | let mut mandelbrot_model = MandelbrotModel::get_instance();
134 | | if let Some(key) = window.get_keys_pressed(minifb::KeyRepeat::No).first() {
135 | | print!("\nKey pressed: ");
... |
257 | | }
258 | | }
| |_^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines
= note: `#[warn(clippy::too_many_lines)]` implied by `#[warn(clippy::pedantic)]`
|
docs for function which may panic missing `# Panics` section:
src/view/coloring.rs#L123
warning: docs for function which may panic missing `# Panics` section
--> src/view/coloring.rs:123:5
|
123 | pub fn get_color(&self, color: char) -> u8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: first possible panic found here
--> src/view/coloring.rs:124:9
|
124 | / assert!(
125 | | color == 'R' || color == 'G' || color == 'B',
126 | | "Error: color should be equal to R, G, or B, color = {}",
127 | | color
128 | | );
| |_________^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc
|
docs for function returning `Result` missing `# Errors` section:
src/view/coloring.rs#L43
warning: docs for function returning `Result` missing `# Errors` section
--> src/view/coloring.rs:43:5
|
43 | pub fn new(r_g_b: &str) -> Result<ColorChannelMapping, String> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc
= note: `#[warn(clippy::missing_errors_doc)]` implied by `#[warn(clippy::pedantic)]`
|
item in documentation is missing backticks:
src/view/coloring.rs#L10
warning: item in documentation is missing backticks
--> src/view/coloring.rs:10:10
|
10 | /// E.g: Ok(ColorChannelMapping::BGR) means that red will get the value of blue, green the value of green, and blue the value of red:
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
help: try
|
10 | /// E.g: `Ok(ColorChannelMapping::BGR`) means that red will get the value of blue, green the value of green, and blue the value of red:
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
item in documentation is missing backticks:
src/view/coloring.rs#L8
warning: item in documentation is missing backticks
--> src/view/coloring.rs:8:19
|
8 | ///A mapping from ColorChannelMapping -> RGB, the first character denotes the new red channel, the second character the new green channel,
| ^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
help: try
|
8 | ///A mapping from `ColorChannelMapping` -> RGB, the first character denotes the new red channel, the second character the new green channel,
| ~~~~~~~~~~~~~~~~~~~~~
|
the function has a cognitive complexity of (7/5):
src/model/rendering.rs#L108
warning: the function has a cognitive complexity of (7/5)
--> src/model/rendering.rs:108:41
|
108 | let handle = thread::spawn(move || {
| ^^
|
= help: you could split it up into multiple smaller functions
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity
note: the lint level is defined here
--> src/lib.rs:4:5
|
4 | clippy::nursery,
| ^^^^^^^^^^^^^^^
= note: `#[warn(clippy::cognitive_complexity)]` implied by `#[warn(clippy::nursery)]`
|
docs for function which may panic missing `# Panics` section:
src/model/mandelbrot_model.rs#L41
warning: docs for function which may panic missing `# Panics` section
--> src/model/mandelbrot_model.rs:41:5
|
41 | pub fn get_instance() -> MutexGuard<'static, MandelbrotModel> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: first possible panic found here
--> src/model/mandelbrot_model.rs:42:9
|
42 | MANDELBROT_MODEL_INSTANCE.lock().unwrap()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc
|
item in documentation is missing backticks:
src/model/mandelbrot_model.rs#L40
warning: item in documentation is missing backticks
--> src/model/mandelbrot_model.rs:40:31
|
40 | /// Returns the singleton MandelbrotModel instance.
| ^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
= note: `#[warn(clippy::doc_markdown)]` implied by `#[warn(clippy::pedantic)]`
help: try
|
40 | /// Returns the singleton `MandelbrotModel` instance.
| ~~~~~~~~~~~~~~~~~
|
using `clone` on type `Config` which implements the `Copy` trait:
src/model/mandelbrot_model.rs#L31
warning: using `clone` on type `Config` which implements the `Copy` trait
--> src/model/mandelbrot_model.rs:31:21
|
31 | config: config.clone(),
| ^^^^^^^^^^^^^^ help: try removing the `clone` call: `config`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
note: the lint level is defined here
--> src/lib.rs:9:5
|
9 | clippy::complexity
| ^^^^^^^^^^^^^^^^^^
= note: `#[warn(clippy::clone_on_copy)]` implied by `#[warn(clippy::complexity)]`
|
you should consider adding a `Default` implementation for `MandelbrotModel`:
src/model/mandelbrot_model.rs#L25
warning: you should consider adding a `Default` implementation for `MandelbrotModel`
--> src/model/mandelbrot_model.rs:25:5
|
25 | / pub fn new() -> MandelbrotModel {
26 | | let config = Config::build(env::args()).unwrap_or_else(|err| {
27 | | eprintln!("Problem parsing arguments: {}", err);
28 | | process::exit(1);
... |
37 | | }
38 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try adding this
|
24 + impl Default for MandelbrotModel {
25 + fn default() -> Self {
26 + Self::new()
27 + }
28 + }
|
|
docs for function which may panic missing `# Panics` section:
src/controller/user_input.rs#L31
warning: docs for function which may panic missing `# Panics` section
--> src/controller/user_input.rs:31:1
|
31 | pub fn get_user_input_untrimmed() -> String {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: first possible panic found here
--> src/controller/user_input.rs:34:5
|
34 | / io::stdin()
35 | | .read_line(&mut user_input)
36 | | .expect("Error: Failed to read the user's input from stdin.");
| |_____________________________________________________________________^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc
note: the lint level is defined here
--> src/lib.rs:3:5
|
3 | clippy::pedantic,
| ^^^^^^^^^^^^^^^^
= note: `#[warn(clippy::missing_panics_doc)]` implied by `#[warn(clippy::pedantic)]`
|
you should consider adding a `Default` implementation for `Config`:
src/controller/config.rs#L32
warning: you should consider adding a `Default` implementation for `Config`
--> src/controller/config.rs:32:5
|
32 | / pub fn new() -> Config {
33 | | Config {
34 | | window_width: WIDTH,
35 | | window_height: HEIGHT,
... |
42 | | }
43 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
note: the lint level is defined here
--> src/lib.rs:2:5
|
2 | clippy::all,
| ^^^^^^^^^^^
= note: `#[warn(clippy::new_without_default)]` implied by `#[warn(clippy::all)]`
help: try adding this
|
31 + impl Default for Config {
32 + fn default() -> Self {
33 + Self::new()
34 + }
35 + }
|
|
static `COLOR_CHANNEL_MAPPING` is never used:
src/lib.rs#L56
warning: static `COLOR_CHANNEL_MAPPING` is never used
--> src/lib.rs:56:8
|
56 | static COLOR_CHANNEL_MAPPING: ColorChannelMapping = ColorChannelMapping::RGB;
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
|
unused variable: `c`:
src/lib.rs#L264
warning: unused variable: `c`
--> src/lib.rs:264:46
|
264 | fn handle_left_mouse_clicked(x: f32, y: f32, c: &ComplexPlane) {
| ^ help: if this is intentional, prefix it with an underscore: `_c`
|
= note: `#[warn(unused_variables)]` on by default
|
unused import: `mandelbrot_model`:
src/lib.rs#L45
warning: unused import: `mandelbrot_model`
--> src/lib.rs:45:13
|
45 | use model::{mandelbrot_model, pixel_buffer, pixel_plane, rendering};
| ^^^^^^^^^^^^^^^^
|
unused import: `model::mandelbrot_function::MandelbrotFunction`:
src/lib.rs#L43
warning: unused import: `model::mandelbrot_function::MandelbrotFunction`
--> src/lib.rs:43:5
|
43 | use model::mandelbrot_function::MandelbrotFunction;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
|
clippy_check
The following actions uses node12 which is deprecated and will be forced to run on node16: actions-rs/clippy-check@v1. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
|
benchmark
The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
|