Skip to content

Commit

Permalink
bump ruff to 0.8.1 (#11350)
Browse files Browse the repository at this point in the history
* bump ruff 0.8.1

* fix ruff

* fix unittests

* update

* update

* fix unittest
  • Loading branch information
manuel-sommer authored Dec 20, 2024
1 parent 874d493 commit 460cd7c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dojo/tools/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def requires_tool_type(scan_type):

# iterate through the modules in the current package
package_dir = str(Path(__file__).resolve().parent)
for module_name in os.listdir(package_dir):
for module_name in os.listdir(package_dir): # noqa: PTH208
# check if it's dir
if Path(os.path.join(package_dir, module_name)).is_dir():
try:
Expand Down
2 changes: 1 addition & 1 deletion requirements-lint.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruff==0.8.0
ruff==0.8.1
17 changes: 10 additions & 7 deletions tests/Import_scanner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ def setUp(self):
git.Repo.clone_from("https://github.com/DefectDojo/sample-scan-files", self.repo_path)
self.remove_items = ["__init__.py", "__init__.pyc", "factory.py", "factory.pyc",
"factory.py", "LICENSE", "README.md", ".gitignore", ".git", "__pycache__"]
tool_path = dir_path[:-5] + "dojo/tools"
tools = sorted(os.listdir(tool_path))
tests = sorted(os.listdir(self.repo_path))
tool_path = Path(dir_path[:-5] + "dojo/tools")
tools = sorted(any(tool_path.iterdir()))
p = Path(self.repo_path)
tests = sorted(any(p.iterdir()))
self.tools = [i for i in tools if i not in self.remove_items]
self.tests = [i for i in tests if i not in self.remove_items]

Expand All @@ -43,7 +44,8 @@ def test_check_test_file(self):
missing_tests += ["\nNO TEST FILES"]

for test in self.tests:
cases = sorted(os.listdir(self.repo_path + "/" + test))
p = Path(self.repo_path + "/" + test)
cases = sorted(any(p.iterdir()))
cases = [i for i in cases if i not in self.remove_items]
if len(cases) == 0 and tool not in missing_tests:
missing_tests += [test]
Expand Down Expand Up @@ -145,8 +147,8 @@ def test_engagement_import_scan_result(self):
options_text = [scan.strip() for scan in options_text]

mod_options = options_text
mod_options = [re.sub(r" Scanner", "", scan) for scan in mod_options]
mod_options = [re.sub(r" Scan", "", scan) for scan in mod_options]
mod_options = [scan.replace(" Scanner", "") for scan in mod_options]
mod_options = [scan.replace(" Scan", "") for scan in mod_options]
mod_options = [scan.lower().replace("-", " ").replace(".", "") for scan in mod_options]

acronyms = []
Expand Down Expand Up @@ -177,7 +179,8 @@ def test_engagement_import_scan_result(self):

failed_tests = []
for test in self.tests:
cases = sorted(os.listdir(self.repo_path + "/" + test))
p = Path(self.repo_path + "/" + test)
cases = sorted(any(p.iterdir()))
cases = [i for i in cases if i not in self.remove_items]
if len(cases) == 0:
failed_tests += [test.upper() + ": No test cases"]
Expand Down
4 changes: 2 additions & 2 deletions unittests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def test_get_parser_test_active_in_db(self):

def test_parser_name_matches_module(self):
"""Test to ensure that parsers' class names match their module names"""
package_dir = "dojo/tools"
module_names = os.listdir(package_dir)
package_dir = Path("dojo/tools")
module_names = package_dir.iterdir()
missing_parsers = []
excluded_parsers = [
"wizcli_common_parsers", # common class for other wizcli parsers, there is not parsing here
Expand Down

0 comments on commit 460cd7c

Please sign in to comment.