ratatui-org / ratatui

Rust library that's all about cooking up terminal user interfaces (TUIs) 👨‍🍳🐀
https://ratatui.rs
MIT License
8.82k stars 263 forks source link

refactor(lint): fix new lint warnings #1178

Closed EdJoPaTo closed 2 weeks ago

EdJoPaTo commented 3 weeks ago
codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.3%. Comparing base (d370aa7) to head (b7b8b41).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1178 +/- ## ===================================== Coverage 94.3% 94.3% ===================================== Files 60 60 Lines 14677 14677 ===================================== Hits 13841 13841 Misses 836 836 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

EdJoPaTo commented 2 weeks ago
warning: usage of a legacy numeric method
  --> src/layout/rect.rs:61:29
   |
61 |         let max_area = u16::max_value();
   |                             ^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants
   = note: `#[warn(clippy::legacy_numeric_constants)]` on by default
help: use the associated constant instead
   |
61 |         let max_area = u16::MAX;
   |                             ~~~

warning: unnecessary structure name repetition
  --> src/style/palette_conversion.rs:26:9
   |
26 |         Color::Rgb(red, green, blue)
   |         ^^^^^ help: use the applicable keyword: `Self`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self
   = note: requested on the command line with `-W clippy::use-self`

warning: unnecessary structure name repetition
  --> src/style/palette_conversion.rs:51:9
   |
51 |         Color::from(srgb_color)
   |         ^^^^^ help: use the applicable keyword: `Self`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self

warning: `ratatui` (lib) generated 3 warnings (run `cargo clippy --fix --lib -p ratatui` to apply 2 suggestions)
warning: `ratatui` (lib test) generated 3 warnings (3 duplicates)
warning: unnecessary structure name repetition
   --> examples/demo/app.rs:125:41
    |
125 |     pub fn new(titles: Vec<&'a str>) -> TabsState {
    |                                         ^^^^^^^^^ help: use the applicable keyword: `Self`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self
    = note: requested on the command line with `-W clippy::use-self`

warning: `ratatui` (example "demo") generated 1 warning (run `cargo clippy --fix --example "demo"` to apply 1 suggestion)
EdJoPaTo commented 2 weeks ago

nightly has even more warnings… not sure whether I should include them in this PR.

warning: doc list item missing indentation
 --> src/text.rs:8:5
  |
8 | //! [`Text`].
  |     ^
  |
  = help: if this is supposed to be its own paragraph, add a blank line
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation
  = note: `#[warn(clippy::doc_lazy_continuation)]` on by default
help: indent this line
  |
8 | //!   [`Text`].
  |     ++

warning: doc list item missing indentation
   --> src/widgets/block.rs:222:9
    |
222 |     /// the leftover space)
    |         ^
    |
    = help: if this is supposed to be its own paragraph, add a blank line
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation
help: indent this line
    |
222 |     ///   the leftover space)
    |         ++

warning: doc list item missing indentation
   --> src/widgets/list.rs:377:5
    |
377 | /// multi-line items
    |     ^
    |
    = help: if this is supposed to be its own paragraph, add a blank line
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation
help: indent this line
    |
377 | ///   multi-line items
    |     ++

warning: this could be a `const fn`
  --> src/widgets/reflow.rs:52:5
   |
52 | /     pub fn new(lines: O, max_line_width: u16, trim: bool) -> Self {
53 | |         Self {
54 | |             input_lines: lines,
55 | |             max_line_width,
...  |
60 | |         }
61 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn
   = note: requested on the command line with `-W clippy::missing-const-for-fn`

warning: this could be a `const fn`
   --> src/widgets/reflow.rs:251:5
    |
251 | /     pub fn new(lines: O, max_line_width: u16) -> Self {
252 | |         Self {
253 | |             input_lines: lines,
254 | |             max_line_width,
...   |
257 | |         }
258 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn

warning: `ratatui` (lib) generated 5 warnings
warning: this could be a `const fn`
   --> examples/demo/app.rs:125:5
    |
125 | /     pub fn new(titles: Vec<&'a str>) -> Self {
126 | |         Self { titles, index: 0 }
127 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn
    = note: requested on the command line with `-W clippy::missing-const-for-fn`

warning: `ratatui` (example "demo") generated 1 warning
warning: the borrowed expression implements the required traits
   --> src/widgets/table/table.rs:918:45
    |
918 |         let table = Table::default().widths(&vec![Constraint::Length(100)]);
    |                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `vec![Constraint::Length(100)]`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
    = note: `#[warn(clippy::needless_borrows_for_generic_args)]` on by default

warning: `ratatui` (lib test) generated 6 warnings (5 duplicates) (run `cargo clippy --fix --lib -p ratatui --tests` to apply 1 suggestion)
joshka commented 2 weeks ago

Thanks for listing those off.

nightly has even more warnings… not sure whether I should include them in this PR.

Yeah, probably another PR