diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2529a6b4..8dd95a36 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/README.md b/README.md index 8c574a91..588264e9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# pysonar-scanner +# pysonar A wrapper around SonarScanner CLI, available on PyPI. # Disclaimer @@ -15,12 +15,12 @@ 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 @@ -28,7 +28,7 @@ It assumes a running SonarQube server or a project configured on SonarCloud. 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 @@ -36,13 +36,13 @@ There are multiple ways of providing these properties, described below in descen ### 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__. @@ -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" ``` @@ -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. @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 25867b7a..a020b65a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] @@ -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' diff --git a/tests/its/utils/cli_client.py b/tests/its/utils/cli_client.py index 8946e5da..6a8829de 100644 --- a/tests/its/utils/cli_client.py +++ b/tests/its/utils/cli_client.py @@ -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, @@ -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, diff --git a/tests/its/utils/pysonar-scanner-debug.py b/tests/its/utils/pysonar-debug.py similarity index 75% rename from tests/its/utils/pysonar-scanner-debug.py rename to tests/its/utils/pysonar-debug.py index 8a5da7d1..3934c0aa 100644 --- a/tests/its/utils/pysonar-scanner-debug.py +++ b/tests/its/utils/pysonar-debug.py @@ -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. """