Ballasi / num2words

Convert numbers like 42 to forty-two
https://crates.io/crates/num2words
Apache License 2.0
17 stars 9 forks source link

Lots of Clippy Warnings #28

Open Laifsyn opened 7 months ago

Laifsyn commented 7 months ago

There's a lot of things that clippy isn't happy about. I was wondering if you plan to sort them out anytime. Also I got a file for rustfmt which uses nightly. In case you would like to use it. I personally like the option of grouping by modules


  --> src\lang\fr.rs:18:16
   |
18 | const UNITS: [&'static str; 9] = [
   |               -^^^^^^^---- help: consider removing `'static`: `&str`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes
   = note: `#[warn(clippy::redundant_static_lifetimes)]` on by default

warning: constants have by default a `'static` lifetime
  --> src\lang\fr.rs:22:15
   |
22 | const TENS: [&'static str; 9] = [
   |              -^^^^^^^---- help: consider removing `'static`: `&str`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes

warning: constants have by default a `'static` lifetime
  --> src\lang\fr.rs:34:16
   |
34 | const TEENS: [&'static str; 10] = [
   |               -^^^^^^^---- help: consider removing `'static`: `&str`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes

warning: constants have by default a `'static` lifetime
  --> src\lang\fr.rs:39:16
   |
39 | const MEGAS: [&'static str; 33] = [
   |               -^^^^^^^---- help: consider removing `'static`: `&str`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes

warning: useless conversion to the same type: `std::string::String`
   --> src\currency.rs:176:9
    |
176 | /         String::from(
177 | |             match self {
178 | |                 Currency::AED | Currency::KWD => "fils",
179 | |                 Currency::ARS | Currency::BRL | Currency::CLP | Currency::COP | Currency::MXN => {
...   |
192 | |             .replace("{}", if plural_form { "s" } else { "" }),
193 | |         )
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
    = note: `#[warn(clippy::useless_conversion)]` on by default
help: consider removing `String::from()`
    |
176 ~         match self {
177 +                 Currency::AED | Currency::KWD => "fils",
178 +                 Currency::ARS | Currency::BRL | Currency::CLP | Currency::COP | Currency::MXN => {
179 +                     "centavo{}"
180 +                 }
181 ~                 Currency::CRC => "céntimo{}",
182 +                 Currency::IDR | Currency::MYR => "sen{}",
183 +                 Currency::KRW => "jeon{}",
184 +                 Currency::SAR => "halalat{}",
185 +                 Currency::THB => "satang{}",
186 +                 Currency::UAH => "kopiyok{}",
187 +                 Currency::UYU => "centesimo{}",
188 +                 Currency::VND => "xu{}",
189 +                 _ => cent,
190 +             }
191 +             .replace("{}", if plural_form { "s" } else { "" })
    |

warning: module has the same name as its containing module
 --> src\lang\mod.rs:2:1
  |
2 | mod lang;
  | ^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_inception
  = note: `#[warn(clippy::module_inception)]` on by default

warning: called `is_some()` after searching an `Iterator` with `find`
   --> src\lang\lang.rs:104:18
    |
104 |                   .find(|v| ["feminine", "feminin", "féminin", "f"].contains(&v.as_str()))
    |  __________________^
105 | |                 .is_some();
    | |__________________________^ help: use `any()` instead: `any(|v| ["feminine", "feminin", "féminin", "f"].contains(&v.as_str()))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
    = note: `#[warn(clippy::search_is_some)]` on by default

warning: called `is_some()` after searching an `Iterator` with `find`
   --> src\lang\lang.rs:106:28
    |
106 |               let reformed = preferences
    |  ____________________________^
107 | |                 .iter()
108 | |                 .find(|v: &&String| {
109 | |                     ["reformed", "1990", "rectifié", "rectification"].contains(&v.as_str())
110 | |                 })
111 | |                 .is_some();
    | |__________________________^
    |
    = help: this is more succinctly expressed by calling `any()`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some

warning: called `is_some()` after searching an `Iterator` with `find`
   --> src\lang\lang.rs:118:18
    |
118 |                   .find(|v| ["feminine", "feminin", "féminin", "f"].contains(&v.as_str()))
    |  __________________^
119 | |                 .is_some();
    | |__________________________^ help: use `any()` instead: `any(|v| ["feminine", "feminin", "féminin", "f"].contains(&v.as_str()))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some

warning: called `is_some()` after searching an `Iterator` with `find`
   --> src\lang\lang.rs:120:28
    |
120 |               let reformed = preferences
    |  ____________________________^
121 | |                 .iter()
122 | |                 .find(|v: &&String| {
123 | |                     ["reformed", "1990", "rectifié", "rectification"].contains(&v.as_str())
124 | |                 })
125 | |                 .is_some();
    | |__________________________^
    |
    = help: this is more succinctly expressed by calling `any()`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some

warning: called `is_some()` after searching an `Iterator` with `find`
   --> src\lang\lang.rs:132:18
    |
132 |                   .find(|v| ["feminine", "feminin", "féminin", "f"].contains(&v.as_str()))
    |  __________________^
133 | |                 .is_some();
    | |__________________________^ help: use `any()` instead: `any(|v| ["feminine", "feminin", "féminin", "f"].contains(&v.as_str()))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some

warning: called `is_some()` after searching an `Iterator` with `find`
   --> src\lang\lang.rs:134:28
    |
134 |               let reformed = preferences
    |  ____________________________^
135 | |                 .iter()
136 | |                 .find(|v: &&String| {
137 | |                     ["reformed", "1990", "rectifié", "rectification"].contains(&v.as_str())
138 | |                 })
139 | |                 .is_some();
    | |__________________________^
    |
    = help: this is more succinctly expressed by calling `any()`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some

warning: stripping a suffix manually
   --> src\lang\fr.rs:318:25
    |
318 |                         &w[..w.len() - 1]
    |                         ^^^^^^^^^^^^^^^^^
    |
note: the suffix was tested here
   --> src\lang\fr.rs:317:21
    |
warning: constants have by default a `'static` lifetime
  --> src\lang\fr.rs:18:16
   |
18 | const UNITS: [&'static str; 9] = [
   |               -^^^^^^^---- help: consider removing `'static`: `&str`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes
   = note: `#[warn(clippy::redundant_static_lifetimes)]` on by default

warning: constants have by default a `'static` lifetime
  --> src\lang\fr.rs:22:15
   |
22 | const TENS: [&'static str; 9] = [
   |              -^^^^^^^---- help: consider removing `'static`: `&str`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes

warning: constants have by default a `'static` lifetime
  --> src\lang\fr.rs:34:16
   |
34 | const TEENS: [&'static str; 10] = [
   |               -^^^^^^^---- help: consider removing `'static`: `&str`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes

warning: constants have by default a `'static` lifetime
  --> src\lang\fr.rs:39:16
   |
39 | const MEGAS: [&'static str; 33] = [
   |               -^^^^^^^---- help: consider removing `'static`: `&str`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes

warning: useless conversion to the same type: `std::string::String`
   --> src\currency.rs:176:9
    |
176 | /         String::from(
177 | |             match self {
178 | |                 Currency::AED | Currency::KWD => "fils",
179 | |                 Currency::ARS | Currency::BRL | Currency::CLP | Currency::COP | Currency::MXN => {
...   |
192 | |             .replace("{}", if plural_form { "s" } else { "" }),
193 | |         )
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
    = note: `#[warn(clippy::useless_conversion)]` on by default
help: consider removing `String::from()`
    |
176 ~         match self {
177 +                 Currency::AED | Currency::KWD => "fils",
178 +                 Currency::ARS | Currency::BRL | Currency::CLP | Currency::COP | Currency::MXN => {
179 +                     "centavo{}"
180 +                 }
181 ~                 Currency::CRC => "céntimo{}",
182 +                 Currency::IDR | Currency::MYR => "sen{}",
183 +                 Currency::KRW => "jeon{}",
184 +                 Currency::SAR => "halalat{}",
185 +                 Currency::THB => "satang{}",
186 +                 Currency::UAH => "kopiyok{}",
187 +                 Currency::UYU => "centesimo{}",
188 +                 Currency::VND => "xu{}",
189 +                 _ => cent,
190 +             }
191 +             .replace("{}", if plural_form { "s" } else { "" })
    |

warning: module has the same name as its containing module
 --> src\lang\mod.rs:2:1
  |
2 | mod lang;
  | ^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_inception
  = note: `#[warn(clippy::module_inception)]` on by default

warning: called `is_some()` after searching an `Iterator` with `find`
   --> src\lang\lang.rs:104:18
    |
104 |                   .find(|v| ["feminine", "feminin", "féminin", "f"].contains(&v.as_str()))
    |  __________________^
105 | |                 .is_some();
    | |__________________________^ help: use `any()` instead: `any(|v| ["feminine", "feminin", "féminin", "f"].contains(&v.as_str()))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
    = note: `#[warn(clippy::search_is_some)]` on by default

warning: called `is_some()` after searching an `Iterator` with `find`
   --> src\lang\lang.rs:106:28
    |
106 |               let reformed = preferences
    |  ____________________________^
107 | |                 .iter()
108 | |                 .find(|v: &&String| {
109 | |                     ["reformed", "1990", "rectifié", "rectification"].contains(&v.as_str())
110 | |                 })
111 | |                 .is_some();
    | |__________________________^
    |
    = help: this is more succinctly expressed by calling `any()`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some

warning: called `is_some()` after searching an `Iterator` with `find`
   --> src\lang\lang.rs:118:18
    |
118 |                   .find(|v| ["feminine", "feminin", "féminin", "f"].contains(&v.as_str()))
    |  __________________^
119 | |                 .is_some();
    | |__________________________^ help: use `any()` instead: `any(|v| ["feminine", "feminin", "féminin", "f"].contains(&v.as_str()))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some

warning: called `is_some()` after searching an `Iterator` with `find`
   --> src\lang\lang.rs:120:28
    |
120 |               let reformed = preferences
    |  ____________________________^
121 | |                 .iter()
122 | |                 .find(|v: &&String| {
123 | |                     ["reformed", "1990", "rectifié", "rectification"].contains(&v.as_str())
124 | |                 })
125 | |                 .is_some();
    | |__________________________^
    |
    = help: this is more succinctly expressed by calling `any()`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some

warning: called `is_some()` after searching an `Iterator` with `find`
   --> src\lang\lang.rs:132:18
    |
132 |                   .find(|v| ["feminine", "feminin", "féminin", "f"].contains(&v.as_str()))
    |  __________________^
133 | |                 .is_some();
    | |__________________________^ help: use `any()` instead: `any(|v| ["feminine", "feminin", "féminin", "f"].contains(&v.as_str()))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some

warning: called `is_some()` after searching an `Iterator` with `find`
   --> src\lang\lang.rs:134:28
    |
134 |               let reformed = preferences
    |  ____________________________^
135 | |                 .iter()
136 | |                 .find(|v: &&String| {
137 | |                     ["reformed", "1990", "rectifié", "rectification"].contains(&v.as_str())
138 | |                 })
139 | |                 .is_some();
    | |__________________________^
    |
    = help: this is more succinctly expressed by calling `any()`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some

warning: stripping a suffix manually
   --> src\lang\fr.rs:318:25
    |
318 |                         &w[..w.len() - 1]
    |                         ^^^^^^^^^^^^^^^^^
    |
note: the suffix was tested here
   --> src\lang\fr.rs:317:21
    |
317 |                     if w.ends_with('e') {
    |                     ^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip
    = note: `#[warn(clippy::manual_strip)]` on by default
help: try using the `strip_suffix` method
    |
317 ~                     if let Some(<stripped>) = w.strip_suffix('e') {
318 ~                         <stripped>
    |```