Skip to content

Commit

Permalink
Update sonar-scanner version and test accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
Topin2001 committed Jun 17, 2024
1 parent b85bf3f commit d763052
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ RUN apt update \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

# sonar-scanner
RUN curl -ksSLO https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006.zip \
&& unzip sonar-scanner-cli-5.0.1.3006.zip \
&& mv ./sonar-scanner-5.0.1.3006 /sonar-scanner \
&& rm sonar-scanner-cli-5.0.1.3006.zip
RUN curl -ksSLO https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.0.0.4432.zip \
&& unzip sonar-scanner-cli-6.0.0.4432.zip \
&& mv ./sonar-scanner-6.0.0.4432 /sonar-scanner \
&& rm sonar-scanner-cli-6.0.0.4432.zip

# CppCheck
RUN curl -ksSLO https://github.com/danmar/cppcheck/archive/refs/tags/2.14.0.tar.gz \
Expand Down
40 changes: 20 additions & 20 deletions tests/test_cnes_sonar_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,18 @@ def language(cls, language_name: str, language_key: str, folder: str,
:param language_name: language name to display
:param language_key: language key for SonarQube
:param folder: folder name, relative to the tests/ folder
:param sensors_info: array of lines of sensors to look for in the scanner output
:param sensors_INFO array of lines of sensors to look for in the scanner output
:param project_key: project key (sonar.project_key of sonar-project.properties)
:param nb_issues: number of issues with the Sonar way Quality Profile
:param cnes_qp: (optional) name of the CNES Quality Profile to apply, if any
:param nb_issues_cnes_qp: (optional) number of issues with the CNES Quality Profile, if specified
Example (not a doctest):
sensors = (
"INFO: Sensor CheckstyleSensor [checkstyle]",
"INFO: Sensor FindBugs Sensor [findbugs]",
"INFO: Sensor PmdSensor [pmd]",
"INFO: Sensor CoberturaSensor [cobertura]"
"INFO Sensor CheckstyleSensor [checkstyle]",
"INFO Sensor FindBugs Sensor [findbugs]",
"INFO Sensor PmdSensor [pmd]",
"INFO Sensor CoberturaSensor [cobertura]"
)
self.language("Java", "java", "java", sensors, "java-dummy-project", 3, "CNES_JAVA_A", 6)
"""
Expand Down Expand Up @@ -202,7 +202,7 @@ def get_number_of_issues():
# Make sure all non-default for this language plugins were executed by the scanner
for sensor_line in sensors_info:
# Hint: if this test fails, a plugin may not be installed correctly or a sensor is not triggered when needed
assert sensor_line in output
assert any(sensor_line in line for line in output.split('\n'))
# Wait for SonarQube to process the results
time.sleep(8)
# Check that the project was added to the server
Expand Down Expand Up @@ -293,8 +293,8 @@ def import_analysis_results(cls, project_name: str, project_key: str,
Example (not a doctest):
rule_violated = "cppcheck:arrayIndexOutOfBounds"
expected_sensor = "INFO: Sensor C++ (Community) CppCheckSensor [cxx]"
expected_import = "INFO: CXX-CPPCHECK processed = 1"
expected_sensor = "INFO Sensor C++ (Community) CppCheckSensor [cxx]"
expected_import = "INFO CXX-CPPCHECK processed = 1"
self.import_analysis_results("CppCheck Dummy Project", "cppcheck-dummy-project",
"CNES_C_A", "c++", "tests/c_cpp", "cppcheck", rule_violated, expected_sensor, expected_import)
"""
Expand Down Expand Up @@ -370,7 +370,7 @@ def test_language_c_cpp(self):
so that I can see its level of quality on the SonarQube server.
"""
sensors = (
"INFO: Sensor CXX [cxx]",
"INFO Sensor CXX [cxx]",
)
self.language("C/C++", "cxx", "c_cpp", sensors, "c-dummy-project", 0, "RNC C A", 0)
# 0 issue are expected with the Sonar way Quality Profile for
Expand All @@ -382,7 +382,7 @@ def test_language_fortran_77(self):
so that I can see its level of quality on the SonarQube server.
"""
sensors = (
"INFO: Sensor Sonar i-Code [icode]",
"INFO Sensor Sonar i-Code [icode]",
)
self.language("Fortran 77", "f77", "fortran77", sensors, "fortran77-dummy-project", 11)

Expand All @@ -392,7 +392,7 @@ def test_language_fortran_90(self):
so that I can see its level of quality on the SonarQube server.
"""
sensors = (
"INFO: Sensor Sonar i-Code [icode]",
"INFO Sensor Sonar i-Code [icode]",
)
self.language("Fortran 90", "f90", "fortran90", sensors, "fortran90-dummy-project", 14)

Expand All @@ -402,10 +402,10 @@ def test_language_java(self):
so that I can see its level of quality on the SonarQube server.
"""
sensors = (
"INFO: Sensor CheckstyleSensor [checkstyle]",
"INFO: Sensor FindBugs Sensor [findbugs]",
"INFO: Sensor PmdSensor [pmd]",
"INFO: Sensor CoberturaSensor [cobertura]"
"INFO Sensor CheckstyleSensor [checkstyle]",
"INFO Sensor FindBugs Sensor [findbugs]",
"INFO Sensor PmdSensor [pmd]",
"INFO Sensor CoberturaSensor [cobertura]"
)
self.language("Java", "java", "java", sensors, "java-dummy-project", 3, "RNC A", 6)

Expand All @@ -422,7 +422,7 @@ def test_language_shell(self):
so that I can see its level of quality on the SonarQube server.
"""
sensors = (
"INFO: Sensor ShellCheck Sensor [shellcheck]",
"INFO Sensor ShellCheck Sensor [shellcheck]",
)
self.language("Shell", "shell", "shell", sensors, "shell-dummy-project", 60, "RNC SHELL", 19)

Expand Down Expand Up @@ -460,8 +460,8 @@ def test_import_cppcheck_results(self):
of a CppCheck analysis to SonarQube.
"""
rule_violated = "cppcheck:arrayIndexOutOfBounds"
expected_sensor = "INFO: Sensor CXX [cxx]"
expected_import = "INFO: Sensor CXX Cppcheck report import"
expected_sensor = "INFO Sensor CXX [cxx]"
expected_import = "INFO Sensor CXX Cppcheck report import"
self.import_analysis_results("CppCheck Dummy Project", "cppcheck-dummy-project",
"RNC CPP A", "cxx", "tests/c_cpp", "cppcheck", rule_violated, expected_sensor, expected_import)

Expand All @@ -471,7 +471,7 @@ def test_import_pylint_results(self):
of a pylint analysis to SonarQube.
"""
rule_violated = "external_pylint:C0326"
expected_sensor = "INFO: Sensor Python Sensor [python]"
expected_import = "INFO: Sensor Import of Pylint issues [python]"
expected_sensor = "INFO Sensor Python Sensor [python]"
expected_import = "INFO Sensor Import of Pylint issues [python]"
self.import_analysis_results("Pylint Dummy Project", "pylint-dummy-project",
"Sonar way", "py", "tests/python", "src", rule_violated, expected_sensor, expected_import)

0 comments on commit d763052

Please sign in to comment.