Linters for Mathlib #
In this file we define additional linters for mathlib.
Perhaps these should be moved to Batteries in the future.
Linter that checks whether a structure should be in Prop.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Linter that check that all deprecated
tags come with since
dates.
Equations
- One or more equations did not get rendered due to their size.
Instances For
dupNamespace
linter #
The dupNamespace
linter produces a warning when a declaration contains the same namespace
at least twice consecutively.
For instance, Nat.Nat.foo
and One.two.two
trigger a warning, while Nat.One.Nat
does not.
The dupNamespace
linter is set on by default. Lean emits a warning on any declaration that
contains the same namespace at least twice consecutively.
For instance, Nat.Nat.foo
and One.two.two
trigger a warning, while Nat.One.Nat
does not.
Note.
This linter will not detect duplication in namespaces of autogenerated declarations
(other than the one whose declId
is present in the source declaration).
getIds stx
extracts the declId
nodes from the Syntax
stx
.
If stx
is an alias
or an export
, then it extracts an ident
, instead of a declId
.
The dupNamespace
linter is set on by default. Lean emits a warning on any declaration that
contains the same namespace at least twice consecutively.
For instance, Nat.Nat.foo
and One.two.two
trigger a warning, while Nat.One.Nat
does not.
Note.
This linter will not detect duplication in namespaces of autogenerated declarations
(other than the one whose declId
is present in the source declaration).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The "missing end" linter #
The "missing end" linter emits a warning on non-closed section
s and namespace
s.
It allows the "outermost" noncomputable section
to be left open (whether or not it is named).
The "missing end" linter emits a warning on non-closed section
s and namespace
s.
It allows the "outermost" noncomputable section
to be left open (whether or not it is named).
The "missing end" linter emits a warning on non-closed section
s and namespace
s.
It allows the "outermost" noncomputable section
to be left open (whether or not it is named).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The cdot
linter #
The cdot
linter is a syntax-linter that flags uses of the "cdot" ·
that are achieved
by typing a character different from ·
.
For instance, a "plain" dot .
is allowed syntax, but is flagged by the linter.
The cdot
linter flags uses of the "cdot" ·
that are achieved by typing a character
different from ·
.
For instance, a "plain" dot .
is allowed syntax, but is flagged by the linter.
findCDot stx
extracts from stx
the syntax nodes of kind
Lean.Parser.Term.cdot
or cdotTk
.
unwanted_cdot stx
returns an array of syntax atoms within stx
corresponding to cdot
s that are not written with the character ·
.
This is precisely what the cdot
linter flags.
Equations
- Mathlib.Linter.unwanted_cdot stx = Array.filter (fun (x : Lean.Syntax) => !Mathlib.Linter.isCDot? x) (Mathlib.Linter.findCDot stx)
Instances For
The cdot
linter flags uses of the "cdot" ·
that are achieved by typing a character
different from ·
.
For instance, a "plain" dot .
is allowed syntax, but is flagged by the linter.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The dollarSyntax
linter #
The dollarSyntax
linter flags uses of <|
that are achieved by typing $
.
These are disallowed by the mathlib style guide, as using <|
pairs better with |>
.
The dollarSyntax
linter flags uses of <|
that are achieved by typing $
.
These are disallowed by the mathlib style guide, as using <|
pairs better with |>
.
findDollarSyntax stx
extracts from stx
the syntax nodes of kind
$
.
The dollarSyntax
linter flags uses of <|
that are achieved by typing $
.
These are disallowed by the mathlib style guide, as using <|
pairs better with |>
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The lambdaSyntax
linter #
The lambdaSyntax
linter is a syntax linter that flags uses of the symbol λ
to define anonymous
functions, as opposed to the fun
keyword. These are syntactically equivalent; mathlib style
prefers the latter as it is considered more readable.
The lambdaSyntax
linter flags uses of the symbol λ
to define anonymous functions.
This is syntactically equivalent to the fun
keyword; mathlib style prefers using the latter.
findLambdaSyntax stx
extracts from stx
all syntax nodes of kind
Term.fun
.
The lambdaSyntax
linter flags uses of the symbol λ
to define anonymous functions.
This is syntactically equivalent to the fun
keyword; mathlib style prefers using the latter.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The "longFile" linter #
The "longFile" linter emits a warning on files which are longer than a certain number of lines (1500 by default).
The "longFile" linter emits a warning on files which are longer than a certain number of lines
(1500 by default). If this option is set to N
lines, the linter warns once a file has more than
N
lines. A value of 0
silences the linter entirely.
The "longFile" linter emits a warning on files which are longer than a certain number of lines
(1500 by default). If this option is set to N
lines, the linter warns once a file has more than
N
lines. A value of 0
silences the linter entirely.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The "longLine linter" #
The "longLine" linter emits a warning on lines longer than 100 characters. We allow lines containing URLs to be longer, though.
The "longLine" linter emits a warning on lines longer than 100 characters. We allow lines containing URLs to be longer, though.
Equations
- One or more equations did not get rendered due to their size.