I am new to SonarQube, and am trying to use it with a Javascript project, on Windows. I've followed the doc as best I can and am successfully seeing the static code analysis sonar does.
I am using JsTestDriver for my unit tests, and producing a code coverage report file. I see the test results in SonarQube, but the code coverage is always reported as 0.0%. If I don't specify a code coverage report file, or specify a file name that doesn't exist, the code coverage block in my dashboard does not display at all, so I know Sonar is seeing the file in some sense. I have run jGenHtml against the file and it produces correct HTML output, with the results I expect, so I know the file has content and is formatted correctly.
I have specified the location for these files in my Javascript plugin settings. As indicated by the doc and some forum posts I found, I used the relative directory path test/results for the actual unit test results (which show up fine) and the relative file name test/results/code-coverage.dat for the coverage report. I've also tried specifying the file as an absolute path, but it didn't help.
Any insight would be appreciated.
This is working now, thanks to the suggestion comment from David RACODON.
It seems my code coverage report contains file paths that look like this:
SF:H:\perforce_workspaces\atlasjs_main\.\test\lib\jquery-1.8.2.js
I edited the file to remove the \.\ bit in the middle, and now Sonar is able to import the file.
The sample project's coverage report does not have this in its paths, and I note that I have been using a slightly newer verson of jsTestDriver than the sample app. I am using 1.3.5, while the sample app comes with 1.3.4.b. I don't know if they changed the output format between revisions of the coverage plugin, or if this is something specific with my project. In any event, I should be able to figure out a way to prevent or remove the offending characters.
Note that jgenhtml was able to read my file just fine with the extraneoud \.\ so this seems to be an issue with Sonar being very picky.
Related
is there a way how to debug source maps in chrome? At least to see where is what mapped?
My problem is that I am remapping ts generated file (using source-maps), for whatever reason, does not matter. When I remap them and use console.log or console.error the console correctly shows the line where the console.log or console.error was executed and I can even navigate to the line in the original ts source file. But when I try to set a break point in the .js file on the same line where the console.log is located the break point is set incorrectly to "previous" line (or other file, if there is no any statement in the .ts file)
So the question is, is there a way to tell to chrome to show me mapped relations for js and ts files? If no, is there any other tool, ideally friendly, where I can click on statement and see were is it mapped to? I am lazy to write one, especially in this case I am not sure what I am doing wrong.
Thanks
EDIT:
In between I have found this:
http://sokra.github.io/source-map-visualization/#
and this:
https://github.com/danvk/source-map-explorer
I could not find anything because I was asking google in a wrong way.
EDIT2:
My bundled and remapped files seems to be ok.
It seems to be a bug in chrome debuger itself. Because when I place a break point directly to the typescript file it stops correctly.
So it seems to me the chrome incorrectly maps only breakpoints set in the original (bundled) js file what is actually bundle of compiled typescipt files accompanied with remapped .js.map files to the .js.map bundle.
I want to auto-indent an entire JavaScript file in WebStorm, and in my settings I have the following:
The problem is that when I use the menu Code -> Auto-Indent Lines or Code -> Reformat Code the indentation level remains at 2.
Is there a setting somewhere I am missing? I don't want to be inconsistent with the coding standards put in place.
The problem was with the .editorconfig file located in the root of the project directory. Although I can't recall receiving a warning, the settings in that file overwrote the Webstorm settings, and changing them to the desired indentations resulted in the desired result.
I need your help/guidance about one problem I have for the last two days.
The sonar-javascript plugin is not able to get the results of my Javascript UnitTests. I am generating unit tests and lcov results using JSTestDriver. The lcov results are working and are correctly shown in SonarQube. I also have to say that I am using Windows. Here is the error I have:
Test result will not be saved for test class "UnitTests.controlesTest", because SonarQube associated resource has not been found using file name: UnitTests\controlesTest.js"
The error is very similar to this one: Importing javascript XML JUnit tests to sonar using jstestdriver fails. However, this error seems to be fixed in the last SNAPSHOT (2.8). The file I am trying to access is stored in UnitTests/controlesTest.js. I tried to go into the sonar-javascript source, and find a way to correct this issue (at least, try to understand it). I ended up in the file JsTestDriverSensor.java in the function getTestFileRelativePathToBaseDir. I found that this line is not able to get my file (UnitTests\controles.js). Actually, fileIterator does not contain any InputFile.
Iterator<InputFile> fileIterator = fileSystem.inputFiles(predicate).iterator();
So I tried different predicates to understand why my file is not found. At the end, I found that the following predicate fileSystem.predicates().hasType(InputFile.Type.TEST) is the reason why this file is not found. A quick fix is to change:
- 108 testFilePredicate,
+ 108 mainFilePredicate,
I must be doing something wrong, maybe someone has an idea ?
The "sonar.tests" property has to be set in the sonar-project.properties (or in newer version SonarQube.Analysis.xml). This allows the sonar-javascript plugin to find the javascript test files.
This error is similar to many that others have been citing, with a different spin. I get the error, "Invalid signature. Code object is not signed at all. The binary at path [.../iscroll.js] contains an invalid signature. Make sure you have signed your application with a distribution certificate..." and so on, similar to these problems:
Error itms-90035 - Xcode
XCode Error itms-90035 - Invalid signature?
However, I haven't seen any so far that reference problems with javascript errors, so I wanted to post this question which I'll answer below with my fix.
The fix I found that worked right away was to remove the assets folder that is created by Cordova. If your build is properly created, only 5 files are needed:
index.html file
codova.js
assets/all.min.css
assets/all.min.js
assets/app.js
With just this small subset of files, the .js code signing errors disappear, along with any other errors you might be getting from .sh files, etc.
NOTE: We use minified code, and this list is for minified compiles.
I've tried to set up Simogeo's FileManager but I can only get half of it working.
My plan is to set it to a specific folder (../imgs/gallery) and allow the client to upload, download, rename, remove files - basically change the ones displayed on a specific page (../gallery.html).
Right now though, I can't get the FileManager to work properly. In it's absolutely simplest form (that is, uploading the extracted files to my /www/ root and duplicating filemanager.config.js.default to filemanager.config.js) it will allow me to create a folder and upload files but the second I do that, it'll just keep 'loading' something. Nothing shows, nothing is usable and a refresh will completely remove it from view.
The files are being created/uploaded in the ../userfiles/ folder which I can change in the future but it's just not working even in a pure setting.
(also, the instructions request changing a file ../connectors/php/filemanager.config.php, which for the life of me, I cannot find. ../connectors/php/default.config.php exists but doesn't follow the instructions very well if I was to substitute that.)
EDIT: I tried the 0.8 version, having no problems. It's a shame the up-to-date one doesn't work for me.
Are you sure permissions are set correctly on your folder ?
You could try :
chmod -R 0777 /path/to/filemanager/userfiles/
or (asserting you're running apache with www-data user :
chown -R www-data:www-data /path/to/filemanager/
You may also have a look to the configuration wiki page and sample page.
(also, the instructions request changing a file ../connectors/php/filemanager.config.php, which for the life of me, I cannot find. ../connectors/php/default.config.php exists but doesn't follow the instructions very well if I was to substitute that.)
Thanks for pointing this out. It is updated.
In my case the problem arose when migrating a site from dedicated hosting with PHP 5.3 to shared hosting with PHP 5.4, all of a sudden the file manager started behaving as described by the original poster. I updated to the latest FileManger version (2.0.0-dev) but still the same.
A look at the server error log showed a fatal error in connectors/php/filemanager.class.php on line #1312 where require_once('./inc/vendor/wideimage/lib/WideImage.php') failed to open the file. Checking the path there is no "vendor" directory so I removed that from the path and the server error went away. But still the same loading graphic.
I then considered that PHP 5.4.x wants to have the TimeZone set and depending on the server configuration may throw warnings or errors, even fatal ones in the background. So I added date_default_timezone_set ('America/Toronto'); at the top of the file connectors/php/filemanager.php and after that everything worked perfect. This may not be the optimal solution but it worked for me. If you try it of course change the TimeZone to your own.
This one had me pulling my hair out for a while, hope it helps someone.