Skip to content

Commit f6b4a44

Browse files
committed
fix(BenchmarkJava): check if file exist to avoid error
1 parent 266848d commit f6b4a44

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

codesectools/datasets/BenchmarkJava/dataset.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,17 @@ def load_dataset(self) -> list[TestCode]:
148148
for row in reader:
149149
filename = f"{row[0]}.java"
150150
filepath = testcode_dir / filename
151-
content = filepath.read_text()
152-
cwes = [CWEs.from_id(int(row[3]))]
153-
has_vuln = True if row[2] == "true" else False
154-
files.append(
155-
TestCode(
156-
filepath.relative_to(self.directory),
157-
content,
158-
cwes,
159-
has_vuln,
151+
if filepath.is_file():
152+
content = filepath.read_text()
153+
cwes = [CWEs.from_id(int(row[3]))]
154+
has_vuln = True if row[2] == "true" else False
155+
files.append(
156+
TestCode(
157+
filepath.relative_to(self.directory),
158+
content,
159+
cwes,
160+
has_vuln,
161+
)
160162
)
161-
)
162163

163164
return files

0 commit comments

Comments
 (0)