getinstachip / vpm

Verilog package manager written in Rust
MIT License
127 stars 12 forks source link

CI : add lint and formater #35

Open mtb0x1 opened 2 months ago

mtb0x1 commented 2 months ago

Consider adding clippy and fmt steps to CI on push. There is a long list of warring, some are a bit noisy and other might point to a potential issues.

I can take this if needed.

Some examples:

warning: this `if` has identical blocks
   --> src/cmd/include.rs:290:52
    |
290 |             let iostandard = if port_name == "clk" { "LVCMOS33" } else { "LVCMOS33" };
    |                                                    ^^^^^^^^^^^^^^
    |
note: same as this
   --> src/cmd/include.rs:290:72
    |
290 |             let iostandard = if port_name == "clk" { "LVCMOS33" } else { "LVCMOS33" };
    |                                                                        ^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
    = note: `#[warn(clippy::if_same_then_else)]` on by default
warning: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
   --> src/cmd/include.rs:549:31
    |
549 | fn update_lockfile(full_path: &PathBuf, url: &str, contents: &str, visited: &HashSet<String>, is_top_module: bool) -> Result<()> {
    |                               ^^^^^^^^ help: change this to: `&Path`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
warning: useless use of `format!`
   --> src/cmd/include.rs:300:31
    |
300 |         xdc_content.push_str(&format!("create_clock -period 10.000 -name sys_clk_pin -waveform {{0.000 5.000}} -add [get_ports {{ clk }}]\n"));
    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"create_clock -period 10.000 -name sys_clk_pin -waveform {0.000 5.000} -add [get_ports { clk }]\n".to_string()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format
sathvikr commented 2 months ago

That would help a lot! Thanks for offering to take it. Will also ensure that warnings are minimized, but it would help :)