2

I have a ReactJS Javascript project workspace in Windows 10 OS for which I wanted to use SonarScanner to run code analysis. I have setup and verified that SonarScanner is running correctly. I also set the "sonar.host.url" in SonarScanner/conf/sonar-scanner.properties file. I can see the results of the scan everytime I run.

I then added the "sonar-project.properties" file in my workspace. These are the settings in the "sonar-project.properties" file:

sonar-project.properties
# must be unique in a given SonarQube instance
sonar.projectKey=Project1

# --- optional properties ---

# defaults to project key
sonar.projectName=React Webapp
# defaults to 'not provided'
#sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Defaults to .
sonar.projectBaseDir=C:/code/model-group-webapp
sonar.sources=src

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

I then ran the sonar-scanner command like this "$sonar-scanner -X".

I can see in the logs that the Javascript files are read, but the files are indexed with language "null".

13:56:46.764 INFO: Source paths: src
13:56:46.765 INFO: Source encoding: windows-1252, default locale: en_US
13:56:46.768 INFO: Index files
13:56:46.794 DEBUG: 'src/App.js' indexed with language 'null'
13:56:46.796 DEBUG: 'src/App.test.js' indexed with language 'null'
13:56:46.796 DEBUG: 'src/config/config.js' indexed with language 'null'
13:56:46.798 DEBUG: 'src/EditPanel.js' indexed with language 'null'
13:56:46.800 DEBUG: 'src/Filter.js' indexed with language 'null'
13:56:46.800 DEBUG: 'src/index.css' indexed with language 'null'
13:56:46.805 DEBUG: 'src/index.js' indexed with language 'null'
13:56:46.805 DEBUG: 'src/logo.svg' indexed with language 'null'
13:56:46.810 DEBUG: 'src/serviceWorker.js' indexed with language 'null'

I also noticed that Javascript was not in the available languages in the logs. It only showed Java:

14:29:42.889 INFO: Load project repositories (done) | time=125ms
14:29:42.990 DEBUG: Available languages:
14:29:42.993 DEBUG:   * Java => "java"

In the Sonarqube server, the project shows 0 errors and vulnerabilities, with no source code. enter image description here

What is the missing configuration here?

Shankar
  • 2,625
  • 3
  • 25
  • 49

1 Answers1

0

If you are running from jenkins, add the srs path of your code files,

sonar.language=js (optional)
sonar.sources=./src/main/TestApp 
Simas Joneliunas
  • 2,890
  • 20
  • 28
  • 35
Geeky_Mr.V
  • 19
  • 3