Skip to content

Commit

Permalink
Adding the feature to turn off the codes and some fine tuning of the …
Browse files Browse the repository at this point in the history
…message text
  • Loading branch information
TeroFrondelius committed Feb 22, 2017
1 parent 39c50f5 commit a81d069
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
21 changes: 15 additions & 6 deletions src/Lint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -397,7 +406,7 @@ function convertmsgtojson(msgs, style)
"location" => Dict("file" => file,
"position" => errorrange),
"excerpt" => code,
"description" => "$evar $txt"))
"description" => "$evar: $txt"))

end
end
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test/server.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,33 +103,33 @@ 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"
@test results_array[1]["severity"] == 1
@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"
Expand Down

0 comments on commit a81d069

Please sign in to comment.