Skip to content

[Merged by Bors] - feat: add endOf linter - #14378

Closed
adomani wants to merge 21 commits into
masterfrom
adomani/endOfLinter_allow_noncomputable
Closed

adomani wants to merge 21 commits into
masterfrom
adomani/endOfLinter_allow_noncomputable

Conversation

@adomani

@adomani adomani commented Jul 3, 2024 •

Copy link
Copy Markdown
Contributor

This linter emits a warning at the end of a file if there are unclosed namespaces or sections.
All missing ends have been added (automatically) in #14621.

Unlike #14352, this PR does leaves outermost noncomputable sections open.

Zulip thread


Self-correcting script:

eval "$(
  lake build |
    grep -v "^\(✔ \[\|note: \|⚠ \[\|trace: \|Build completed\)" |
      sed -z "s=warning: \./\./\./\./\([^:]*\):[^']*'\([^']*\)'\n=\nprintf '\2\\n' >> \1\n\n\n=g" |
      sed -z "s=\n\n*=\n=g; s=\([^']\)\nend=\1\n\nend=g"
)"

Open in Gitpod

@github-actions

github-actions Bot commented Jul 3, 2024 •

Copy link
Copy Markdown

PR summary b600a781ce

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ endOfLinter
+ getLinterHash

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

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

@adomani adomani mentioned this pull request Jul 3, 2024
@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 5, 2024
@ghost ghost removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 6, 2024
@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 8, 2024
@ghost ghost removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 10, 2024

@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.

Thanks for writing this linter! Looks very nice overall --- I have some suggestions for polish, code clarity etc.
I pushed those directly: if you disagree with any or have further suggestions, I'm very interested in your opinion. Notably, I have tweaked the linter error message; your script will need adaptation.

I have not reviewed the automatic fixes yet, will do so next.

  • What do you think about adding a test?
  • I'm not sold on the name "EndOf" yet: what do you think about "openSectionsNamespaces", "unclosedSectionsNamespaces" or perhaps "unclosedScopes"?

@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've gone through all the automatic changes now. Obviously, they are all correct (in the sense that they compile and pass the linter). A few times, they expose pre-existing weirdness; I'd prefer to fix that instead. (This could be a pre-requisite PR which I can approve quickly.)

· simp only [Set.mem_setOf_eq, Walk.start_mem_support, exists_true_left]
refine ⟨hw, Walk.connected_induce_support _ _ _⟩

end induced_subgraphs

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.

Pre-existing: do we have a policy that section names should be CamelCase or match their declarations?

Comment thread Mathlib/RingTheory/Bialgebra/Basic.lean Resolved

end Positivity

end Meta

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.

Also pre-existing: tactics are sometimes in the Meta and sometimes in the Tactic namespaces: is there an intentional difference? (Presumably also out of scope of this PR.)

Comment thread Mathlib/Topology/Separation.lean Resolved
Comment thread test/Lint.lean Resolved
Comment thread test/Traversable.lean

end

end Testing

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.

This namespace is inconsistent with the other tests -> rename to Tests instead?

@grunweg

grunweg commented Jul 10, 2024 •

Copy link
Copy Markdown
Contributor

#14620 contains a few of these fixes.
As discussed with adomani, let's land these fixes as a follow-up, and land the linter now.

Comment thread Mathlib/Tactic/Linter/Lint.lean Resolved
@ghost ghost added merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) and removed blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) labels Jul 10, 2024
@grunweg grunweg removed merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. labels Jul 10, 2024
@grunweg

grunweg commented Jul 10, 2024

Copy link
Copy Markdown
Contributor

The fixes to the other files have landed; I have merged master. This PR now just contains the linter.
I still think the implementation is good.
maintainer merge

@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 Jul 10, 2024
@grunweg grunweg added the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Jul 10, 2024
@github-actions github-actions Bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Jul 10, 2024

@jcommelin jcommelin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks 🎉

bors merge

mathlib-bors Bot pushed a commit that referenced this pull request Jul 11, 2024
This linter emits a warning at the end of a file if there are unclosed `namespace`s or `section`s.
All missing `end`s have been added (automatically) in #14621.

Unlike #14352, this PR does leaves outermost `noncomputable section`s open.

[Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/linting.20for.20unclosed.20sections.3F)



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

mathlib-bors Bot commented Jul 11, 2024

Copy link
Copy Markdown
Contributor

Build failed (retrying...):

mathlib-bors Bot pushed a commit that referenced this pull request Jul 11, 2024
This linter emits a warning at the end of a file if there are unclosed `namespace`s or `section`s.
All missing `end`s have been added (automatically) in #14621.

Unlike #14352, this PR does leaves outermost `noncomputable section`s open.

[Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/linting.20for.20unclosed.20sections.3F)



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

mathlib-bors Bot commented Jul 11, 2024

Copy link
Copy Markdown
Contributor

Build failed (retrying...):

@mattrobball

Copy link
Copy Markdown
Contributor

bors r-

@mathlib-bors

mathlib-bors Bot commented Jul 11, 2024

Copy link
Copy Markdown
Contributor

Canceled.

@mattrobball

Copy link
Copy Markdown
Contributor

Wronskian violates the linter and just got in

@mattrobball

Copy link
Copy Markdown
Contributor

bors delegate+

Please merge again when fixed

@mathlib-bors

mathlib-bors Bot commented Jul 11, 2024

Copy link
Copy Markdown
Contributor

✌️ adomani can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@github-actions github-actions Bot added the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Jul 11, 2024
@adomani

adomani commented Jul 11, 2024

Copy link
Copy Markdown
Contributor Author

bors r+

mathlib-bors Bot pushed a commit that referenced this pull request Jul 11, 2024
This linter emits a warning at the end of a file if there are unclosed `namespace`s or `section`s.
All missing `end`s have been added (automatically) in #14621.

Unlike #14352, this PR does leaves outermost `noncomputable section`s open.

[Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/linting.20for.20unclosed.20sections.3F)



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

mathlib-bors Bot commented Jul 11, 2024

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title feat: add endOf linter [Merged by Bors] - feat: add endOf linter Jul 11, 2024
@mathlib-bors mathlib-bors Bot closed this Jul 11, 2024
@mathlib-bors
mathlib-bors Bot deleted the adomani/endOfLinter_allow_noncomputable branch July 11, 2024 15:09
@adomani adomani mentioned this pull request Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. t-linter Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants