Skip to content

Commit 172492c

Browse files
committed
chore: move linter.setOption to the style namespace (#16212)
Extracted from #15971.
1 parent 6eb5bd6 commit 172492c

File tree

8 files changed

+33
-33
lines changed

8 files changed

+33
-33
lines changed

Mathlib/Tactic/Linter/Style.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ namespace Mathlib.Linter
2323

2424
/-- The `setOption` linter emits a warning on a `set_option` command, term or tactic
2525
which sets a `pp`, `profiler` or `trace` option. -/
26-
register_option linter.setOption : Bool := {
26+
register_option linter.style.setOption : Bool := {
2727
defValue := false
2828
descr := "enable the `setOption` linter"
2929
}
3030

31-
namespace Style.SetOption
31+
namespace Style.setOption
3232

3333
/-- Whether a syntax element is a `set_option` command, tactic or term:
3434
Return the name of the option being set, if any. -/
@@ -52,22 +52,22 @@ used in production code.
5252
(Some tests will intentionally use one of these options; in this case, simply allow the linter.)
5353
-/
5454
def setOptionLinter : Linter where run := withSetOptionIn fun stx => do
55-
unless Linter.getLinterValue linter.setOption (← getOptions) do
55+
unless Linter.getLinterValue linter.style.setOption (← getOptions) do
5656
return
5757
if (← MonadState.get).messages.hasErrors then
5858
return
5959
if let some head := stx.find? is_set_option then
6060
if let some name := parse_set_option head then
6161
let forbidden := [`debug, `pp, `profiler, `trace]
6262
if forbidden.contains name.getRoot then
63-
Linter.logLint linter.setOption head
63+
Linter.logLint linter.style.setOption head
6464
m!"Setting options starting with '{"', '".intercalate (forbidden.map (·.toString))}' \
6565
is only intended for development and not for final code. \
6666
If you intend to submit this contribution to the Mathlib project, \
6767
please remove 'set_option {name}'."
6868

6969
initialize addLinter setOptionLinter
7070

71-
end Style.SetOption
71+
end Style.setOption
7272

7373
end Mathlib.Linter

lakefile.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ abbrev mathlibOnlyLinters : Array LeanOption := #[
3131
`linter.longLine, true⟩,
3232
`linter.oldObtain, true,⟩,
3333
`linter.refine, true⟩,
34-
`linter.setOption, true
34+
`linter.style.setOption, true
3535
]
3636

3737
/-- These options are passed as `leanOptions` to building mathlib, as well as the

test/Explode.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ info: true_iff : ∀ (p : Prop), (True ↔ p) = p
2424
-/
2525
#guard_msgs in #explode true_iff
2626

27-
set_option linter.setOption false
27+
set_option linter.style.setOption false
2828
-- On command line, tests format functions with => rather than ↦ without this.
2929
set_option pp.unicode.fun true
3030

test/LibrarySearch/basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Mathlib.Data.Real.Basic
66

77
set_option autoImplicit true
88

9-
set_option linter.setOption false
9+
set_option linter.style.setOption false
1010
-- Enable this option for tracing:
1111
-- set_option trace.Tactic.librarySearch true
1212
-- And this option to trace all candidate lemmas before application.

test/LintStyle.lean

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import Mathlib.Tactic.Common
66
/-! Tests for the `setOption` linter -/
77
section setOption
88

9-
-- The warning generated by `linter.setOption` is not suppressed by `#guard_msgs`,
9+
-- The warning generated by `linter.style.setOption` is not suppressed by `#guard_msgs`,
1010
-- because the linter is run on `#guard_msgs` itself. This is a known issue, see e.g.
1111
-- https://leanprover.zulipchat.com/#narrow/stream/348111-batteries/topic/unreachableTactic.20linter.20not.20suppressed.20by.20.60.23guard_msgs.60
1212
-- We jump through an extra hoop here to silence the warning.
13-
set_option linter.setOption false
13+
set_option linter.style.setOption false
1414

1515
-- All types of options are supported: boolean, numeric and string-valued.
1616
-- On the top level, i.e. as commands.
@@ -19,60 +19,60 @@ set_option linter.setOption false
1919
warning: Setting options starting with 'debug', 'pp', 'profiler', 'trace' is only intended
2020
for development and not for final code. If you intend to submit this contribution to the
2121
Mathlib project, please remove 'set_option pp.all'.
22-
note: this linter can be disabled with `set_option linter.setOption false`
22+
note: this linter can be disabled with `set_option linter.style.setOption false`
2323
-/
2424
#guard_msgs in
25-
set_option linter.setOption true in
25+
set_option linter.style.setOption true in
2626
set_option pp.all true
2727

2828
/--
2929
warning: Setting options starting with 'debug', 'pp', 'profiler', 'trace' is only intended
3030
for development and not for final code. If you intend to submit this contribution to the
3131
Mathlib project, please remove 'set_option profiler'.
32-
note: this linter can be disabled with `set_option linter.setOption false`
32+
note: this linter can be disabled with `set_option linter.style.setOption false`
3333
-/
3434
#guard_msgs in
35-
set_option linter.setOption true in
35+
set_option linter.style.setOption true in
3636
set_option profiler false
3737

3838
/--
3939
warning: Setting options starting with 'debug', 'pp', 'profiler', 'trace' is only intended
4040
for development and not for final code. If you intend to submit this contribution to the
4141
Mathlib project, please remove 'set_option pp.all'.
42-
note: this linter can be disabled with `set_option linter.setOption false`
42+
note: this linter can be disabled with `set_option linter.style.setOption false`
4343
-/
4444
#guard_msgs in
45-
set_option linter.setOption true in
45+
set_option linter.style.setOption true in
4646
set_option pp.all false
4747

4848
/--
4949
warning: Setting options starting with 'debug', 'pp', 'profiler', 'trace' is only intended
5050
for development and not for final code. If you intend to submit this contribution to the
5151
Mathlib project, please remove 'set_option profiler.threshold'.
52-
note: this linter can be disabled with `set_option linter.setOption false`
52+
note: this linter can be disabled with `set_option linter.style.setOption false`
5353
-/
5454
#guard_msgs in
55-
set_option linter.setOption true in
55+
set_option linter.style.setOption true in
5656
set_option profiler.threshold 50
5757

5858
/--
5959
warning: Setting options starting with 'debug', 'pp', 'profiler', 'trace' is only intended
6060
for development and not for final code. If you intend to submit this contribution to the
6161
Mathlib project, please remove 'set_option trace.profiler.output'.
62-
note: this linter can be disabled with `set_option linter.setOption false`
62+
note: this linter can be disabled with `set_option linter.style.setOption false`
6363
-/
6464
#guard_msgs in
65-
set_option linter.setOption true in
65+
set_option linter.style.setOption true in
6666
set_option trace.profiler.output "foo"
6767

6868
/--
6969
warning: Setting options starting with 'debug', 'pp', 'profiler', 'trace' is only intended
7070
for development and not for final code. If you intend to submit this contribution to the
7171
Mathlib project, please remove 'set_option debug.moduleNameAtTimeout'.
72-
note: this linter can be disabled with `set_option linter.setOption false`
72+
note: this linter can be disabled with `set_option linter.style.setOption false`
7373
-/
7474
#guard_msgs in
75-
set_option linter.setOption true in
75+
set_option linter.style.setOption true in
7676
set_option debug.moduleNameAtTimeout false
7777

7878
-- The lint does not fire on arbitrary options.
@@ -84,10 +84,10 @@ set_option autoImplicit false
8484
warning: Setting options starting with 'debug', 'pp', 'profiler', 'trace' is only intended
8585
for development and not for final code. If you intend to submit this contribution to the
8686
Mathlib project, please remove 'set_option pp.all'.
87-
note: this linter can be disabled with `set_option linter.setOption false`
87+
note: this linter can be disabled with `set_option linter.style.setOption false`
8888
-/
8989
#guard_msgs in
90-
set_option linter.setOption true in
90+
set_option linter.style.setOption true in
9191
lemma tactic : True := by
9292
set_option pp.all true in
9393
trivial
@@ -96,10 +96,10 @@ lemma tactic : True := by
9696
warning: Setting options starting with 'debug', 'pp', 'profiler', 'trace' is only intended
9797
for development and not for final code. If you intend to submit this contribution to the
9898
Mathlib project, please remove 'set_option pp.raw.maxDepth'.
99-
note: this linter can be disabled with `set_option linter.setOption false`
99+
note: this linter can be disabled with `set_option linter.style.setOption false`
100100
-/
101101
#guard_msgs in
102-
set_option linter.setOption true in
102+
set_option linter.style.setOption true in
103103
lemma tactic2 : True := by
104104
set_option pp.raw.maxDepth 32 in
105105
trivial
@@ -108,10 +108,10 @@ lemma tactic2 : True := by
108108
warning: Setting options starting with 'debug', 'pp', 'profiler', 'trace' is only intended
109109
for development and not for final code. If you intend to submit this contribution to the
110110
Mathlib project, please remove 'set_option pp.all'.
111-
note: this linter can be disabled with `set_option linter.setOption false`
111+
note: this linter can be disabled with `set_option linter.style.setOption false`
112112
-/
113113
#guard_msgs in
114-
set_option linter.setOption true in
114+
set_option linter.style.setOption true in
115115
lemma tactic3 : True := by
116116
set_option pp.all false in
117117
trivial
@@ -120,10 +120,10 @@ lemma tactic3 : True := by
120120
warning: Setting options starting with 'debug', 'pp', 'profiler', 'trace' is only intended
121121
for development and not for final code. If you intend to submit this contribution to the
122122
Mathlib project, please remove 'set_option trace.profiler.output'.
123-
note: this linter can be disabled with `set_option linter.setOption false`
123+
note: this linter can be disabled with `set_option linter.style.setOption false`
124124
-/
125125
#guard_msgs in
126-
set_option linter.setOption true in
126+
set_option linter.style.setOption true in
127127
lemma tactic4 : True := by
128128
set_option trace.profiler.output "foo" in
129129
trivial

test/Recall.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Mathlib.Analysis.Calculus.Deriv.Basic
33
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic
44
import Mathlib.Data.Complex.Exponential
55

6-
set_option linter.setOption false
6+
set_option linter.style.setOption false
77
-- Remark: When the test is run by make/CI, this option is not set, so we set it here.
88
set_option pp.unicode.fun true
99
set_option autoImplicit true

test/delabLinearIndependent.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Mathlib.LinearAlgebra.LinearIndependent
22

3-
set_option linter.setOption false
3+
set_option linter.style.setOption false
44
set_option pp.unicode.fun true
55

66
variable {K V : Type*} [DivisionRing K] [AddCommGroup V] [Module K V] {s : Set V} {x : V}

test/vec_notation.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ open Lean
88
open Lean.Meta
99
open Qq
1010

11-
set_option linter.setOption false in
11+
set_option linter.style.setOption false in
1212
set_option pp.unicode.fun false
1313

1414
/-! These tests are testing `PiFin.toExpr` and fail with

0 commit comments

Comments
 (0)