File: .lake/packages/batteries/Batteries/Tactic/Lint/Basic.lean

full_name: Std.Tactic.Lint.isAutoDecl
code: /--
Returns true if `decl` is an automatically generated declaration.

Also returns true if `decl` is an internal name or created during macro
expansion.
-/
def isAutoDecl (decl : Name) : CoreM Bool 
goal: Lean.CoreM Bool

full_name: Std.Tactic.Lint.Linter.noErrorsFound
code: /-- A linting test for the `#lint` command. -/
structure Linter where
  /-- `test` defines a test to perform on every declaration. It should never fail. Returning `none`
  signifies a passing test. Returning `some msg` reports a failing test with error `msg`. -/
  test : Name → MetaM (Option MessageData)
  /-- `noErrorsFound` is the message printed when all tests are negative -/
  noErrorsFound : MessageData
  /-- `errorsFound` is printed when at least one test is positive -/
  errorsFound : MessageData
  /-- If `isFast` is false, this test will be omitted from `#lint-`. -/
  isFast := true
goal: Lean.MessageData

full_name: Std.Tactic.Lint.Linter.isFast
code: /-- A linting test for the `#lint` command. -/
structure Linter where
  /-- `test` defines a test to perform on every declaration. It should never fail. Returning `none`
  signifies a passing test. Returning `some msg` reports a failing test with error `msg`. -/
  test : Name → MetaM (Option MessageData)
  /-- `noErrorsFound` is the message printed when all tests are negative -/
  noErrorsFound : MessageData
  /-- `errorsFound` is printed when at least one test is positive -/
  errorsFound : MessageData
  /-- If `isFast` is false, this test will be omitted from `#lint-`. -/
  isFast := true
goal: Bool

full_name: Std.Tactic.Lint.Linter.errorsFound
code: /-- A linting test for the `#lint` command. -/
structure Linter where
  /-- `test` defines a test to perform on every declaration. It should never fail. Returning `none`
  signifies a passing test. Returning `some msg` reports a failing test with error `msg`. -/
  test : Name → MetaM (Option MessageData)
  /-- `noErrorsFound` is the message printed when all tests are negative -/
  noErrorsFound : MessageData
  /-- `errorsFound` is printed when at least one test is positive -/
  errorsFound : MessageData
  /-- If `isFast` is false, this test will be omitted from `#lint-`. -/
  isFast := true
goal: Lean.MessageData

full_name: Std.Tactic.Lint.Linter.test
code: /-- A linting test for the `#lint` command. -/
structure Linter where
  /-- `test` defines a test to perform on every declaration. It should never fail. Returning `none`
  signifies a passing test. Returning `some msg` reports a failing test with error `msg`. -/
  test : Name → MetaM (Option MessageData)
  /-- `noErrorsFound` is the message printed when all tests are negative -/
  noErrorsFound : MessageData
  /-- `errorsFound` is printed when at least one test is positive -/
  errorsFound : MessageData
  /-- If `isFast` is false, this test will be omitted from `#lint-`. -/
  isFast := true
goal: Lean.Name → Lean.MetaM (Option Lean.MessageData)

full_name: Std.Tactic.Lint.Linter
code: /-- A linting test for the `#lint` command. -/
structure Linter where
  /-- `test` defines a test to perform on every declaration. It should never fail. Returning `none`
  signifies a passing test. Returning `some msg` reports a failing test with error `msg`. -/
  test : Name → MetaM (Option MessageData)
  /-- `noErrorsFound` is the message printed when all tests are negative -/
  noErrorsFound : MessageData
  /-- `errorsFound` is printed when at least one test is positive -/
  errorsFound : MessageData
  /-- If `isFast` is false, this test will be omitted from `#lint-`. -/
  isFast := true
goal: Type

full_name: Std.Tactic.Lint.NamedLinter
code: /-- A `NamedLinter` is a linter associated to a particular declaration. -/
structure NamedLinter extends Linter where
  /-- The name of the named linter. This is just the declaration name without the namespace. -/
  name : Name
  /-- The linter declaration name -/
  declName : Name
goal: Type

full_name: Std.Tactic.Lint.NamedLinter.name
code: /-- A `NamedLinter` is a linter associated to a particular declaration. -/
structure NamedLinter extends Linter where
  /-- The name of the named linter. This is just the declaration name without the namespace. -/
  name : Name
  /-- The linter declaration name -/
  declName : Name
goal: Lean.Name

full_name: Std.Tactic.Lint.NamedLinter.declName
code: /-- A `NamedLinter` is a linter associated to a particular declaration. -/
structure NamedLinter extends Linter where
  /-- The name of the named linter. This is just the declaration name without the namespace. -/
  name : Name
  /-- The linter declaration name -/
  declName : Name
goal: Lean.Name

full_name: Std.Tactic.Lint.getLinter
code: /-- Gets a linter by declaration name. -/
def getLinter (name declName : Name) : CoreM NamedLinter 
goal: Lean.CoreM Std.Tactic.Lint.NamedLinter

full_name: Std.Tactic.Lint.batteriesLinterExt
code: /-- Defines the `env_linter` extension for adding a linter to the default set. -/
initialize batteriesLinterExt :
    PersistentEnvExtension (Name × Bool) (Name × Bool) (NameMap (Name × Bool)) ←
  let addEntryFn := fun m (n, b) => m.insert (n.updatePrefix .anonymous) (n, b)
  registerPersistentEnvExtension {
    mkInitial := pure {}
    addImportedFn := fun nss => pure <|
      nss.foldl (init := {}) fun m ns => ns.foldl (init := m) addEntryFn
    addEntryFn
    exportEntriesFn := fun es => es.fold (fun a _ e => a.push e) #[]
  }
goal: Lean.PersistentEnvExtension (Lean.Name × Bool) (Lean.Name × Bool) (Lean.NameMap (Lean.Name × Bool))

full_name: Std.Tactic.Lint.initFn._@..lake.packages.batteries.Batteries.Tactic.Lint.Basic._hyg.627
code: /-- Defines the `env_linter` extension for adding a linter to the default set. -/
initialize batteriesLinterExt :
    PersistentEnvExtension (Name × Bool) (Name × Bool) (NameMap (Name × Bool)) ←
  let addEntryFn := fun m (n, b) => m.insert (n.updatePrefix .anonymous) (n, b)
  registerPersistentEnvExtension {
    mkInitial := pure {}
    addImportedFn := fun nss => pure <|
      nss.foldl (init := {}) fun m ns => ns.foldl (init := m) addEntryFn
    addEntryFn
    exportEntriesFn := fun es => es.fold (fun a _ e => a.push e) #[]
  }
goal: IO (Lean.PersistentEnvExtension (Lean.Name × Bool) (Lean.Name × Bool) (Lean.NameMap (Lean.Name × Bool)))

full_name: Std.Tactic.Lint.env_linter
code: /--
Defines the `@[env_linter]` attribute for adding a linter to the default set.
The form `@[env_linter disabled]` will not add the linter to the default set,
but it will be shown by `#list_linters` and can be selected by the `#lint` command.

Linters are named using their declaration names, without the namespace. These must be distinct.
-/
syntax (name := env_linter) "env_linter" &" disabled"? : attr
goal: Lean.ParserDescr

full_name: Std.Tactic.Lint.initFn._@..lake.packages.batteries.Batteries.Tactic.Lint.Basic._hyg.817
code: initialize registerBuiltinAttribute {
  name := `env_linter
  descr := "Use this declaration as a linting test in #lint"
  add   := fun decl stx kind => do
    let dflt := stx[1].isNone
    unless kind == .global do throwError "invalid attribute 'env_linter', must be global"
    let shortName := decl.updatePrefix .anonymous
    if let some (declName, _) := (batteriesLinterExt.getState (← getEnv)).find? shortName then
      Elab.addConstInfo stx declName
      throwError
        "invalid attribute 'env_linter', linter '{shortName}' has already been declared"
    let constInfo ← getConstInfo decl
    unless ← (isDefEq constInfo.type (mkConst ``Linter)).run' do
      throwError "must have type Linter, got {constInfo.type}"
    modifyEnv fun env => batteriesLinterExt.addEntry env (decl, dflt)
}
goal: IO Unit

full_name: Std.Tactic.Lint.nolint
code: /-- `@[nolint linterName]` omits the tagged declaration from being checked by
the linter with name `linterName`. -/
syntax (name := nolint) "nolint" (ppSpace ident)+ : attr
goal: Lean.ParserDescr

full_name: Std.Tactic.Lint.nolintAttr
code: /-- Defines the user attribute `nolint` for skipping `#lint` -/
initialize nolintAttr : ParametricAttribute (Array Name) ←
  registerParametricAttribute {
    name := `nolint
    descr := "Do not report this declaration in any of the tests of `#lint`"
    getParam := fun _ => fun
      | `(attr| nolint $[$ids]*) => ids.mapM fun id => withRef id <| do
        let shortName := id.getId.eraseMacroScopes
        let some (declName, _) := (batteriesLinterExt.getState (← getEnv)).find? shortName
          | throwError "linter '{shortName}' not found"
        Elab.addConstInfo id declName
        pure shortName
      | _ => Elab.throwUnsupportedSyntax
  }
goal: Lean.ParametricAttribute (Array Lean.Name)

full_name: Std.Tactic.Lint.initFn._@..lake.packages.batteries.Batteries.Tactic.Lint.Basic._hyg.1278
code: /-- Defines the user attribute `nolint` for skipping `#lint` -/
initialize nolintAttr : ParametricAttribute (Array Name) ←
  registerParametricAttribute {
    name := `nolint
    descr := "Do not report this declaration in any of the tests of `#lint`"
    getParam := fun _ => fun
      | `(attr| nolint $[$ids]*) => ids.mapM fun id => withRef id <| do
        let shortName := id.getId.eraseMacroScopes
        let some (declName, _) := (batteriesLinterExt.getState (← getEnv)).find? shortName
          | throwError "linter '{shortName}' not found"
        Elab.addConstInfo id declName
        pure shortName
      | _ => Elab.throwUnsupportedSyntax
  }
goal: IO (Lean.ParametricAttribute (Array Lean.Name))

full_name: Std.Tactic.Lint.shouldBeLinted
code: /-- Returns true if `decl` should be checked
using `linter`, i.e., if there is no `nolint` attribute. -/
def shouldBeLinted [Monad m] [MonadEnv m] (linter : Name) (decl : Name) : m Bool 
goal: m Bool