Commit Graph

218 Commits

Author SHA1 Message Date
Alex Macleod
1528c1db47 Deserialize Msrv directly in Conf 2023-10-18 20:35:09 +00:00
jonboh
8b02dac542 add lint for struct field names
side effect for `enum_variants`:
use .first() instead of .get(0) in enum_variants lint
move to_camel_case to str_util module
move module, enum and struct name repetitions check to a single file `item_name_repetitions`
rename enum_variants threshold config option
2023-10-18 19:20:08 +02:00
Caio
8c0870de7f Address comment 2023-10-13 10:31:02 -03:00
Caio
d1796054fe Document conflicting lints 2023-10-13 10:09:58 -03:00
Michael Schubart
0f8b8625bd Fix documentation link
The file pointed to by the old link

557f6848bd/clippy_lints/src/lib.rs (L110)

did not talk about categories and levels.

The new link (hopefully) points here

https://doc.rust-lang.org/stable/clippy/

which has a nice table explaining the mappings.
2023-10-01 16:44:30 +01:00
Alex Macleod
ec2f62677f Add manual_hash_one lint 2023-09-26 13:49:15 +00:00
Trevor Gross
1b3e5dd0fc Change default configuration of undocumented_unsafe_blocks
This patch sets the two configuration options for
`undocumented_unsafe_blocks` to `true` by default: these are
`accept-comment-above-statement` and `accept-comment-above-attributes`.
Having these values `false` by default prevents what many users would
consider clean code, e.g. placing the `// SAFETY:` comment above a
single-line functino call, rather than directly next to the argument.

changelog: [`undocumented_unsafe_blocks`]: set
`accept-comment-above-statement` and `accept-comment-above-attributes`
to `true` by default.
2023-09-20 03:41:33 -04:00
y21
981e96008b new lint: path_ends_with_ext 2023-09-15 16:17:51 +02:00
bors
60a18b7831 Auto merge of #11449 - blyxyas:book-write_tests, r=flip1995
Should be final writing_tests commit

Fixes that book `FIXME`.

r? `@flip1995`
changelog: none
2023-09-03 20:25:41 +00:00
bors
b65e544535 Auto merge of #10626 - blyxyas:book-trait_checking, r=flip1995
Clippy Book Chapter Updates Reborn: Trait Checking

This PR adds a new chapter to the book: "Trait Checking". No major changes from the source (just some typos, re-phrasing, the usual).

## Notes

- Does not require any other PR to be merged.
- To talk about the whole project, please use the tracking issue for the project #10597 (It also contains a timeline, discussions and more information)

changelog: Add a new "Trait Checking" chapter to the book
2023-09-02 11:21:48 +00:00
blyxyas
92d47dbb29
Add emitting_lints link to Writing tests and remove that FIXME 2023-09-02 12:26:13 +02:00
bors
3cf1087dcd Auto merge of #10598 - blyxyas:book-emit_lints, r=flip1995
Clippy Book Chapter Updates Reborn: Emitting lints

The PR adds a new chapter to the book: "Emitting lints". This time it changed a lot from the old source file.

## Notes

- For discussion about  the whole project, please use the tracking issue for the project #10597 (It also contains a timeline, discussions, and more information)

changelog: Add a new "Emitting lints" chapter to the book

r? `@flip1995`
2023-09-02 09:49:57 +00:00
blyxyas
a26937ff0e
Fix links 2023-09-02 11:46:20 +02:00
bors
aa371eb154 Auto merge of #10596 - blyxyas:book-write_tests, r=flip1995
Clippy Book Chapter Updates Reborn: Writing tests

This PR adds  a new chapter to the book: "Writing tests". The changes have been mainly done from reviews from #9426 and some minor re-writes.

## Notes

- We still need to check that the `git status`es are correct, as `cargo dev new_lint` changed a lot since 2022.
- Requires #10598: Link to "Emitting Lints" where I flagged with `FIXME:`.
- To talk about the whole project, please use the tracking issue for the project #10597 (It also contains a timeline, discussions and more information)

changelog: Add a new "Writing tests" chapter to the book
r? `@flip1995`
2023-09-02 09:34:16 +00:00
blyxyas
e1a3f635fc
Apply suggestion 2023-09-02 11:23:27 +02:00
Ben Schofield
55bd0fe296 Fix metadata collection 2023-08-30 16:02:37 -07:00
Philipp Krones
8ee6ca0981
Update rustfix section to new ui-test crate 2023-08-18 20:16:26 +02:00
Philipp Krones
9b8b83556b
Formatting and minor wording fixes 2023-08-18 19:55:01 +02:00
Philipp Krones
32dc7c592d
Applying review suggestions 2023-08-18 19:28:41 +02:00
Philipp Krones
864df49bd3
Formatting, slimming and ui-toml tests 2023-08-18 19:18:15 +02:00
blyxyas
289bafa3e0
New chapter: Writing tests
Co-authored-by: Nahua <kangnahua@gmail.com>
2023-08-17 22:58:26 +02:00
blyxyas
2a3f75b0b8
Fix CI 2023-08-17 22:56:39 +02:00
blyxyas
b2e1ede39c
Change Tokio example description to Core 2023-08-17 22:56:39 +02:00
blyxyas
94387efc83
Fixes based on reviews 2023-08-17 22:56:38 +02:00
blyxyas
3c50a0a18d
Add new chapter: "Trait Checking" 2023-08-17 22:56:37 +02:00
Philipp Krones
1dbc8dd0cf
Fix define_lints->defining_lints typo in link 2023-08-16 14:54:47 +02:00
Philipp Krones
e8d79b8645
Formatting 2023-08-16 14:50:40 +02:00
blyxyas
9e4a2d7fca
Fixes based on reviews 2023-08-16 14:50:40 +02:00
blyxyas
111f0229da
Add "Method Checking"
Co-authored-by: Nahua <kangnahua@gmail.com>
2023-08-16 14:50:40 +02:00
Philipp Krones
783c119768
Address review comments and formatting 2023-08-16 14:36:09 +02:00
blyxyas
6076cda3c5
Fix CI 2023-08-16 14:30:39 +02:00
blyxyas
b91d676b60
Move "Lint types to the top" 2023-08-16 14:30:39 +02:00
blyxyas
7465436270
Improve briefness 2023-08-16 14:30:39 +02:00
blyxyas
735380b2cc
Try to clear up confusion between type and category. 2023-08-16 14:30:39 +02:00
blyxyas
c22906b37f
Fix CI formatting issues 2023-08-16 14:30:38 +02:00
blyxyas
97d31c8ae0
New chapter: Defining Lints
Co-authored-by: Nahua <kangnahua@gmail.com>
2023-08-16 14:30:38 +02:00
bors
75370e0671 Auto merge of #11325 - oli-obk:SPEEDTEST, r=flip1995
Fix SPEEDTEST instructions and output

* `--nocapture` hasn't been needed anymore since forever (even before `ui_test`)
* the result was dividing by 1000 instead of the number of test runs, giving bogus (but still useful for the purpose) timing results.

changelog: fix SPEEDTEST instructions and output
2023-08-11 15:30:38 +00:00
Oli Scherer
a7af8bc6ec Fix SPEEDTEST instructions 2023-08-11 15:22:06 +00:00
Oli Scherer
3d88fae050 Update ui test crate 2023-08-11 14:02:28 +00:00
Catherine
9cf1509b25 New lint absolute_paths 2023-07-21 17:26:58 -05:00
bors
8e261c09bb Auto merge of #11049 - Centri3:manual_is_infinite, r=blyxyas,xFrednet
New lints [`manual_is_infinite`] and [`manual_is_finite`]

Closes #9665

changelog: New lints [`manual_is_infinite`] and [`manual_is_finite`]
[#11049](https://github.com/rust-lang/rust-clippy/pull/11049)
2023-07-08 18:45:35 +00:00
Catherine
41438c2b90 Refactor, remove Constant::to_bits 2023-07-08 13:17:35 -05:00
Alex Macleod
28655266b5 Fix changelog PR listings, create them automatically in fetch_prs_between.sh 2023-07-07 12:07:05 +00:00
bors
ea4ca225fb Auto merge of #10920 - blyxyas:speedtest, r=llogiq
Add `SPEEDTEST`

In the `master` branch, we currently don't have any way to test the performance of a single lint in changes.
This PR adds `SPEEDTEST`, the environment variable which lets you do a speed test on a lint / category of tests with various configuration options.

Maybe we should merge this with `lintcheck` 🤔
See the book page for more information.

changelog:none
2023-07-02 15:48:50 +00:00
bors
1990b72e8a Auto merge of #11058 - Centri3:typos, r=xFrednet
Fix typos

Just a couple misc typos I found

changelog: none
2023-07-02 12:11:30 +00:00
Catherine
885a18207f Fix typos 2023-07-02 07:11:05 -05:00
Catherine
cb5d7e344a address comments 2023-07-01 12:37:16 -05:00
Catherine
826edd75ef heavily refactor 2023-06-29 06:46:28 -05:00
bors
9020937bbe Auto merge of #11030 - darklyspaced:master, r=Centri3,xFrednet
suggests `is_some_and` over `map().unwrap`

changelog: Enhancement: [`option_map_unwrap_or`] now considers the [`msrv`] config when creating the suggestion.

 * modified option_map_unwrap_or lint to recognise when an `Option<T>` is mapped to an `Option<bool>` with false being used when `None` is detected; suggests the use of `is_some_and` instead
 * msrv is set to 1.70.0 for this lint; when `is_some_and` was stabilised

fixes #9125
2023-06-29 09:54:51 +00:00
darklyspaced
bb42b18081
ran cargo collect-metadata 2023-06-29 17:30:39 +08:00
bors
6ce656f157 Auto merge of #11039 - Alexendoo:bless, r=llogiq
Add `BLESS` for compile-test and some cleanup

changelog: none

Allows passing the environment variable `BLESS` to bless tests, which is useful when you want to bless internal tests - `BLESS= cargo uitest -Finternal`

Also updates a place in the docs referring to `cargo dev bless` and removes some unused test deps
2023-06-27 20:25:06 +00:00
Alex Macleod
76de5560fa Add BLESS for compile-test and some cleanup 2023-06-27 16:39:13 +00:00
Centri3
8cb6c86996 change category and refactor
Update raw_strings.rs

Revert "new lints for visibility"

This reverts commit 0e5a537d209727169769dc19cf86aef27122c092.

new lints for visibility
2023-06-27 05:16:40 -05:00
Centri3
cb52d19ce1 don't lint needless_raw_string_hashes when it's unnecessary 2023-06-27 05:12:00 -05:00
blyxyas
d69c4f553c
Add SPEEDTEST 2023-06-26 20:32:32 +02:00
bors
15ed281699 Auto merge of #10426 - oli-obk:ui_test, r=Manishearth
Port clippy away from compiletest to ui_test

Reasons to do this:

* runs completely on stable Rust
* is easier to extend with new features
* has its own dogfood test suite, so changes can be tested in [the `ui_test` repo](https://github.com/oli-obk/ui_test)
* supports dependencies from crates.io without having to manually fiddle with command line flags
* supports `ui-cargo`, `ui`, `ui-toml` out of the box, no need to find and run the tests ourselves

One thing that is a big difference to `compiletest` is that if a test emits *any* error, you need to mark all of them with `//~ ERROR:` annotations. Since many clippy tests did not have annotations, I changed many lints to be `warn` in their test so that only the `stderr` output is tested.

TODO:

* [ ] check that this still works as a subtree in the rustc repo

changelog: none
<!-- changelog_checked -->

Note: at present the latest changes needed for clippy are only available as a git dependency, but I expect to publish a new crates.io version soon
2023-06-26 17:32:51 +00:00
Oli Scherer
514b6d04bb Port clippy away from compiletest to ui_test 2023-06-26 14:13:07 +00:00
blyxyas
aea731ebdb
update changelog's data ranges 2023-06-26 13:48:49 +02:00
bors
ce0a48a9b6 Auto merge of #10994 - y21:issue8772, r=giraffate
[`type_repetition_in_bounds`]: respect MSRV for combining bounds

Fixes #8772.

changelog: [`type_repetition_in_bounds`]: respect msrv for combining `?Sized` bound
2023-06-23 00:31:04 +00:00
y21
75f9fbc93d update lint configuration 2023-06-23 02:07:05 +02:00
Catherine
e3b601a1aa Add WebAssembly to allowed idents 2023-06-20 18:12:20 -05:00
bors
8fd021f504 Auto merge of #10986 - Centri3:undocumented_unsafe_blocks, r=Manishearth
Allow safety comment above attributes

Closes #8679

changelog: Enhancement: [`undocumented_safety_block`]: Added `accept-comment-above-attributes` configuration.
2023-06-20 05:04:46 +00:00
Centri3
cc2e49f695 allow safety comment above attributes 2023-06-19 23:46:57 -05:00
Centri3
2cd4a9182a Ignore functions annotated with #[test] 2023-06-18 19:32:38 -05:00
Renato Lochetti
e2e6a02445
Addressing reviewer comments 2023-06-17 09:36:38 -03:00
Renato Lochetti
520228b377
Adding configuration to allow safety comment above stmt containing unsafe block 2023-06-17 09:36:36 -03:00
y21
6ad7c6f4e6 update lint_configuration.md 2023-06-12 12:21:38 +02:00
y21
c8c7a3c79c fix rebase weirdness 2023-06-12 12:21:38 +02:00
y21
7312a93a06 new lint: large_stack_frames 2023-06-12 12:21:38 +02:00
Centri3
203e875189 cargo collect-metadata 2023-06-12 03:22:01 -05:00
Centri3
243943ff56 make it work for locals as well
oopos
2023-06-12 03:22:01 -05:00
bors
e986b6444e Auto merge of #10917 - Centri3:module_inception, r=xFrednet
allow disabling module inception on private modules

Fixes #10842

changelog: Enhancement [`module_inception`]: Added `allow-private-module-inception` configuration.
[#10917](https://github.com/rust-lang/rust-clippy/pull/10917)
<!-- changelog_checked -->
2023-06-10 13:21:48 +00:00
Centri3
b303e2053c allow disabling module inception on private modules
allow disabling module inception on private modules
2023-06-10 08:09:07 -05:00
Centri3
725399a178 move to complexity but don't lint by default 2023-06-07 18:34:34 -05:00
Centri3
88143ac295 decided against reinventing the wheel 2023-06-07 18:34:34 -05:00
bors
00001d6e08 Auto merge of #10699 - blyxyas:book-lint_config, r=flip1995
Clippy Book Chapter Updates Reborn: Refresh Lint Configuration's looks

This PR modernizes and clears up some confusion with the "Lint Configuration Options" chapter from the book.

### Changes

- **Remove 'Option - Default Value" table**

    - Why was it even there?
    - It shouldn't be the first thing an user sees when they enter the chapter. It's clunky, ugly and not useful. The default values for configs are stated in a per-config basis if needed.

- **Add a simple description of what the chapter contains, and the scheme of each configuration option**

- **Minor formatting, mainly adding code fragments to code text**

    - It seemed weird and jarring not having back-ticks on text like "arithmetic_side_effects".
    -  Improves readability and separation between configs.

- **Separate a little bit the Affected Lints list + "Affected lists" message**

    - Not having something indicating that the list is about the lints that use the configuration option is confusing.
    - It isn't as important as the description and example. Therefore should be separated a little bit imo

---

This is an independent effort from #10597, but as it's still a Book Chapter Update, I thought it would be cool to include it here. I'm going to keep the reviewing process for this PR to rustbot's desires.

[Rendered](https://github.com/blyxyas/rust-clippy/blob/book-lint_config/book/src/lint_configuration.md)
[Current](https://github.com/rust-lang/rust-clippy/blob/master/book/src/lint_configuration.md)

changelog: Refresh styling from the "Lint Configuration Options" book chapter.
2023-06-02 12:51:26 +00:00
MarcusGrass
194343fcea
Explain path-search using a list 2023-06-01 12:54:20 +02:00
MarcusGrass
5f5e2e2ac1
Explain which paths clippy searches for configuration in docs 2023-06-01 12:14:55 +02:00
adrianEffe
591f5f7ea9
Update urls in Type Checking 2023-05-17 22:55:14 +03:00
blyxyas
b7a6054712
Refresh Lint Configuration's looks 2023-05-09 21:39:24 +02:00
Sergen Karaoglan
d1f55e6b53 run linkcheck in Remark CI
fix new lints link

install nightly rust-docs

run linkcheck without nightly toolchain

remove nightly toolchain, add rust-docs component

Test Remark

Update basics.md

Update basics.md

Update basics.md

update workflow

add rust docs toolchain

Update remark.yml

workflow test

manual test

update book path

add linkcheck book to CI

Update lint_passes.md
2023-04-28 15:11:48 +01:00
bors
990bbdc2be Auto merge of #10656 - Centri3:master, r=xFrednet
Add configuration for `semicolon_block` lints

Does exactly what it says on the tin, suggests moving a block's final semicolon inside if it's multiline and outside if it's singleline.

I don't really like how this is implemented so I'm not too sure if this is ready yet. Alas, it might be ok.

---

fixes #10654

changelog: Enhancement: [`semicolon_inside_block`]: Added `semicolon-inside-block-ignore-singleline` as a new config value.
[#10656](https://github.com/rust-lang/rust-clippy/pull/10656)
changelog: Enhancement: [`semicolon_outside_block`]: Added `semicolon-outside-block-ignore-multiline` as a new config value.
[#10656](https://github.com/rust-lang/rust-clippy/pull/10656)
<!-- changelog_checked -->
2023-04-25 20:12:00 +00:00
Centri3
8c8cf40707 Update lint_configuration.md 2023-04-25 14:44:56 -05:00
bors
a7335cbf90 Auto merge of #10712 - blyxyas:fix-fixflag_implies_all_targets, r=llogiq
Document that `cargo clippy --fix` implies `--all-targets`

In [`cargo fix`'s documentation](https://doc.rust-lang.org/cargo/commands/cargo-fix.html) they indicate that `fix` implies `--all-targets` if no target is supplied. As Clippy uses Cargo under the hood, this also applies to Clippy, but we didn't document that behaviour.

This PR changes that

Fixes #10690
changelog: Add to documentation that `--fix` implies `--all-targets`
2023-04-25 17:11:52 +00:00
blyxyas
4a76b6f04f
Add the warning to all documentation. 2023-04-25 02:05:32 +02:00
bors
96f8471d81 Auto merge of #10649 - jsoref:spelling, r=Jarcho
Spelling

This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling).

The misspellings have been reported at https://github.com/jsoref/rust-clippy/actions/runs/4710771873#summary-12776860721

The action reports that the changes in this PR would make it happy: https://github.com/jsoref/rust-clippy/actions/runs/4710771874#summary-12776860722

changelog: none
2023-04-23 22:30:06 +00:00
Josh Soref
d2061faf9e Spelling
* applying
* binding
* complex
* constituent
* demonstrate
* desugaring
* exact
* expression
* for
* functionalities
* github
* implementation
* infers
* multiple conflicting traits
* mutable
* necessarily
* nightly
* nonexistent
* optional
* parameter
* reassignments
* resources
* substitution
* suggestion
* that
* that array is
* using the

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-23 10:52:27 -04:00
Oli Scherer
def1705a27 Update to a compiletest-rs version that requires //@ for commands 2023-04-20 14:44:03 +00:00
bors
0c44586ff7 Auto merge of #10651 - lukaslueg:issue10641, r=xFrednet
Add size-parameter to unecessary_box_returns

Fixes #10641

This adds a configuration-knob to the `unecessary_box_returns`-lint which allows _not_ linting a `fn() -> Box<T>` if `T` is "large". The default byte size above which we no longer lint is 128 bytes (due to https://github.com/rust-lang/rust-clippy/issues/4652#issue-505670554, also used in #9373). The overall rational is given in #10641.

---

changelog: Enhancement: [`unnecessary_box_returns`]: Added new lint configuration `unnecessary-box-size` to set the maximum size of `T` in `Box<T>` to be linted
[#10651](https://github.com/rust-lang/rust-clippy/pull/10651)
<!-- changelog_checked -->
2023-04-19 12:42:33 +00:00
Lukas Lueg
4bc68f9c60 Add size-parameter to unecessary_box_returns
Fixes #10641
2023-04-19 14:32:05 +02:00
blyxyas
f76615a7ac
New chapter: Emitting lints 2023-04-17 10:24:47 +02:00
bors
90cb0fa2f3 Auto merge of #10652 - blyxyas:book-macro_expansions, r=flip1995
Clippy Book Chapter Updates Reborn: Macro Expansions

This PR adds a new chapter to the book: "Macro Expansions". There weren't big changes apart from grammar, re-phrasing and stylistic choices.

## Notes

- **Does not require any other chapter** to be merged before this
- To talk about the whole project, please use the tracking issue for the project #10597 (It also contains a timeline, discussions and more information)

changelog: Add a new "Macro Expansions" chapter to the book

r? `@flip1995`
2023-04-16 21:17:46 +00:00
blyxyas
e3a352d0bb
Add new chapter: "Macro Expansions"
Co-authored-by: Nahua <kangnahua@gmail.com>
2023-04-16 23:16:27 +02:00
Philipp Krones
b842e99ddf
Make warning about hir_ty_to_ty more visible 2023-04-16 21:08:59 +02:00
Philipp Krones
fbb69dea91
Improve type checking and lint passes chapters
Adds the lint passes chapter to the index.

Moves additional reading material for beginners to the front page of the
development section.

Clarify some details in hir::Ty vs ty::Ty.
2023-04-16 20:59:25 +02:00
bors
004981647f Auto merge of #10622 - blyxyas:book-lint_passes, r=llogiq
Clippy Book Chapter Updates Reborn: Lint Passes

This PR adds a new chapter to the book: "Lint passes". No major changes apart from some re-phrasing, fixing typos... etc.

## Notes

- Requires #10595 to be merged before this one (Or else, a link will be broken).
- To talk about the whole project, please use the tracking issue for the project #10597 (It also contains a timeline, discussions and more information)

changelog: Add a new "Lint passes" chapter to the book
r? `@flip1995`
2023-04-14 17:04:54 +00:00
blyxyas
b4732679fc
Talk about symbol information in "Early Lint Pass" 2023-04-12 23:59:56 +02:00
Philipp Krones
0266a9e9a3
Fix links in Clippy book
Links to README.md files must actually be links to index.md files,
because of the inner workings of `mdbook`.

Also use the latest mdbook version in CI.
2023-04-11 14:43:47 +02:00
blyxyas
c19c08f4b2
Fix CI 2023-04-10 11:09:52 +02:00
blyxyas
0b1b535116
Add "Lint Passes" chapter 2023-04-10 10:59:12 +02:00