Skip to content

[Merged by Bors] - feat: the header linter - #16574

Closed
adomani wants to merge 92 commits into
masterfrom
adomani/docModule_copied_assert_not_exists
Closed

adomani wants to merge 92 commits into
masterfrom
adomani/docModule_copied_assert_not_exists

Conversation

@adomani

@adomani adomani commented Sep 7, 2024 •

Copy link
Copy Markdown
Contributor

This syntax linter checks that

  • the copyright statement is correctly formatted;
  • Mathlib.Tactic is not imported;
  • makes sure that the module docs are the first non-import command of each file.

The linter is off by default on projects downstream of mathlib, but it is on by default on mathlib.

This subsumes the corresponding text-based linters. These will be removed in a future PR.


Open in Gitpod

@adomani adomani added the RFC Request for comment label Sep 7, 2024
@github-actions

github-actions Bot commented Sep 7, 2024 •

Copy link
Copy Markdown

PR summary 40502a4bd5

Import changes exceeding 2%

% File
+8.33% Mathlib.Init

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
There are 4868 files with changed transitive imports taking up over 199781 characters: this is too many to display!
You can run scripts/import_trans_difference.sh all locally to see the whole output.

Declarations diff

+ authorsLineChecks
+ broadImportsCheck
+ copyrightHeaderChecks
+ firstNonImport?
+ getImportIds
+ headerLinter
+ parseUpToHere
+ replaceMultilineComments
+ toSyntax

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.

@grunweg grunweg left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I finally finished digesting this. This looks very good, and basically ready to maintainer merge --- once the commit with tweaks to copyright headers lands; I will PR that right now. (Edit: #17660)

Comment thread Mathlib/Tactic/Linter/Header.lean Resolved
@YaelDillies Can you comment on the comment in Data/Finset/Sym? Can that one
be removed, or should it be preserved? (If so, can it be clarified to be
understandable to other readers?)
remove debugging output. And tweak a comment.
And fix a defect on comparing style exceptions for the duplicate imports linter.
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Oct 11, 2024
mathlib-bors Bot pushed a commit that referenced this pull request Oct 11, 2024
The comment in `Data/Finset/Sym` is a porting artifact and can just be removed.

Pre-requisite for rewriting the copyright header linter in Lean in #16574.
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Oct 11, 2024
@mathlib4-dependent-issues-bot

Copy link
Copy Markdown

This PR/issue depends on:

@adomani adomani left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you so much for the review and the updates!

Comment thread Mathlib/Tactic/Linter/Header.lean Resolved
| .node _ ``Lean.Parser.Module.module #[_header, .node _ `null args] => args[0]?
| _=> some .missing -- this is unreachable, if the input comes from `testParseModule`

/-- `getImportIds s` takes as input `s : Syntax`.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If we are serious about controlling imports in Init, then maybe rather than adding a comment, we should actually think about what is wanted and how to enforce it.

@grunweg grunweg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is good to go.
maintainer merge

| .node _ ``Lean.Parser.Module.module #[_header, .node _ `null args] => args[0]?
| _=> some .missing -- this is unreachable, if the input comes from `testParseModule`

/-- `getImportIds s` takes as input `s : Syntax`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree this would be a good idea - and a follow-up PR. I just added a comment; feel free to tweak it.

@github-actions

Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by grunweg.

@github-actions github-actions Bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Oct 12, 2024
@kim-em

kim-em commented Oct 16, 2024

Copy link
Copy Markdown
Contributor

bors merge

@github-actions github-actions Bot added the ready-to-merge This PR has been sent to bors. label Oct 16, 2024
mathlib-bors Bot pushed a commit that referenced this pull request Oct 16, 2024
This syntax linter checks that
* the copyright statement is correctly formatted;
* `Mathlib.Tactic` is not imported;
* makes sure that the module docs are the first non-import command of each file.

The linter is off by default on projects downstream of mathlib, but it is on by default on mathlib.

This subsumes the corresponding text-based linters. These will be removed in a future PR.



Co-authored-by: Michael Rothgang <[email protected]>
Co-authored-by: grunweg <[email protected]>
@mathlib-bors

mathlib-bors Bot commented Oct 16, 2024

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title feat: the header linter [Merged by Bors] - feat: the header linter Oct 16, 2024
@mathlib-bors mathlib-bors Bot closed this Oct 16, 2024
@mathlib-bors
mathlib-bors Bot deleted the adomani/docModule_copied_assert_not_exists branch October 16, 2024 03:40
mathlib-bors Bot pushed a commit that referenced this pull request Oct 31, 2024
…nd author lines (#17556)

They are superseded by the header linter (#16574).
grunweg added a commit that referenced this pull request Nov 2, 2024
…nd author lines (#17556)

They are superseded by the header linter (#16574).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

large-import Automatically added label for PRs with a significant increase in transitive imports maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. ready-to-merge This PR has been sent to bors. t-linter Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants