Skip to content

Commit 9503ebb

Browse files
committed
Enable refurb validation in ruff
Signed-off-by: tdruez <[email protected]>
1 parent 33cd112 commit 9503ebb

File tree

6 files changed

+7
-11
lines changed

6 files changed

+7
-11
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ select = [
168168
"S", # flake8-bandit
169169
"I", # isort
170170
"C9", # McCabe complexity
171-
"FIX",# flake8-fixme
171+
"FIX", # flake8-fix
172+
"FURB", # refurb
172173
]
173174
ignore = ["D1", "D203", "D205", "D212", "D400", "D415"]
174175

scanpipe/models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,8 +1184,7 @@ def write_input_file(self, file_object):
11841184
file_path = Path(self.input_path / filename)
11851185

11861186
with open(file_path, "wb+") as f:
1187-
for chunk in file_object.chunks():
1188-
f.write(chunk)
1187+
f.writelines(file_object.chunks())
11891188

11901189
def copy_input_from(self, input_location):
11911190
"""

scanpipe/pipes/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ def _clean_package_data(package_data):
166166
package_data = package_data.copy()
167167
if release_date := package_data.get("release_date"):
168168
if type(release_date) is str:
169-
if release_date.endswith("Z"):
170-
release_date = release_date[:-1]
169+
release_date = release_date.removesuffix("Z")
171170
package_data["release_date"] = datetime.fromisoformat(release_date).date()
172171

173172
# Strip leading "codebase/" to make path compatible with

scanpipe/pipes/federatedcode.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ def add_scan_result(project, repo, package_scan_file, logger=None):
156156
write_to.parent.mkdir(parents=True, exist_ok=True)
157157
results_generator = JSONResultsGenerator(project)
158158
with open(write_to, encoding="utf-8", mode="w") as file:
159-
for chunk in results_generator:
160-
file.write(chunk)
159+
file.writelines(results_generator)
161160

162161
return relative_scan_file_path
163162

scanpipe/pipes/js.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def is_source_mapping_in_minified(resource, map_file_name):
6969
lines = resource.file_content.split("\n")
7070
total_lines = len(lines)
7171
# Get the last 5 lines.
72-
tail = 5 if total_lines > 5 else total_lines
72+
tail = min(total_lines, 5)
7373
return any(source_mapping in line for line in reversed(lines[-tail:]))
7474

7575

scanpipe/pipes/spdx.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,7 @@ def date_to_iso(date_str):
380380
if not date_str:
381381
return
382382

383-
if date_str.endswith("Z"):
384-
date_str = date_str[:-1]
385-
383+
date_str = date_str.removesuffix("Z")
386384
as_datetime = datetime.fromisoformat(date_str)
387385
return as_datetime.isoformat(timespec="seconds") + "Z"
388386

0 commit comments

Comments
 (0)