Commit graph

1346 commits

Author SHA1 Message Date
Jacherr
89210d7c5a new lint unnecessary_map_or 2024-11-12 23:00:26 +00:00
decryphe
f7ab2c9908 new lint: source_item_ordering 2024-10-30 10:03:16 +01:00
Robert Spencer
acc3842d43 Add new map_with_unused_argument_over_ranges lint
This lint checks for code that looks like
```rust
  let something : Vec<_> = (0..100).map(|_| {
    1 + 2 + 3
  }).collect();
```
which is more clear as
```rust
  let something : Vec<_> = std::iter::repeat_with(|| {
    1 + 2 + 3
  }).take(100).collect();
```
or
```rust
  let something : Vec<_> =
      std::iter::repeat_n(1 + 2 + 3, 100)
      .collect();
```

That is, a map over a range which does nothing with the parameter
passed to it is simply a function (or closure) being called `n`
times and could be more semantically expressed using `take`.
2024-10-29 21:32:00 +00:00
Samuel Tardieu
91a1d16a81 Add new lint: map_all_any_identity 2024-10-29 11:59:15 +01:00
Samuel Tardieu
62c4daf358 New lint needless_as_bytes 2024-10-28 09:19:17 +01:00
bors
dae1be90ee Auto merge of #13525 - xFrednet:changelog-1-82, r=dswij
Changelog for Clippy 1.82 ✈️

```
Roses are red,
Violets are blue,
EuroRust in Austria,
    RustConf in Canada.
```

---

### The cat of this release is *Racka*:

<img height=500 src="https://github.com/user-attachments/assets/e5e3cc95-6fc3-4214-aab0-4f26e0967ae5" alt="The cats of this Clippy release" />

Cats for the next release can be nominated in the comments :D

---

changelog: none
2024-10-17 11:13:09 +00:00
GnomedDev
42511a3ffa
Add lint for unnecessary lifetime bounded &str return 2024-10-15 17:06:21 +01:00
xFrednet
512ad86d68
Changelog: Update category for too_long_first_doc_paragraph 2024-10-15 17:13:19 +02:00
bors
c71f0bebd2 Auto merge of #13334 - nyurik:ascii-str-eq, r=xFrednet
Add manual_ignore_cast_cmp lint

```rust
// bad
fn compare(a: &str, b: &str) -> bool {
    a.to_ascii_lowercase() == b.to_ascii_lowercase()
    || a.to_ascii_lowercase() == "abc"
}

// good
fn compare(a: &str, b: &str) -> bool {
   a.eq_ignore_ascii_case(b)
   || a.eq_ignore_ascii_case("abc")
}
```

- [x] Followed [lint naming conventions][lint_naming]
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `cargo dev update_lints`
- [x] Added lint documentation
- [x] Run `cargo dev fmt`

changelog: New lint: [`manual_ignore_case_cmp`] `perf`
[#13334](https://github.com/rust-lang/rust-clippy/pull/13334)

Closes #13204
2024-10-13 07:34:38 +00:00
xFrednet
731c473fd9
Changelog for Clippy 1.82 ✈️ 2024-10-09 19:04:21 +02:00
bors
753629bb33 Auto merge of #13412 - GnomedDev:regex-comp-in-loop, r=y21
Implement lint for regex::Regex compilation inside a loop

Closes #598.

Seems like a pretty simple one, I'm not sure if I sorted out all the lint plumbing correctly because I was adding it to the existing regex pass, but seems to work. The name is a bit jank and I'm super open to suggestions for changing it.

changelog: [`regex_creation_in_loops`]: Added lint for Regex compilation inside loops.
2024-10-05 18:41:45 +00:00
Yuri Astrakhan
d1dec199ee Add manual_ignore_cast_cmp lint 2024-10-01 01:11:05 -04:00
Yuri Astrakhan
73a16c10db Suggest Option<&T> instead of &Option<T> 2024-09-28 11:57:34 -04:00
GnomedDev
9f5bfe24eb Implement lint for regex::Regex compilation inside a loop 2024-09-21 12:46:08 +01:00
Ruairidh Williamson
05ebce8e1a
Add lint unused_trait_names 2024-09-21 00:56:38 +01:00
Lukas Lueg
290a01e448 Initial impl of unnecessary_first_then_check
Fixes #11212
2024-09-19 21:27:39 +02:00
Samarth1696
46f8d360de Lint ready 2024-09-07 13:21:09 +05:30
Sour1emon
d7996da9da Add manual_is_power_of_two 2024-09-05 18:38:06 -07:00
Artem Belyakov
9415e6e6eb Add manual_div_ceil 2024-09-06 00:55:42 +02:00
bors
c95c767663 Auto merge of #13323 - xFrednet:chnagelog-1-81, r=flip1995
Changelog for Clippy 1.81 🔰

Roses are red,
Violets are blue,
Expectations are stable,
And reasons are set

---

### The cat of this release is *Keepy* submitted by `@blyxyas:`

<img height=500 src="https://github.com/rust-lang/rust-clippy/assets/73757586/902dd802-5ac8-471e-bb93-e195526ba580" alt="The cats of this Clippy release" />

Cats for the next release can be nominated in the comments :D

---

changelog: none
2024-09-05 09:17:12 +00:00
Soveu
273b561609 add pointers_in_nomem_asm_block lint 2024-09-03 18:58:05 +02:00
bors
ac914d3457 Auto merge of #12476 - GuillaumeGomez:add-manual_arithmetic_check, r=y21
Extend `implicit_saturating_sub` lint

Fixes #10070.

It can serve as base if we want to add equivalent checks for other arithmetic operations.

Also one important note: when writing this lint, I realized that I could check for wrong conditions performed beforehand on subtraction and added another part in the lint. Considering they both rely on the same checks, I kept both in the same place. Not sure if it makes sense though...

changelog: Extend `implicit_saturating_sub` lint
2024-08-31 16:03:42 +00:00
Fridtjof Stoldt
cbc6910c35
Changelog: Correct lint level
Co-authored-by: Timo <30553356+y21@users.noreply.github.com>
2024-08-29 22:15:18 +02:00
xFrednet
9aa23b8317
Changelog for Clippy 1.81 🔰 2024-08-29 21:54:05 +02:00
Guillaume Gomez
d20fc38f0a Create new inverted_saturating_sub lint 2024-08-29 20:20:13 +02:00
y21
e8ac4ea418 new lint: zombie_processes 2024-08-27 21:51:02 +02:00
bors
603d5a19c9 Auto merge of #13294 - WeiTheShinobi:new_lint_used_underscore_items, r=llogiq
Add new lint: `used_underscore_items`

Closes #13260

---

changelog: new [`used_underscore_items`] lint against using items with a single leading underscore
2024-08-27 10:59:31 +00:00
bors
30e0b69908 Auto merge of #12993 - GuillaumeGomez:too_long_first_doc_paragraph, r=Centri3
Add new `too_long_first_doc_paragraph` first paragraph lint

Fixes https://github.com/rust-lang/rust-clippy/issues/12989.

changelog: Add new `too_long_first_doc_paragraph` first paragraph lint
2024-08-24 15:23:34 +00:00
WeiTheShinobi
b615c82180
Add new lint: used_underscore_items 2024-08-21 19:57:41 +08:00
bors
5ead90f13a Auto merge of #12150 - ithinuel:add_misleading_use_of_ok, r=y21
Add lint for `unused_result_ok`

This PR adds a lint to capture the use of `expr.ok();` when the result is not _really_ used.

This could be interpreted as the result being checked (like it is with `unwrap()` or `expect`) but
it actually only ignores the result.

`let _ = expr;` expresses that intent better.

This was also mentionned in #8994 (although not being the main topic of that issue).

changelog: [`misleading_use_of_ok`]: Add new lint to capture `.ok();` when the result is not _really_ used.
2024-08-06 19:01:41 +00:00
Jason Newcomb
2c34d58159 Store deprecated lints as an array of tuples.
Remove legacy deprecations.
Remove "View Source" link for deprecated lints.
2024-08-05 09:15:55 -04:00
Wilfried Chauveau
182c26891e
Add lint for unused_result_ok 2024-07-29 17:56:45 +01:00
Guillaume Gomez
855a9d1377 Add new too_long_first_doc_paragraph first paragraph lint 2024-07-26 11:21:32 +02:00
bors
df0cb6c51e Auto merge of #13125 - xFrednet:changelog-1-80, r=dswij
Changelog for Clippy 1.80 🌞

Roses are red,
Violets are blue,
Summer is fun,
So much sun

---

### The cat of this release is *Maunzer* submitted by `@llogiq:`

<img height=500 src="https://github.com/rust-lang/rust-clippy/assets/4200835/a1da6948-446d-4ccf-95a7-c816a8afdc3f" alt="The cats of this Clippy release" />

Cats for the next release can be nominated in the comments :D

---

changelog: none

I wish everyone reading this a beautiful and happy day =^.^=
2024-07-25 12:48:54 +00:00
lengyijun
cb77f12600 [pathbuf_init_then_push]: Checks for calls to push immediately after creating a new PathBuf
Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>
2024-07-21 14:22:48 +08:00
xFrednet
642ab11a48
Changelog for Clippy 1.80 🌞 2024-07-18 20:58:50 +02:00
Jason Newcomb
23d96f65e4 Rename overflow_check_conditional to panicking_overflow_checks. 2024-07-07 10:24:42 -04:00
bors
3ed690f07a Auto merge of #12974 - alex-semenyuk:rename_thread_local_initializer_can_be_made_const, r=Alexendoo
Rename thread_local_initializer_can_be_made_const to missing_const_for_thread_local

Close #12934
As discussed at #12934 name `thread_local_initializer_can_be_made_const` sounds against convention for other lints which describe the issue/wrong code but not suggestion and it is quite long. The new name take example from existing lint `missing_const_for_fn`

changelog: `thread_local_initializer_can_be_made_const` : Rename to [`missing_const_for_thread_local`]
2024-07-05 17:50:06 +00:00
Alexey Semenyuk
6621e6cbfa Rename thread_local_initializer_can_be_made_const to missing_const_for_thread_local 2024-07-05 19:40:37 +05:00
Milo Moisson
2c09ac3d39
feat: add cfg_not_test lint 2024-07-05 10:28:26 +02:00
Marcel Müller
88c4a22480
New Lint: byte_char_slices
This patch adds a new lint that checks for potentially harder to read
byte char slices: `&[b'a', b'b']` and suggests to replace them with the
easier to read `b"ab"` form.

Signed-Off-By: Marcel Müller <m.mueller@ifm.com>
Co-authored-by: Matthias Beyer <matthias.beyer@ifm.com>

Use iterator to skip validation

Signed-off-by: Marcel Müller <m.mueller@ifm.com>
Suggested-by: Alex Macleod <alex@macleod.io>

Convert quote escapes to proper form

Signed-off-by: Marcel Müller <m.mueller@ifm.com>

Add more convertable test cases

Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2024-07-04 14:31:15 +02:00
Renato Lochetti
6661e83e7b
Rename lint, generalize function, add known issues, use multispan 2024-07-03 19:42:34 +01:00
Renato Lochetti
0f915f6f30
Add new lint hashset_insert_after_contains 2024-07-03 19:41:26 +01:00
Roman Franchuk
b08b8b8a75 Implement a lint to replace bit manual rotations with rotate_left/rotate_right 2024-06-29 22:31:10 +02:00
Philipp Krones
e9e7a815a7
Merge remote-tracking branch 'upstream/master' into rustup 2024-06-27 18:49:59 +02:00
xFrednet
1b4c281fe7 RFC 2383: Stabilize lint_reasons in Clippy 🖇️ 2024-06-25 17:50:48 +02:00
vohoanglong0107
2f9f204123 feat: unnecessary_min_max lint 2024-06-20 13:57:16 +00:00
Jason Newcomb
22710f33a8 Add lint manual_inspect 2024-06-16 18:33:43 -04:00
kyle oneill
3405ce3bca Add field_scoped_visibility_modifiers lint 2024-06-16 15:54:48 -04:00
Philipp Krones
3bff119f63 Merge commit '3e5a02b13b1244545454752c6629b767522a44b1' into clippy-subtree-update 2024-06-13 12:30:48 +02:00