Skip to content

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

Closed
adomani wants to merge 21 commits intomasterfrom
adomani/endOfLinter_allow_noncomputable
Closed

[Merged by Bors] - feat: add endOf linter#14378
adomani wants to merge 21 commits intomasterfrom
adomani/endOfLinter_allow_noncomputable

Conversation

@adomani
Copy link
Copy Markdown
Contributor

@adomani adomani commented Jul 3, 2024

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
Copy link
Copy Markdown

github-actions bot commented Jul 3, 2024

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
Copy link
Copy Markdown
Contributor

@grunweg grunweg left a comment

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"?

Copy link
Copy Markdown
Contributor

@grunweg grunweg left a comment

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?


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


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
Copy link
Copy Markdown
Contributor

grunweg commented Jul 10, 2024

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

@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 A reviewer has asked the author a question or requested changes. labels Jul 10, 2024
@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Jul 10, 2024

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
Copy link
Copy Markdown
Member

@jcommelin jcommelin left a comment

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 <rothgami@math.hu-berlin.de>
Co-authored-by: grunweg <rothgami@math.hu-berlin.de>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jul 11, 2024

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 <rothgami@math.hu-berlin.de>
Co-authored-by: grunweg <rothgami@math.hu-berlin.de>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jul 11, 2024

Build failed (retrying...):

@mattrobball
Copy link
Copy Markdown
Contributor

bors r-

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jul 11, 2024

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
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jul 11, 2024

✌️ 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
Copy link
Copy Markdown
Contributor Author

adomani commented Jul 11, 2024

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 <rothgami@math.hu-berlin.de>
Co-authored-by: grunweg <rothgami@math.hu-berlin.de>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jul 11, 2024

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