Skip to content

Commit b173835

Browse files
committed
add pyton-report related properties to cli
1 parent 887ee96 commit b173835

3 files changed

Lines changed: 68 additions & 0 deletions

File tree

src/pysonar_scanner/configuration/cli.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,30 @@ def __parse_cli_args(cls) -> tuple[argparse.Namespace, list[str]]:
451451
type=bool,
452452
help="Equivalent to -Dsonar.python.xunit.skipDetails",
453453
)
454+
parser.add_argument(
455+
"--sonar-python-mypy-report-paths",
456+
"-Dsonar.python.mypy.reportPaths",
457+
type=str,
458+
help="Comma-separated mypy report paths, relative to project's root",
459+
)
460+
parser.add_argument(
461+
"--sonar-python-bandit-report-paths",
462+
"-Dsonar.python.bandit.reportPaths",
463+
type=str,
464+
help="Comma-separated bandit report paths, relative to project's root",
465+
)
466+
parser.add_argument(
467+
"--sonar-python-flake8-report-paths",
468+
"-Dsonar.python.flake8.reportPaths",
469+
type=str,
470+
help="Comma-separated flake8 report paths, relative to project's root",
471+
)
472+
parser.add_argument(
473+
"--sonar-python-ruff-report-paths",
474+
"-Dsonar.python.ruff.reportPaths",
475+
type=str,
476+
help="Comma-separated ruff report paths, relative to project's root",
477+
)
454478
parser.add_argument(
455479
"--sonar-modules", "-Dsonar.modules", type=str, help="Comma-delimited list of modules to analyze"
456480
)

src/pysonar_scanner/configuration/properties.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@
9393
SONAR_MODULES: Key = "sonar.modules"
9494
SONAR_PYTHON_XUNIT_REPORT_PATH = "sonar.python.xunit.reportPath"
9595
SONAR_PYTHON_XUNIT_SKIP_DETAILS = "sonar.python.xunit.skipDetails"
96+
SONAR_PYTHON_MYPY_REPORT_PATHS = "sonar.python.mypy.reportPaths"
97+
SONAR_PYTHON_BANDIT_REPORT_PATHS = "sonar.python.bandit.reportPaths"
98+
SONAR_PYTHON_FLAKE8_REPORT_PATHS = "sonar.python.flake8.reportPaths"
99+
SONAR_PYTHON_RUFF_REPORT_PATHS = "sonar.python.ruff.reportPaths"
96100
TOML_PATH: Key = "toml-path"
97101

98102

@@ -484,6 +488,26 @@ def env_variable_name(self) -> str:
484488
default_value=None,
485489
cli_getter=lambda args: args.sonar_python_xunit_skip_details or getattr(args, "Dsonar.python.xunit.skipDetails")
486490
),
491+
Property(
492+
name=SONAR_PYTHON_MYPY_REPORT_PATHS,
493+
default_value=None,
494+
cli_getter=lambda args: args.sonar_python_mypy_report_paths
495+
),
496+
Property(
497+
name=SONAR_PYTHON_BANDIT_REPORT_PATHS,
498+
default_value=None,
499+
cli_getter=lambda args: args.sonar_python_bandit_report_paths
500+
),
501+
Property(
502+
name=SONAR_PYTHON_FLAKE8_REPORT_PATHS,
503+
default_value=None,
504+
cli_getter=lambda args: args.sonar_python_flake8_report_paths
505+
),
506+
Property(
507+
name=SONAR_PYTHON_RUFF_REPORT_PATHS,
508+
default_value=None,
509+
cli_getter=lambda args: args.sonar_python_ruff_report_paths
510+
),
487511
Property(
488512
name=SONAR_MODULES,
489513
default_value=None,

tests/unit/test_configuration_cli.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
from pysonar_scanner.configuration.configuration_loader import CliConfigurationLoader
2626
from pysonar_scanner.configuration.properties import (
2727
SONAR_HOST_URL,
28+
SONAR_PYTHON_BANDIT_REPORT_PATHS,
29+
SONAR_PYTHON_FLAKE8_REPORT_PATHS,
30+
SONAR_PYTHON_MYPY_REPORT_PATHS,
31+
SONAR_PYTHON_RUFF_REPORT_PATHS,
2832
SONAR_REGION,
2933
SONAR_SCANNER_API_BASE_URL,
3034
SONAR_SCANNER_ARCH,
@@ -151,6 +155,10 @@
151155
SONAR_PYTHON_SKIP_UNCHANGED: True,
152156
SONAR_PYTHON_XUNIT_REPORT_PATH: "path/to/xunit/report",
153157
SONAR_PYTHON_XUNIT_SKIP_DETAILS: True,
158+
SONAR_PYTHON_MYPY_REPORT_PATHS: "path/to/mypy/reports",
159+
SONAR_PYTHON_BANDIT_REPORT_PATHS: "path/to/bandit/reports",
160+
SONAR_PYTHON_FLAKE8_REPORT_PATHS: "path/to/flake8/reports",
161+
SONAR_PYTHON_RUFF_REPORT_PATHS: "path/to/ruff/reports",
154162
SONAR_MODULES: "module1,module2",
155163
}
156164

@@ -328,6 +336,14 @@ def test_impossible_os_choice(self):
328336
"--sonar-python-xunit-report-path",
329337
"path/to/xunit/report",
330338
"--sonar-python-xunit-skip-details",
339+
"--sonar-python-mypy-report-paths",
340+
"path/to/mypy/reports",
341+
"--sonar-python-bandit-report-paths",
342+
"path/to/bandit/reports",
343+
"--sonar-python-flake8-report-paths",
344+
"path/to/flake8/reports",
345+
"--sonar-python-ruff-report-paths",
346+
"path/to/ruff/reports",
331347
"--sonar-modules",
332348
"module1,module2",
333349
],
@@ -401,6 +417,10 @@ def test_all_cli_args(self):
401417
"-Dsonar.python.skipUnchanged=true",
402418
"-Dsonar.python.xunit.reportPath=path/to/xunit/report",
403419
"-Dsonar.python.xunit.skipDetails=true",
420+
"-Dsonar.python.mypy.reportPaths=path/to/mypy/reports",
421+
"-Dsonar.python.bandit.reportPaths=path/to/bandit/reports",
422+
"-Dsonar.python.flake8.reportPaths=path/to/flake8/reports",
423+
"-Dsonar.python.ruff.reportPaths=path/to/ruff/reports",
404424
"-Dsonar.modules=module1,module2",
405425
],
406426
)

0 commit comments

Comments
 (0)