Skip to content

Commit a666ede

Browse files
authored
Documentation/589 fix sonar documentation (#594)
* Corrected configuration for Sonar documentation for host.url * Add new line after header at the top of the versionsed changelog * Add reference to Sonar's analysis parameter page * Add more information about exclusions * Add and correct information on pyupgrade usage * Reduce duplicate information by creating a General remarks section
1 parent 2c35dad commit a666ede

File tree

7 files changed

+54
-10
lines changed

7 files changed

+54
-10
lines changed

doc/changes/unreleased.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
11
# Unreleased
2+
3+
## Documentation
4+
5+
* #589: Corrected configuration for Sonar documentation for host.url
6+
* #535: Added more information about Sonar's usage of ``exclusions``
7+
* #596: Corrected and added more information regarding ``pyupgrade``
8+
9+
## Refactoring
10+
11+
* #596: Added newline after header in versioned changelog

doc/user_guide/features/formatting_code/index.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ deterministic manner.
4444

4545
Configuration
4646
+++++++++++++
47+
4748
black
4849
^^^^^
4950

@@ -59,6 +60,7 @@ For further configuration options, see
5960

6061
isort
6162
^^^^^
63+
6264
Ensure ``isort`` is configured with compatibility for ``black``:
6365

6466
.. literalinclude:: ../../../../project-template/{{cookiecutter.repo_name}}/pyproject.toml
@@ -72,9 +74,10 @@ For further configuration options, see
7274

7375
pyupgrade
7476
^^^^^^^^^
75-
No initial configuration of ``pyupgrade`` is required.
7677

77-
For individual configuration, see the
78-
`pyupgrade CLI options <https://pypi.org/project/pyupgrade/>`__. These can
79-
be passed to the :ref:`formatting_sessions` via the ``pyupgrade_args``
80-
attribute of the :class:`noxconfig.Config`.
78+
No initial configuration of ``pyupgrade`` is required. By default, this is
79+
configured to be derived from the minimum Python version that your project supports
80+
and is defined in the :meth:`exasol.toolbox.config.BaseConfig.pyupgrade_argument`.
81+
82+
For further configuration options, see the
83+
`pyupgrade documentation <https://pypi.org/project/pyupgrade/>`__.

doc/user_guide/features/metrics/sonar.rst

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,14 @@ In the code
5353
5454
[tool.sonar]
5555
projectKey = "<sonar-project-key>"
56-
hostUrl = "https://sonarcloud.io"
56+
host.url = "https://sonarcloud.io"
5757
organization = "exasol"
5858
exclusions = "<source-directory>/version.py,<source_directory>/<directory-to-ignore>/*"
5959
60+
.. note::
61+
For more information, see the :ref:`General remarks <configuration_general_remarks>` section.
62+
63+
6064
.. _configure_sonar_private_project:
6165

6266
**Private** GitHub repository
@@ -98,8 +102,33 @@ In the code
98102
99103
[tool.sonar]
100104
projectKey = "com.exasol:<project-key>"
101-
hostUrl = "https://sonar.exasol.com"
105+
host.url = "https://sonar.exasol.com"
102106
organization = "exasol"
103107
exclusions = "<source-directory>/version.py,<source_directory>/<directory-to-ignore>/*"
104108
109+
.. note::
110+
For more information, see the :ref:`General remarks <configuration_general_remarks>` section.
111+
105112
.. _Exasol Way: https://sonarcloud.io/organizations/exasol/quality_gates/show/AXxvLH-3BdtLlpiYmZhh
113+
.. _Sonar Matching Patterns: https://docs.sonarsource.com/sonarqube-server/project-administration/setting-analysis-scope/defining-matching-patterns
114+
115+
.. _configuration_general_remarks:
116+
117+
General remarks
118+
^^^^^^^^^^^^^^^^^^^
119+
For additional configuration information, see `Sonar's analysis parameters <https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/analysis-parameters>`__ page.
120+
121+
``exclusions``
122+
""""""""""""""
123+
With the value of ``exclusions``, you can exclude files and directories of your
124+
project from Sonar's analysis:
125+
126+
* You can use wildcards, e.g. ``<root>/dir/*.py`` or ``<root>/**/*.py``
127+
* Multiple exclusions can be comma-separated (as shown above).
128+
* For excluding arbitrary directories and files below a specific directory, please use two asterisks, e.g. ``root/abc/**``.
129+
130+
See the `Sonar Matching Patterns`_ for more details.
131+
132+
By default, the nox session ``sonar:check`` only analyses the source code,
133+
as specified by the ``PROJECT_CONFIG.source``, so directories outside of this
134+
are already excluded from being analyzed.

exasol/toolbox/util/release/changelog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def _create_versioned_changelog(self, unreleased_content: str) -> None:
5050
if dependency_changes := self._describe_dependency_changes():
5151
dependency_content = f"## Dependency Updates\n{dependency_changes}"
5252

53-
template = cleandoc(f"{header}\n{unreleased_content}\n{dependency_content}")
53+
template = cleandoc(f"{header}\n\n{unreleased_content}\n{dependency_content}")
5454
self.versioned_changelog_md.write_text(template + "\n")
5555

5656
def _extract_unreleased_notes(self) -> str:

project-template/{{cookiecutter.repo_name}}/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ ignore_errors = true
6565

6666
[tool.sonar]
6767
projectKey = "com.exasol:{{cookiecutter.repo_name}}"
68-
hostUrl = "https://sonarcloud.io"
68+
host.url = "https://sonarcloud.io"
6969
organization = "exasol"
7070
exclusions = "exasol/{{cookiecutter.package_name}}/version.py"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@ poetry-plugin-export = ">=1.8"
120120

121121
[tool.sonar]
122122
projectKey = "com.exasol:python-toolbox"
123-
hostUrl = "https://sonarcloud.io"
123+
host.url = "https://sonarcloud.io"
124124
organization = "exasol"
125125
exclusions = "exasol/toolbox/version.py"

test/unit/util/release/changelog_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def test_update_changelogs_for_release(
181181
saved_text
182182
== cleandoc(
183183
f"""# 1.0.0 - {datetime.today().strftime('%Y-%m-%d')}
184+
184185
## Added
185186
* Added Awesome feature
186187
@@ -218,6 +219,7 @@ def test_update_changelogs_for_release_with_no_dependencies(
218219
saved_text
219220
== cleandoc(
220221
f"""# 1.0.0 - {datetime.today().strftime('%Y-%m-%d')}
222+
221223
## Added
222224
* Added Awesome feature
223225

0 commit comments

Comments
 (0)