Skip to content

Commit

Permalink
wip: testing: copyright mostly works; isolated by is too weak -> stre…
Browse files Browse the repository at this point in the history
…ngthen next!
  • Loading branch information
grunweg committed May 25, 2024
1 parent 6d70611 commit d61b18a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Mathlib/Tactic/Linter/TextBased.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2024 Michael Rothgang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Rothgang
Author: Michael Rothgang and Joe Doe
-/

import Lean.Elab.Command
Expand Down Expand Up @@ -175,7 +175,8 @@ def copyright_header : LinterCore := fun lines ↦ Id.run do
-- The second line should be standard.
let expected_second_line := "Released under Apache 2.0 license as described in the file LICENSE."
if start.get? 2 != some expected_second_line then
output := output.push (StyleError.copyright s!"Second line should be {expected_second_line}", 3)
output := output.push (StyleError.copyright
s!"Second line should be \"{expected_second_line}\"", 3)
-- The third line should contain authors.
if let some line := start.get? 3 then
if !line.containsSubstr "Author" then
Expand All @@ -202,7 +203,8 @@ def isolated_by_dot_semicolon : LinterCore := fun lines ↦ Id.run do
-- should not be used in the second or later arguments of a tuple/anonymous constructor
-- See https://github.com/leanprover-community/mathlib4/pull/3825#discussion_r1186702599
if !previous_line.endsWith "," then
if !(line.containsSubstr ", fun" && (line.endsWith "=>" || line.endsWith "↦")) then
if !(previous_line.containsSubstr ", fun" &&
(previous_line.endsWith "=>" || previous_line.endsWith "↦")) then
output := output.push (StyleError.isolated_by, line_number)
if line.trimRight.startsWith ". " then
output := output.push (StyleError.dot, line_number) -- has an auto-fix
Expand Down Expand Up @@ -230,7 +232,7 @@ def lint_file (path : System.FilePath) : IO Unit := do
-- XXX: this list is currently not sorted: for github, that's probably fine
format_errors (Array.flatten all_output) (Array.mkEmpty 0)

-- #eval lint_file (System.mkFilePath ["Mathlib", "Tactic", "Linter", "TextBased.lean"])
#eval lint_file (System.mkFilePath ["Mathlib", "Tactic", "Linter", "TextBased.lean"])

/-- Lint all files in `Mathlib.lean`. -/
def check_all_files : IO Unit := do
Expand Down

0 comments on commit d61b18a

Please sign in to comment.