Webstorm - Inspections - JavaScript function metrics not working?
Webstorm 7.0.3 build #WS-133.434 on December 26, 2013.
I'm currently putting together a profile for co-workers to run on our code before submission. I'm having trouble with the "Javascript function metrics" group. I've singled out the following options and tested them with settings of 1 and 2 and they didn't warn against anything they were supposed to:
- Functions with too many parameters
- Overly complex function
- Overly long function
- Overley nested function
After running the tests with each of these items at a very low setting, I just get "No suspicious code found". However, It is very obvious multiple parts of the code should produce warnings. Has anyone else had problems with these options?
I am aware that I can extend JSHint validation to cover these, but I really wanted to be able to set the severity on each item how I see fit. Currently, severity level is shared with all items in the JSHint validation.
Please sign in to leave a comment.
Hello!
metrics do work for me. Can you provide a sample project that shows up the problem? Your idea.log might also help
Sure! I should have thought about that to begin with. Here is a lnk to a very simple project on my dropbox:
https://dl.dropboxusercontent.com/u/54271990/InspectionTest.zip
Contents:
You will notice (or at least for me), none of the validation tests in "Test.xml" will trigger a warning. However, if you go to JSHint and enable the duplicate inspections there (with the same metrics), you will notice that they do flag warnings. Thank you for taking a look. :)
Thanks! seems these metrics don't work with function expressions. Change your code to
function functionWithTooManyParams (nNum1, nNum2, nNum3) {...}
and see it it works...
You are absolutely correct. I didn't even think it would refuse to validate one over the other. That's a bummer, but at least JS Hint appears to handle both, so I will likey stick what that. Thank you so very much for your time!
Looks like a bug to me. Logged as http://youtrack.jetbrains.com/issue/WEB-11077, please vote