Skip to content

Commit 3cfdea6

Browse files
committed
fix: remove unnecessary f-string prefix in vulnrichment.py
Signed-off-by: samay2504 <samay.m2504@gmail.com>
1 parent 32d9724 commit 3cfdea6

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

vulnerabilities/importers/vulnrichment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def advisory_data(self) -> Iterable[AdvisoryData]:
2929
try:
3030
vcs_response = self.clone(repo_url=self.repo_url)
3131
base_path = Path(vcs_response.dest_dir)
32-
for file_path in base_path.glob(f"**/**/*.json"):
32+
for file_path in base_path.glob("**/**/*.json"):
3333
if not file_path.name.startswith("CVE-"):
3434
continue
3535

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# VulnerableCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/aboutcode-org/vulnerablecode for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
8+
#
9+
10+
import ast
11+
import os
12+
13+
14+
def test_no_fstring_without_placeholders_in_vulnrichment():
15+
"""Test that vulnrichment.py does not contain f-strings without placeholders."""
16+
file_path = os.path.join(os.path.dirname(__file__), "..", "importers", "vulnrichment.py")
17+
with open(file_path, "r") as f:
18+
source = f.read()
19+
20+
tree = ast.parse(source)
21+
22+
empty_fstrings = []
23+
for node in ast.walk(tree):
24+
if isinstance(node, ast.JoinedStr):
25+
if all(isinstance(v, ast.Constant) for v in node.values):
26+
empty_fstrings.append(node.lineno)
27+
28+
assert (
29+
len(empty_fstrings) == 0
30+
), f"Found f-strings without placeholders at lines: {empty_fstrings}"

0 commit comments

Comments
 (0)