Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots of Clippy Warnings #28

Open
Laifsyn opened this issue Mar 29, 2024 · 0 comments
Open

Lots of Clippy Warnings #28

Laifsyn opened this issue Mar 29, 2024 · 0 comments

Comments

@Laifsyn
Copy link

Laifsyn commented Mar 29, 2024

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>
    |```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant