diff --git a/src/Lint.jl b/src/Lint.jl index 607aa6d..3b419d1 100644 --- a/src/Lint.jl +++ b/src/Lint.jl @@ -356,7 +356,7 @@ function lintdir{T<:AbstractString}(dir::T, ctx::LintContext=LintContext()) ctx.messages end -function convertmsgtojson(msgs, style) +function convertmsgtojson(msgs, style, dict_data) if style == "lint-message" return JSON.json(msgs) end @@ -381,13 +381,22 @@ function convertmsgtojson(msgs, style) end if style == "standard-linter-v1" + if haskey(dict_data,"show_code") + if dict_data["show_code"] + msgtext = "$code $evar: $txt" + else + msgtext = "$evar: $txt" + end + else + msgtext = "$code $evar: $txt" + end push!(output, Dict("type" => etype, - "text" => "$code $evar $txt", + "text" => msgtext, "range" => errorrange, "filePath" => file)) elseif style == "vscode" push!(output, Dict("severity" => etypenumber, - "message" => "$evar $txt", + "message" => "$evar: $txt", "range" => errorrange, "filePath" => file, "code" => code, @@ -397,7 +406,7 @@ function convertmsgtojson(msgs, style) "location" => Dict("file" => file, "position" => errorrange), "excerpt" => code, - "description" => "$evar $txt")) + "description" => "$evar: $txt")) end end @@ -445,8 +454,8 @@ function readandwritethestream(conn,style) else dict_data = JSON.parse(conn) msgs = lintfile(dict_data["file"], dict_data["code_str"]) - msgs = filtermsgs(msgs,dict_data) - out = convertmsgtojson(msgs,style) + msgs = filtermsgs(msgs, dict_data) + out = convertmsgtojson(msgs, style, dict_data) write(conn,out) end end diff --git a/test/server.jl b/test/server.jl index 360a1f1..038eb5e 100644 --- a/test/server.jl +++ b/test/server.jl @@ -103,25 +103,25 @@ end @test results_array[1]["code"] == "E321" results_array = writeandreadserver(pipe_slv1, json_input1) - @test results_array[1]["text"] == "E321 something use of undeclared symbol" + @test results_array[1]["text"] == "E321 something: use of undeclared symbol" @test results_array[1]["filePath"] == "none" @test results_array[1]["range"] == Array[[0, 0], [0, 80]] @test results_array[1]["type"] == "error" results_array = writeandreadserver(pipe_slv1, json_input2) - @test results_array[1]["text"] == "W351 pi redefining mathematical constant" + @test results_array[1]["text"] == "W351 pi: redefining mathematical constant" @test results_array[1]["filePath"] == "none" @test results_array[1]["range"] == Array[[0, 0], [0, 80]] @test results_array[1]["type"] == "warning" results_array = writeandreadserver(pipe_slv1, json_input3) - @test results_array[1]["text"] == "I382 b argument declared but not used" + @test results_array[1]["text"] == "I382 b: argument declared but not used" @test results_array[1]["filePath"] == "none" @test results_array[1]["range"] == Array[[0, 0], [0, 80]] @test results_array[1]["type"] == "info" results_array = writeandreadserver(pipe_vscode, json_input1) - @test results_array[1]["message"] == "something use of undeclared symbol" + @test results_array[1]["message"] == "something: use of undeclared symbol" @test results_array[1]["filePath"] == "none" @test results_array[1]["range"] == Array[[0, 0], [0, 80]] @test results_array[1]["code"] == "E321" @@ -129,7 +129,7 @@ end @test results_array[1]["source"] == "Lint.jl" results_array = writeandreadserver(pipe_slv2, json_input1) - @test results_array[1]["description"] == "something use of undeclared symbol" + @test results_array[1]["description"] == "something: use of undeclared symbol" @test results_array[1]["location"]["file"] == "none" @test results_array[1]["location"]["position"] == Array[[0, 0], [0, 80]] @test results_array[1]["severity"] == "error"