Skip to content

Add lint output to lint list #8947

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

Merged
merged 1 commit into from
Jun 14, 2022
Merged

Conversation

Serial-ATA
Copy link
Contributor

changelog: Add the ability to show the lint output in the lint list

This just adds the logic to produce the output, it hasn't been added to any lints yet. It did help find some mistakes in some docs though 😄.

Screenshots

A single code block

single-code-block

A single code block with a "Use instead" section

with-usage

Multiple code blocks

multi-code-block

This is the last task in #7172 🎉.
r? @xFrednet (?)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 4, 2022
Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation looks good to me, a few smaller nits, but everything should be simple to fix.

With this change, I would like to ensure that the metadata collection works during the bors check and not on master when the deploy script is run. @flip1995 Would it be possible to run deploy.sh with bors and also push it to the gh-pages (if it's not @bors try). And would we want to have that?

Comment on lines +304 to +306
if line.eq_ignore_ascii_case("Use instead:") || line.eq_ignore_ascii_case("Could be written as:") {
break 'outer;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that a lint description like:

/// ```rs
/// <bad-example 1>
/// ```
///
/// Use instead:
/// ```rs
/// <good-example 1>
/// ```
/// 
/// ### Example 2
/// 
/// ```rs
/// <bad-example 2>
/// ```
///
/// Use instead:
/// ```rs
/// <good-example 2>
/// ```

would only lint the first example correct? I don't know of any lint that has such a documentation, but this would be good to know.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this is just an attempt to do as little work as possible. Normally when lints have multiple examples they use "or" anyway, so it shouldn't be an issue.

Copy link
Member

@xFrednet xFrednet Jun 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'm debating if this actually has a huge impact on the runtime. 🤔

I also want to see how what effect this PR has on the runtime. But I doubt that we can really do any optimization here, since we need to compile every snippet separately. Therefore, it should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are a few timings:

Before the PR
Executed in    8.75 secs    fish           external
   usr time   15.40 secs  310.00 micros   15.40 secs
   sys time    0.62 secs  185.00 micros    0.62 secs
After the PR (no generated output)
Executed in    9.44 secs    fish           external
   usr time   16.87 secs  551.00 micros   16.87 secs
   sys time    0.62 secs    0.00 micros    0.62 secs
Generating the output of 5 lints
Executed in   30.93 secs    fish           external
   usr time   59.21 secs    0.00 micros   59.21 secs
   sys time    3.75 secs  554.00 micros    3.75 secs

Copy link
Member

@xFrednet xFrednet Jun 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's quite a step up from the original run time, and just for 5 lints. Have you looked into parallelizing this step somehow? Maybe we could start the linting processes and not wait for its output?

If it's not possible, I'm also fine with this, as it will only be run, during for merge commits.

Before we merge this, I want to try adding this to the bors workflow, to ensure that the metadata collection always succeeds. Currently, it's only run on master after the merge and can therefore fail without us noticing. I have a good idea how this can be done, and I'll create a PR on the weekend, unless you want to give it a try 🙃

Copy link
Contributor Author

@Serial-ATA Serial-ATA Jun 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll work on parallelization, I've made slight improvements but it could probably be much better.

Also, I'll just wait for your PR. Workflows aren't my forte 😄.

@Serial-ATA Serial-ATA force-pushed the lint-produces-output branch from e5b69df to fdadebe Compare June 7, 2022 00:05
bors added a commit that referenced this pull request Jun 12, 2022
[WIP] Test metadata collection in Bors CI workflow

This PR adds a new check to bors CI workflows, which ensures that the metadata collection success, when it's run as part of the `deploy` script. I've only added it to bors workflows, as the runtime will be high while it'll also succeed most of the time. This is a preparation for #8947.

---

changelog: none

r? `@ghost`
bors added a commit that referenced this pull request Jun 12, 2022
[WIP] Test metadata collection in Bors CI workflow

This PR adds a new check to bors CI workflows, which ensures that the metadata collection success, when it's run as part of the `deploy` script. I've only added it to bors workflows, as the runtime will be high while it'll also succeed most of the time. This is a preparation for #8947.

---

changelog: none

r? `@ghost`
@flip1995
Copy link
Member

Would it be possible to run deploy.sh with bors and also push it to the gh-pages (if it's not @bors try). And would we want to have that?

It would be possible, but we don't want to push from auto. If anything goes wrong in the bors CI and it already pushed to gh-pages, we have invalid docs until the next PR is merged successfully.

bors added a commit that referenced this pull request Jun 13, 2022
Test metadata collection in Bors CI workflow

This PR adds a new check to bors CI workflows, which ensures that the metadata collection success, when it's run as part of the `deploy` script. I've only added it to bors workflows, as the runtime will be high while it'll also succeed most of the time. This is a preparation for #8947.

---

changelog: none

r? `@ghost`
@xFrednet
Copy link
Member

Would it be possible to run deploy.sh with bors and also push it to the gh-pages (if it's not @bors try). And would we want to have that?

It would be possible, but we don't want to push from auto. If anything goes wrong in the bors CI and it already pushed to gh-pages, we have invalid docs until the next PR is merged successfully.

That's also what I thought. With #8988 we now test the metadata collection, which was the main goal with my comment.

I'm also interested how much this PR effects the CI time. So, let's give it a go:

@bors try

@bors
Copy link
Contributor

bors commented Jun 13, 2022

⌛ Trying commit fdadebe with merge 7f85771...

bors added a commit that referenced this pull request Jun 13, 2022
Add lint output to lint list

changelog: Add the ability to show the lint output in the lint list

This just adds the logic to produce the output, it hasn't been added to any lints yet. It did help find some mistakes in some docs though 😄.

### Screenshots

<details>
<summary>A single code block</summary>

![single-code-block](https://user-images.githubusercontent.com/69764315/172013766-145b22b1-1d91-4fb8-9cd0-b967a52d6330.png)
</details>

<details>
<summary>A single code block with a "Use instead" section</summary>

![with-usage](https://user-images.githubusercontent.com/69764315/172013792-d2dd6c9c-defa-41e0-8c27-8e8e311adb63.png)
</details>

<details>
<summary>Multiple code blocks</summary>

![multi-code-block](https://user-images.githubusercontent.com/69764315/172013808-5328f59b-e7c5-4914-a396-253822a6d350.png)
</details>

This is the last task in #7172 🎉.
r? `@xFrednet` (?)
@bors
Copy link
Contributor

bors commented Jun 13, 2022

💔 Test failed - checks-action_dev_test

@xFrednet
Copy link
Member

It looks like this requires a rebase. I'll leave that to @Serial-ATA as this is not time critical and has a low chance of having conflicts since it's an internal lint.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jun 13, 2022
@xFrednet
Copy link
Member

The CI was just fixed on master, let's try this again.

@bors try

@bors
Copy link
Contributor

bors commented Jun 14, 2022

⌛ Trying commit fdadebe with merge 6b1f2a6...

bors added a commit that referenced this pull request Jun 14, 2022
Add lint output to lint list

changelog: Add the ability to show the lint output in the lint list

This just adds the logic to produce the output, it hasn't been added to any lints yet. It did help find some mistakes in some docs though 😄.

### Screenshots

<details>
<summary>A single code block</summary>

![single-code-block](https://user-images.githubusercontent.com/69764315/172013766-145b22b1-1d91-4fb8-9cd0-b967a52d6330.png)
</details>

<details>
<summary>A single code block with a "Use instead" section</summary>

![with-usage](https://user-images.githubusercontent.com/69764315/172013792-d2dd6c9c-defa-41e0-8c27-8e8e311adb63.png)
</details>

<details>
<summary>Multiple code blocks</summary>

![multi-code-block](https://user-images.githubusercontent.com/69764315/172013808-5328f59b-e7c5-4914-a396-253822a6d350.png)
</details>

This is the last task in #7172 🎉.
r? `@xFrednet` (?)
@bors
Copy link
Contributor

bors commented Jun 14, 2022

☀️ Try build successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Build commit: 6b1f2a6 (6b1f2a6a5ae11bfe0f0d42e448808a1b4e41d899)

@xFrednet
Copy link
Member

After, the changes on master this looks good to me. The collection is also still plenty past. It now took 3 min in the CI with compilation. In the future, it might be nice to have an environment value to disable the output production. But this is not necessary right now. Thank you very much for the addition. I love the change!

@xFrednet
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jun 14, 2022

📌 Commit fdadebe has been approved by xFrednet

@bors
Copy link
Contributor

bors commented Jun 14, 2022

⌛ Testing commit fdadebe with merge 5a45805...

@bors
Copy link
Contributor

bors commented Jun 14, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet
Pushing 5a45805 to master...

@bors bors merged commit 5a45805 into rust-lang:master Jun 14, 2022
@xFrednet
Copy link
Member

Just noticed that this PR doesn't add any {{produces}} markers to any lints. It has been a few days since I did the full review 😅. But this adds the infrastructure to add these markers 👍

Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the clippy_dev dependency when next working on this.

@@ -10,6 +10,7 @@ edition = "2021"

[dependencies]
cargo_metadata = "0.14"
clippy_dev = { path = "../clippy_dev", optional = true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed during the sync: depending on clippy_dev feels really wrong. clippy_dev isn't intended to be used as a library, but a standalone binary for clippy dev tools. Nothing should depend on clippy_dev IMO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ups yeah your right, slipped under my radar😅

@@ -188,6 +191,7 @@ impl MetadataCollector {
lints: BinaryHeap::<LintMetadata>::default(),
applicability_info: FxHashMap::<String, ApplicabilityInfo>::default(),
config: collect_configs(),
clippy_project_root: clippy_dev::clippy_project_root(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only place clippy_dev is used. I'm sure we can just hardcode this path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants