lcov import can't coverage files "could not resolve <n> file paths in <path>"

2,365 views
Skip to first unread message

Michael N.

unread,
Jan 16, 2017, 11:06:04 AM1/16/17
to SonarQube
Whenever I try to import the lcov.info that has been successfully generated by gulp-jest, the paths in the lcov-file can't be resolved.

I use gulp-sonar to import them into sonarqube.

The versions I have are:
  • sonarqube: 6.2
  • mySQL: 5.6.34
  • JS Plugin: 2.19.0.3866
  • Java Version: 1.8.0_111
  • gulp-sonar: 3.0.0
  • gulp-jest: 0.6.3
  • gulp-istanbul: 1.1.1

Here is the according snippet from the logs:

[16:54:27] 16:54:27.983 INFO: 7 source files to be analyzed

[16:54:28] 16:54:28.270 INFO: 7/7 source files have been analyzed

[16:54:28] 16:54:28.270 INFO: Test Coverage Sensor is started

[16:54:28] 16:54:28.271 INFO: Analysing [<myHome>/IdeaProjects/ui-adac/coverage/lcov.info]

[16:54:28] 16:54:28.283 WARN: Could not resolve 11 file paths in [<myHome>/IdeaProjects/ui-adac/coverage/lcov.info], first unresolved path: <myHome>/IdeaProjects/ui-adac/src/components/atoms/button/Button.jsx


The paths exist, I copied the path to the command line and was able to open them.

I do this on a Mac locally but the result on our Jenkins (Debian 8) is the exact same. 

My gulp task configuration for sonar is this:

{...}

module.exports = (gulp) => {
 
var options = {
    sonar
: {
      host
: {
        url
: 'http://<our-sonar-url>:9000'
     
},
      projectKey
: 'ui',
      projectName
: 'UI',
      projectVersion
: meta.version,
     
// comma-delimited string of source directories
      sources
: 'src',
      language
: 'js',
      sourceEncoding
: 'UTF-8',
      javascript
: {
        lcov
: {
          reportPaths
: 'coverage/lcov.info'
       
}
     
},
     
exec: {
       
// All these properties will be send to the child_process.exec method (see: https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback )
       
// Increase the amount of data allowed on stdout or stderr (if this value is exceeded then the child process is killed, and the gulp-sonar will fail).
        maxBuffer
: 1024*1024
     
}
   
}
 
};


I found this discussion (http://sonarqube-archive.15.x6.nabble.com/Coverage-no-longer-able-to-locate-file-after-case-change-in-path-td5034232.html) which seems to indicate there is a problem with mixed case paths (which we have) but it's pretty old and says the issue is fixed....

Any input is greatly appreciated. If you need additional logs or configs, I'll gladly provide them. 






Pierre-Yves Nicolas

unread,
Jan 16, 2017, 11:37:10 AM1/16/17
to Michael N., SonarQube
Hi,

The path which cannot be resolved ends with ".jsx".
Did you configure something to have jsx files analyzed by SonarQube?
You can try: sonar.javascript.file.suffixes=.js,.jsx

Pierre-Yves

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/fa263071-801e-4ba4-9ce4-10dc5d7b3551%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael N.

unread,
Jan 17, 2017, 5:24:46 AM1/17/17
to SonarQube, michael...@dertouristik.com
That's it!! Thank you so much!! 

For future reference of people that Google leads here, this is the full sonar gulp task:

const meta = require('../../package.json');
const sonar = require('gulp-sonar');


module.exports = (gulp) => {
 
var options = {
 sonar
: {
 host
: {

 url
: 'http://<url-to-sonar>'
 
},
 projectKey
: 'procect:key',
 projectName
: 'Project Name',
 projectVersion
: 'your.version.nr',

 
// comma-delimited string of source directories
 sources
: 'src',
 language
: 'js',
 sourceEncoding
: 'UTF-8',
 javascript
: {
 lcov
: {
 reportPaths
: 'coverage/lcov.info'
 
},

 file
: {
 suffixes
: '.js,.jsx'

 
}
 
},
 
exec: {
 
// All these properties will be send to the child_process.exec method (see: https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback )
 
// Increase the amount of data allowed on stdout or stderr (if this value is exceeded then the child process is killed, and the gulp-sonar will fail).
 maxBuffer
: 1024*1024
 
}
 
}
 
};


 
// gulp source doesn't matter, all files are referenced in options object above
 
return gulp.src('thisFileDoesNotExist.js', { read: false })
 
.pipe(sonar(options))
 
.on('error', console.log);
};



To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.

Pierre-Yves Nicolas

unread,
Jan 17, 2017, 5:42:36 AM1/17/17
to Michael N., SonarQube
To give some context: jsx files were not recognized by SonarQube as source files because no language plugin was configured to analyze them.
With your new configuration, jsx files are associated to the JavaScript plugin and are imported as source files by SonarQube: it's then possible to have coverage on them.
The big side effect is that the JavaScript rules are now applied to your jsx files and SonarQube may report valuable issues on them.
Do you care only about coverage?

Pierre-Yves


To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/fc5e0ee6-287d-459f-9e95-fa1bc8af1b1e%40googlegroups.com.

Michael N.

unread,
Jan 17, 2017, 5:52:22 AM1/17/17
to SonarQube, michael...@dertouristik.com
At the moment, yes. But in the gulp task that does the actual analysis, I have a regex, that selects only the actual test files (they are all named <class>Spec.jsx):

collectCoverageFrom: [ '**/*.{js,jsx}', '!**/node_modules/**' ],
testRegex
: '^.+Spec\\.(jsx|js)$',

Thing is, I am not at all a frontend developer, rather responsible for build management and such ... so that whole Javascript world is rather new to me...

thanks again, really appreciate it.

Michael
Reply all
Reply to author
Forward
0 new messages