Skip to content

Commit 7b90e6a

Browse files
authored
Fix the code and code description part of diagnostic (#25)
The code attribute should actually be the bandit test id and name, not source code. Plus the code description is a link to the docs. Also bumped the version Signed-off-by: Eric Brown <[email protected]>
1 parent d60f973 commit 7b90e6a

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

bundled/tool/lsp_server.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def _parse_output(content: str) -> list[lsp.Diagnostic]:
114114

115115
for result in results:
116116
location = result["locations"][0]["physicalLocation"]
117+
rule = run["tool"]["driver"]["rules"][result["ruleIndex"]]
117118

118119
start = lsp.Position(
119120
line=location["region"]["startLine"] - line_offset,
@@ -133,8 +134,11 @@ def _parse_output(content: str) -> list[lsp.Diagnostic]:
133134
result["properties"]["issue_severity"],
134135
result["properties"]["issue_confidence"],
135136
),
136-
code=location["region"]["snippet"]["text"],
137-
source=TOOL_MODULE,
137+
code=f"{result["ruleId"]}:{rule["name"]}",
138+
code_description=lsp.CodeDescription(
139+
href=rule["helpUri"],
140+
),
141+
source=TOOL_DISPLAY,
138142
)
139143
diagnostics.append(diagnostic)
140144

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "bandit-pycqa",
33
"displayName": "Bandit by PyCQA",
44
"description": "The official Bandit extension developed by PyCQA",
5-
"version": "2025.3.1",
5+
"version": "2025.3.2",
66
"preview": true,
77
"serverInfo": {
88
"name": "Bandit",

src/test/python_tests/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#
55
# pip-compile --generate-hashes ./src/test/python_tests/requirements.in
66
#
7-
iniconfig==2.0.0 \
8-
--hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \
9-
--hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374
7+
iniconfig==2.1.0 \
8+
--hash=sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7 \
9+
--hash=sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760
1010
# via pytest
1111
packaging==24.2 \
1212
--hash=sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759 \

0 commit comments

Comments
 (0)