Skip to content

Commit d7b422f

Browse files
committed
Make sonar_code_path to make more explicit
1 parent dec4607 commit d7b422f

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

doc/user_guide/features/metrics/sonar.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ In Sonar
4444

4545
In the code
4646
"""""""""""
47-
#. In the ``noxconfig.py``, the relative path to the project's source code is defined with ``Config.source_code_path``.
47+
#. In the ``noxconfig.py``, the relative path to the project's source code is defined with ``Config.sonar_code_path``.
4848
#. Add the following to the project's file ``pyproject.toml``
4949
.. code-block:: toml
5050

exasol/toolbox/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ def pyupgrade_argument(self) -> tuple[str, ...]:
126126
version_number = "".join(version_parts)
127127
return (f"--py{version_number}-plus",)
128128

129+
@computed_field # type: ignore[misc]
130+
@property
131+
def sonar_code_path(self) -> Path:
132+
"""
133+
Relative path needed in nox session `sonar:check` to create the coverage XML
134+
"""
135+
return self.source_code_path.relative_to(self.root_path)
136+
129137
@computed_field # type: ignore[misc]
130138
@property
131139
def source_code_path(self) -> Path:

exasol/toolbox/nox/_artifacts.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,10 @@ def _prepare_coverage_xml(
207207
COVERAGE_XML,
208208
"--include",
209209
f"{source}/*",
210-
"--fail-under=0",
210+
"--fail-under",
211+
"0",
212+
"--data-file",
213+
".coverage",
211214
]
212215
output = subprocess.run(command, capture_output=True, text=True, cwd=cwd) # nosec
213216
if output.returncode != 0:
@@ -247,5 +250,5 @@ def _upload_to_sonar(session: Session, sonar_token: str | None, config: Config)
247250
def upload_artifacts_to_sonar(session: Session) -> None:
248251
"""Upload artifacts to sonar for analysis"""
249252
sonar_token = os.getenv("SONAR_TOKEN")
250-
_prepare_coverage_xml(session, PROJECT_CONFIG.source_code_path)
253+
_prepare_coverage_xml(session, PROJECT_CONFIG.sonar_code_path)
251254
_upload_to_sonar(session, sonar_token, PROJECT_CONFIG)

0 commit comments

Comments
 (0)