@@ -23,7 +23,7 @@ defmodule NextLS.CredoExtensionTest do
23
23
File . write! ( foo , """
24
24
defmodule Foo do
25
25
def run() do
26
- :ok
26
+ dbg( :ok)
27
27
end
28
28
end
29
29
""" )
@@ -39,7 +39,7 @@ defmodule NextLS.CredoExtensionTest do
39
39
setup :with_lsp
40
40
41
41
@ tag init_options: % { "extensions" => % { "credo" => % { "enable" => false } } }
42
- test "disables Credo" , % { client: client , foo: foo } = context do
42
+ test "disables Credo" , % { client: client } = context do
43
43
assert :ok == notify ( client , % { method: "initialized" , jsonrpc: "2.0" , params: % { } } )
44
44
45
45
assert_is_ready ( context , "my_proj" )
@@ -51,6 +51,44 @@ defmodule NextLS.CredoExtensionTest do
51
51
}
52
52
end
53
53
54
+ @ tag init_options: % { "extensions" => % { "credo" => % { "cli_options" => [ "--only" , "warning" ] } } }
55
+ test "configures cli options" , % { client: client , foo: foo } = context do
56
+ assert :ok == notify ( client , % { method: "initialized" , jsonrpc: "2.0" , params: % { } } )
57
+
58
+ assert_is_ready ( context , "my_proj" )
59
+ assert_compiled ( context , "my_proj" )
60
+
61
+ assert_notification "window/logMessage" , % {
62
+ "message" => "[NextLS] [extension] Credo initializing with options" <> _ ,
63
+ "type" => 4
64
+ }
65
+
66
+ uri = uri ( foo )
67
+
68
+ assert_notification "textDocument/publishDiagnostics" , % {
69
+ "uri" => ^ uri ,
70
+ "diagnostics" => [
71
+ % {
72
+ "code" => "Credo.Check.Warning.Dbg" ,
73
+ "codeDescription" => % {
74
+ "href" => "https://hexdocs.pm/credo/Credo.Check.Warning.Dbg.html"
75
+ } ,
76
+ "data" => % {
77
+ "check" => "Elixir.Credo.Check.Warning.Dbg" ,
78
+ "file" => "lib/foo.ex"
79
+ } ,
80
+ "message" => "There should be no calls to dbg." ,
81
+ "range" => % {
82
+ "end" => % { "character" => 999 , "line" => 2 } ,
83
+ "start" => % { "character" => 4 , "line" => 2 }
84
+ } ,
85
+ "severity" => 2 ,
86
+ "source" => "credo"
87
+ }
88
+ ]
89
+ }
90
+ end
91
+
54
92
test "publishes credo diagnostics" , % { client: client , foo: foo } = context do
55
93
assert :ok == notify ( client , % { method: "initialized" , jsonrpc: "2.0" , params: % { } } )
56
94
@@ -69,20 +107,20 @@ defmodule NextLS.CredoExtensionTest do
69
107
"uri" => ^ uri ,
70
108
"diagnostics" => [
71
109
% {
72
- "code" => "Credo.Check.Readability.ParenthesesOnZeroArityDefs " ,
110
+ "code" => "Credo.Check.Warning.Dbg " ,
73
111
"codeDescription" => % {
74
- "href" => "https://hexdocs.pm/credo/Credo.Check.Readability.ParenthesesOnZeroArityDefs .html"
112
+ "href" => "https://hexdocs.pm/credo/Credo.Check.Warning.Dbg .html"
75
113
} ,
76
114
"data" => % {
77
- "check" => "Elixir.Credo.Check.Readability.ParenthesesOnZeroArityDefs " ,
115
+ "check" => "Elixir.Credo.Check.Warning.Dbg " ,
78
116
"file" => "lib/foo.ex"
79
117
} ,
80
- "message" => "Do not use parentheses when defining a function which has no arguments ." ,
118
+ "message" => "There should be no calls to dbg ." ,
81
119
"range" => % {
82
- "end" => % { "character" => 999 , "line" => 1 } ,
83
- "start" => % { "character" => 0 , "line" => 1 }
120
+ "end" => % { "character" => 999 , "line" => 2 } ,
121
+ "start" => % { "character" => 4 , "line" => 2 }
84
122
} ,
85
- "severity" => 3 ,
123
+ "severity" => 2 ,
86
124
"source" => "credo"
87
125
} ,
88
126
% {
0 commit comments