HepLean Documentation

Mathlib.Tactic.Linter.Style

Style linters #

This file contain linters about stylistic aspects: these are only about coding style, but do not affect correctness nor global coherence of mathlib. Historically, some of these were ported from the lint-style.py Python script.

This file defines the following linters:

All of these linters are enabled in mathlib by default, but disabled globally since they enforce conventions which are inherently subjective.

The setOption linter emits a warning on a set_option command, term or tactic which sets a pp, profiler or trace option.

Whether a syntax element is a set_option command, tactic or term: Return the name of the option being set, if any.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Whether a given piece of syntax is a set_option command, tactic or term.

    Equations
    Instances For

      The setOption linter: this lints any set_option command, term or tactic which sets a pp, profiler or trace option.

      Why is this bad? These options are good for debugging, but should not be used in production code. How to fix this? Remove these options: usually, they are not necessary for production code. (Some tests will intentionally use one of these options; in this case, simply allow the linter.)

      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 sections and namespaces. 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 sections and namespaces. 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 sections and namespaces. 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. It also flags "isolated cdots", i.e. when the · is on its own line.

          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. It also flags "isolated cdots", i.e. when the · is on its own line.

          isCDot? stx checks whether stx is a Syntax node corresponding to a cdot typed with the character ·.

          Instances For

            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 cdots that are not written with the character ·. This is precisely what the cdot linter flags.

            Equations
            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. It also flags "isolated cdots", i.e. when the · is on its own line.

              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 (linter.style.longFileDefValue by default on mathlib, no limit for downstream projects). 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 number of lines that the longFile linter considers the default.

                    The "longFile" linter emits a warning on files which are longer than a certain number of lines (linter.style.longFileDefValue by default on mathlib, no limit for downstream projects). 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.
                      Instances For