You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During sonar scanning, each analyzed python file raises a NullPointerException :
WARN: Unable to analyze file: metadata/filters.py
java.lang.NullPointerException: null
at fr.greencodeinitiative.python.checks.AvoidMultipleIfElseStatementCheck.computeElseVariables(AvoidMultipleIfElseStatementCheck.java:251)
at fr.greencodeinitiative.python.checks.AvoidMultipleIfElseStatementCheck.visitElseNode(AvoidMultipleIfElseStatementCheck.java:238)
at fr.greencodeinitiative.python.checks.AvoidMultipleIfElseStatementCheck.visitIfNode(AvoidMultipleIfElseStatementCheck.java:124)
at fr.greencodeinitiative.python.checks.AvoidMultipleIfElseStatementCheck.visitNodeContent(AvoidMultipleIfElseStatementCheck.java:91)
at fr.greencodeinitiative.python.checks.AvoidMultipleIfElseStatementCheck.visitNode(AvoidMultipleIfElseStatementCheck.java:74)
at fr.greencodeinitiative.python.checks.AvoidMultipleIfElseStatementCheck.visitFuncDef(AvoidMultipleIfElseStatementCheck.java:63)
at org.sonar.python.SubscriptionVisitor$SubscriptionContextImpl.execute(SubscriptionVisitor.java:110)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.sonar.python.SubscriptionVisitor.scan(SubscriptionVisitor.java:91)
at org.sonar.python.SubscriptionVisitor.analyze(SubscriptionVisitor.java:71)
at org.sonar.plugins.python.PythonScanner.scanFile(PythonScanner.java:139)
at org.sonar.plugins.python.Scanner.execute(Scanner.java:59)
at org.sonar.plugins.python.PythonSensor.execute(PythonSensor.java:118)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:61)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)
at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:403)
at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:399)
at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:368)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:71)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:65)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
at org.sonarsource.scanner.cli.Main.main(Main.java:62)
To Reproduce
Steps to reproduce the behavior:
# 1. run server
$ docker run -ti --rm -v sq_ecocode_logs:/opt/sonarqube/logs -v sq_ecocode_data:/opt/sonarqube/data -p 9000:9000 --name sonarqube-ecocode ghcr.io/green-code-initiative/sonarqube-ecocode:latest
# 2. go to http://localhost:9000, update admin password, create a project 'foo', then a token
token: sqp_439daaa786a5d68f243398fec2b9a54dc760cb7c
# 3. download plugin and add it to sonarqube
$ wget https://github.com/green-code-initiative/ecoCode-python/releases/download/1.4.0/ecocode-python-plugin-1.4.0.jar
$ docker cp ecocode-python-plugin-1.4.0.jar sonarqube-ecocode:/opt/sonarqube/extensions/plugins
$ docker restart sonarqube-ecocode
# 4. create a new Python Quality Profile with "eco-conception" rules, apply it on the project
# 5. run scanner
$ sudo docker run --network=host --rm -e SONAR_HOST_URL="http://localhost:9000" -e SONAR_SCANNER_OPTS="-Dsonar.projectKey=foo" -e SONAR_LOGIN="sqp_439daaa786a5d68f243398fec2b9a54dc760cb7c" -v "/foo_files:/usr/src" sonarsource/sonar-scanner-cli
Software Versions
SonarQube Version: Community Edition Version 10.1 (build 73491)
Plugin Version: ecocode-python-plugin-1.4.0.jar
The text was updated successfully, but these errors were encountered:
Hi @matthieumarrast,
thank you for your issue.
could you give us a python test file used to reproduce the bug, please ?
I've just checked locally and I have no problem.
Here is my local tests (like a developer to implement a new rule in Python repository) :
launch tool_build.sh on python repository
launch tool_docker-clean.sh to clean docker
launch tool_docker-init.sh and tool_docker-log.sh to launch local Sonarqube with logs on console
when Sonarqube is ready (see logs), go to admin / security to create a new security token
then got to ecocode-common repository, in directory, tools/rules_config and launch install_profile.sh <SECURITY_TOKEN> to initialize ecocode profiles inside local SonarQube
then go to ecocode-python-real-testproject and launch tool_send.sh <SECURITY_TOKEN> to launch sonar scanner and send metrics to local SonarQube
then got to SonarQube UI and check content of new appeared Python project
==> no problem to do all of this in my local machine with all analyzed files inside Python real test project
use case found : create a new JUNIT test in class AvoidMultipleIfElseStatementCheckTest with a verify on avoidGlobalVariableInFunction.py file
==> first execution : NullPointer
==> second execution (after NPE correction) : test crashes indicating that no issue launched but issues expected (it's ok because "non compliant" comments on this test file are for AvoidGlobalVariableInFunctionCheckTest test class and not really for test class AvoidMultipleIfElseStatementCheckTest). thus we have to create a new test case for this one.
Describe the bug
During sonar scanning, each analyzed python file raises a
NullPointerException
:To Reproduce
Steps to reproduce the behavior:
Software Versions
The text was updated successfully, but these errors were encountered: