@@ -55,11 +55,12 @@ open Lean Elab Command in
5555`#check_copyright cop` takes as input the `String` `cop`, expected to be a copyright statement.
5656It logs details of what the linter would report if the `cop` is "malformed".
5757-/
58- elab "#check_copyright " cop:str : command => do
59- let cop := cop.getString
58+ elab "#check_copyright " copStx:str : command => do
59+ let cop := copStx.getString
60+ let offset := copStx.raw.getPos?.get!.increaseBy 1
6061 for (s, m) in Mathlib.Linter.copyrightHeaderChecks cop do
6162 if let some rg := s.getRange? then
62- logInfo
63+ logInfoAt (.ofRange ({start := rg.start.offsetBy offset, stop := rg. stop .offsetBy offset}))
6364 m!"Text: `{replaceMultilineComments s.getAtomVal}`\n \
6465 Range: {(rg.start, rg.stop)}\n \
6566 Message: '{replaceMultilineComments m}'"
@@ -320,3 +321,74 @@ Authors: Name LastName
320321 and others.
321322-/
322323"
324+
325+ /--
326+ info: Text: `Authors:`
327+ Range: (140, 148)
328+ Message: 'The authors line should begin with 'Authors: ''
329+ -/
330+ #guard_msgs in
331+ #check_copyright
332+ "/-
333+ Copyright (c) 2024 Damiano Testa, another Name. All rights reserved.
334+ Released under Apache 2.0 license as described in the file LICENSE.
335+ Authors:
336+ -/
337+ "
338+
339+ /--
340+ info: Text: `. All rights reserved.`
341+ Range: (21, 43)
342+ Message: ''Copyright (c) YYYY' should be followed by a space'
343+ -/
344+ #guard_msgs in
345+ #check_copyright
346+ "/-
347+ Copyright (c) 2024. All rights reserved.
348+ Released under Apache 2.0 license as described in the file LICENSE.
349+ Authors: A
350+ -/
351+ "
352+
353+ /--
354+ info: Text: `. All rights reserved.`
355+ Range: (22, 44)
356+ Message: 'There should be at least one copyright author, separated from the year by exactly one space.'
357+ -/
358+ #guard_msgs in
359+ #check_copyright
360+ "/-
361+ Copyright (c) 2024 . All rights reserved.
362+ Released under Apache 2.0 license as described in the file LICENSE.
363+ Authors: A
364+ -/
365+ "
366+
367+ -- We don't do further validation of names.
368+
369+ #guard_msgs in
370+ #check_copyright
371+ "/-
372+ Copyright (c) 2024 nameinalllowercase. All rights reserved.
373+ Released under Apache 2.0 license as described in the file LICENSE.
374+ Authors: A
375+ -/
376+ "
377+
378+ #guard_msgs in
379+ #check_copyright
380+ "/-
381+ Copyright (c) 2024 First middle LastName. All rights reserved.
382+ Released under Apache 2.0 license as described in the file LICENSE.
383+ Authors: A
384+ -/
385+ "
386+
387+ #guard_msgs in
388+ #check_copyright
389+ "/-
390+ Copyright (c) 2024 First Last Name jr.. All rights reserved.
391+ Released under Apache 2.0 license as described in the file LICENSE.
392+ Authors: A
393+ -/
394+ "
0 commit comments