K. Kwan
K. Kwan

Reputation: 143

WebStorm "weak warnings found" but no highlighted code

New to WebStorm. Trying to determine why WebStorm does not always display highlights in source code, even though weak warnings are reported? As an example, there may be "2 weak warnings found", but only 1 line highlighted in the source editor window.

Is there another way to get a list of warnings, with warning explanations and links to the problem code? Or at the very least, with line number for reference?

Thanks.

Upvotes: 14

Views: 2678

Answers (3)

LSerni
LSerni

Reputation: 57378

This was happening to me on a Javascript file app.js.

Ed Cottrell's answer seemed promising:

The short version is that you have to "kick" the IDE and get it to reset something internally.

But his workaround did not work for me (2016.2.2), nor did the following:

  • copy all contents, cut it away, save the file, paste it back.
  • hit F2 to trigger inspector
  • run inspector manually (Code > Inspect Code)
  • invalidate all caches and restart

So I thought I would carve down what piece of Javascript was triggering the fake error. To begin with I made an identical copy of app.js (Ctrl-C + Ctrl-V in the Files tree). I planned on removing code until I got rid of that pesky weak warning.

The new file (identical - same MD5 even) had no warnings and the green checkmark.

Okay, so I thought "I'll just delete app.js and rename appcopy.js. This will not go well with SVN but what the heck".

Then I thought I was first going to rename app.js, and I did. That triggered the refactor dialog. Silly me, I don't want to do that, and I hit Cancel. Then hit Refactor->Rename again but unchecked all refactorings.

And it was at that point that I noticed the green checkmark had appeared in app.js too.

So I hit Cancel again, and deleted the appcopy.js file.

The weak warning returned on the surviving app.js file!

Okay. Let's start again...

Final procedure

  • Ctrl-C + Ctrl-V and I have a new appunisci.js file identical to my app.js. Green checkmark on both. If only it were that easy...
  • Rename app.js without refactoring and app.js becomes spunisci.js . My app is now broken but no changes to the code are performed.
  • Rename appunisci.js without refactoring into app.js . My app now works again, I have an extra file and a SVN mess.
  • I now have an app.js with the green check mark
  • Finally delete spunisci.js to get rid of the extra file.
  • app.js is still OK!
  • from the command line, since I had also modified app.js (otherwise a simple revert would have fixed SVN)
    • copy app.js to app.bak
    • run svn revert app.js to reset Subversion history
    • copy app.bak to app.js to recover my changes
    • run svn status and confirm that app.js is "M" and not "R +"
  • courting disaster, I hit F2 in PHPStorm and also tried Code > Inspect Code...
    • "No suspicious code found" (as before), green checkmark.

Upvotes: 0

elixenide
elixenide

Reputation: 44823

I'm still not sure why this happens, but I have a fix. The short version is that you have to "kick" the IDE and get it to reset something internally. (I'm not sure what changes or where the IDE saves the change because I forgot to put the internal configuration under version control before playing with it, so I can't see what files it changed.)

This fix is tested in PHPStorm versions 10.0.1, 2016.1, and 2016.2 on OS X versions 10.10 (Yosemite), 10.11.2 (El Capitan), and 10.12 (Sierra).

Steps to Fix the Problem

Follow these steps:

1. Click on the inspector character in the lower right corner of the IDE:

enter image description here

2. Click on "Libraries in scope":

enter image description here

3. Check an option that is currently unchecked (I checked ECMAScript 6):

enter image description here

4. Click "OK" and return to the editor

5. Repeat steps 1-4, but uncheck whatever option you checked in step 3.

You should now get the magical green checkmark:

enter image description here

This glitch has driven me crazy for a while now, and it seems to have driven a few other people crazy, too, but the above steps seem to have fixed it for good.

Upvotes: 14

LazyOne
LazyOne

Reputation: 165088

Trying to determine why WebStorm does not always display highlights in source code, even though weak warnings are reported?

Usually such warnings have very "light" colors that are rather hardly visible. You may want to change them to better colors in your Settings | Preferences | Editor | Colors & Fonts | General

Is there another way to get a list of warnings, with warning explanations and links to the problem code? Or at the very least, with line number for reference?

Code | Inspect Code... where you can choose the scope (only current file; certain folder/scope etc).


If you need particular inspection only -- Code | Run Inspection by Name...

Upvotes: 0

Related Questions