Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The the following keys should be present:

To debug the sonar-scanner being run in the its, the ITs have to be run with `poetry run pytest tests/its --its --debug-its`

The `pysonar-scanner` process will wait until VSCode or any other debug adapter protocol client connects on the port `5678`.
The `pysonar` process will wait until VSCode or any other debug adapter protocol client connects on the port `5678`.

For VSCode, add the following launch configuration in the `configurations` array:
```json
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pysonar-scanner
# pysonar
A wrapper around SonarScanner CLI, available on PyPI.

# Disclaimer
Expand All @@ -15,34 +15,34 @@ These changes include configuration parameter names.

Install with pip:
```
pip install pysonar-scanner
pip install pysonar
```

# Usage

Once installed, the `pysonar-scanner` can be run from the command line to perform an analysis.
Once installed, the `pysonar` scanner can be run from the command line to perform an analysis.
It assumes a running SonarQube server or a project configured on SonarCloud.

## Setting up analysis properties

In order for the analysis to run, analysis properties need to be defined.
There are multiple ways of providing these properties, described below in descending order of priority:

* Through CLI arguments to the `pysonar-scanner` command
* Through CLI arguments to the `pysonar` command
* Under the `[tool.sonar]` key of the `pyproject.toml` file
* Through common properties extracted from the `pyproject.toml`
* In a dedicated `sonar-project.properties` file
* Through environment variables

### Through CLI arguments

Analysis properties can be provided as CLI arguments to the `pysonar-scanner` command.
Analysis properties can be provided as CLI arguments to the `pysonar` command.
They follow the same convention as when running the SonarScanner CLI directly
(see [documentation](https://docs.sonarsource.com/sonarqube/9.9/analyzing-source-code/scanners/sonarscanner/#running-from-zip-file)).
This means that analysis properties provided that way should be prepended with `-D`, for instance:

```
$ pysonar-scanner -Dsonar.login=myAuthenticationToken
$ pysonar -Dsonar.login=myAuthenticationToken
```

You can use all the argument allowed by __SonarScanner__.
Expand Down Expand Up @@ -79,13 +79,13 @@ By default, the scanner will expect the `pyproject.toml` file to be present in t
However, its path can be provided manually through the `toml.path` ([SCANPY-40](https://sonarsource.atlassian.net/jira/software/c/projects/PYSCAN/issues/PYSCAN-40)) CLI argument as well as through the `sonar.projectHome` argument. For instance:

```
pysonar-scanner -Dtoml.path="path/to/pyproject.toml"
pysonar --toml.path "path/to/pyproject.toml"
```

Or:

```
pysonar-scanner -Dsonar.projectHome="path/to/projectHome"
pysonar --sonar-project-home "path/to/projectHome"
```


Expand Down Expand Up @@ -127,7 +127,7 @@ It is also possible to define configure the scanner through environment variable

```
$ export SONAR_HOST_URL="http://localhost:9000"
$ pysonar-scanner
$ pysonar
```

See the __SonarScanner__ [documentation](https://docs.sonarsource.com/sonarqube/9.9/analyzing-source-code/scanners/sonarscanner/) for more information.
Expand All @@ -137,7 +137,7 @@ See the __SonarScanner__ [documentation](https://docs.sonarsource.com/sonarqube/
To install the latest pre-released version of Sonar Scanner Python. Execute the following command:

```shell
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ pysonar-scanner
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ pysonar
```

# License
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ classifiers = ['Environment :: Console', 'Intended Audience :: Developers', 'Ope
description = 'Sonar Scanner for the Python Ecosystem'
keywords = ['sonar', 'sonarqube', 'sonarcloud', 'cleancode']
license = 'LGPL-3.0-only'
name = 'pysonar-scanner'
name = 'pysonar'
readme = 'README.md'
version = "1.0.0"
dynamic = ["dependencies"]
Expand Down Expand Up @@ -53,7 +53,7 @@ from = 'src'
include = 'pysonar_scanner'

[tool.poetry.scripts]
pysonar-scanner = 'pysonar_scanner.__main__:scan'
pysonar = 'pysonar_scanner.__main__:scan'

[[tool.poetry.source]]
name = 'jfrog-server'
Expand Down
4 changes: 2 additions & 2 deletions tests/its/utils/cli_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __run_analysis_with_debugging(self, workdir: pathlib.Path, params: list[str]
"--listen",
str(DEBUGPY_PORT),
"-m",
"tests.its.utils.pysonar-scanner-debug",
"tests.its.utils.pysonar-debug",
f"--sonar-host-url={self.sq_client.base_url}",
f"--token={token}",
*params,
Expand All @@ -81,7 +81,7 @@ def __run_analysis_with_debugging(self, workdir: pathlib.Path, params: list[str]

def __run_analysis_normal(self, workdir: pathlib.Path, params: list[str], token: str) -> CompletedProcess:
command = [
"pysonar-scanner",
"pysonar",
f"--sonar-host-url={self.sq_client.base_url}",
f"--token={token}",
*params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
"""
This module is the entry point for debugging the pysonar-scanner in the its.
The pysonar-scanner-debug is started with the working directory set to the root of the project, so that python
(and pydebug by extension) can find the pysonar-scanner-debug module. However, since the scanner should run in the
This module is the entry point for debugging the pysonar scanner in the its.
The pysonar-debug is started with the working directory set to the root of the project, so that python
(and pydebug by extension) can find the pysonar-debug module. However, since the scanner should run in the
analyzed project, the working directory is changed to the root of the analyzed project before running the scanner.

The pysonar-scanner-debug expects the PYSONAR_SCANNER_DEBUG_WORKDIR environment variable to be set to the directory
The pysonar-debug expects the PYSONAR_SCANNER_DEBUG_WORKDIR environment variable to be set to the directory
where the scanner should be run. This is set to the directory containing the sources to be analyzed.
"""

Expand Down