Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problem indexing #72

Merged
merged 5 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/code-util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,9 @@ function extract_problems(results)
return problems
end

indices = results[REL_CODE_KEY][1]
# Every diagnostic must have a code, and is indexed from 1 to length, so we use that
# for a key.
for i in indices
# Diagnostic categories have identical ordering so we can use row to find matches
# across categories, starting with row 1
for i in 1:length(results[REL_CODE_KEY][1])
code = extract_detail(results, REL_CODE_KEY, 2, i)
# index, subindex, line
line = extract_detail(results, REL_LINE_KEY, 3, i)
Expand Down
4 changes: 2 additions & 2 deletions test/expect_problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ end
# Test matching on code, code + line, code + line + severity
test_results = generate_arrow([
(
:index => 1,
:index => 2,
:code => "UNDEFINED",
:severity => "error",
:line => 2,
:message => "message",
),
(
:index => 2,
:index => 3,
:code => "UNBOUND_VARIABLE",
:severity => "error",
:line => 3,
Expand Down
13 changes: 13 additions & 0 deletions test/integration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@
allow_unexpected = :none,
)

@test_rel(
name = "Expected problems, allow none",
query = """
// Line 1
def output = a
def output = b
""",
expected_problems = [
(:code => :UNDEFINED, :line => 2),
(:code => :UNDEFINED, :line => 3)],
allow_unexpected = :none,
)

@test_rel(
name = "Unexpected problem, ignore all",
query = """
Expand Down