[ANN] InspectionGadgets 0.0.8 released


Announcing version 0.0.8 of the InspectionGadgets plugin, available via the PluginManager
or at http://www.intellij.org/twiki/bin/view/Main/InspectionGadgets. Tested with Aurora versions 1019 and 1024.

Changes in version 0.0.8

Inspection categories are now sorted.
Toggle for error highlighting moved under "Tools" menu
(instead of "Options" which blissfully no longer exists)

New Inspections

  • Return of 'this'

  • Comparison of short and char

  • Use of "assert" as identifier

  • Call to Thread.dumpStack()

  • Subtraction in compareTo()

  • Pointless arithmetic expression

  • Unnecessary 'super()' statement

  • 'throw' inside 'catch' block which ignores the caught exception

  • Non-serializable class with 'readObject()' or 'writeObject()

  • Non-serializable class with serialVersionUID


plus a handful of bugfixes

--Dave "Happy Holidays" Griffith

27 comments
Comment actions Permalink

Dave, this is pretty amazing!

Out of curiosity, how much better a programmer has this particular made
you? I mean do you run it on your code and suddently realize that
things are not as clean as you thought, so you add more inspections to
find more stuff?

I mean writing the inspections alone must take some serious reading of
the java standards!

yikes, the patience!

Good work!

R

Dave Griffith wrote:

Announcing version 0.0.8 of the InspectionGadgets plugin, available via the PluginManager
or at http://www.intellij.org/twiki/bin/view/Main/InspectionGadgets. Tested with Aurora versions 1019 and 1024.

Changes in version 0.0.8

Inspection categories are now sorted.
Toggle for error highlighting moved under "Tools" menu
(instead of "Options" which blissfully no longer exists)

New Inspections

  • Return of 'this'

  • Comparison of short and char

  • Use of "assert" as identifier

  • Call to Thread.dumpStack()

  • Subtraction in compareTo()

  • Pointless arithmetic expression

  • Unnecessary 'super()' statement

  • 'throw' inside 'catch' block which ignores the caught exception

  • Non-serializable class with 'readObject()' or 'writeObject()

  • Non-serializable class with serialVersionUID


plus a handful of bugfixes

--Dave "Happy Holidays" Griffith

0
Comment actions Permalink

Dave,

With the ever growing list of inspections, can you provide a convenient
way to jump from an online warning/error to the associated IDE>Errors
setting for that inspection? I'd like to request the feature but I'm
guessing it would more properly be a general IDEA feature request.

Thanks,
Jon

0
Comment actions Permalink

it's already there! drop the attentions dropdown menu when the bulb lights, and see what's inside.

0
Comment actions Permalink

Doh! And how many months has that been available and I've been oblivious
to it? Idea guys & Dave - you have to stop reading people's minds
especially before we even have the thoughts. On the other hand, keep
doing it.

Jon

tc master wrote:

it's already there! drop the attentions dropdown menu when the bulb lights, and see what's inside.


0
Comment actions Permalink

I think it's been there since about 972 or so. At first I thought I'd hate it, but it does come in handy.

--Dave

0
Comment actions Permalink

Cool. Now, how do we get your code for that into IDEA itself so that
non-IG inspections also have the feature?

Jon

Dave Griffith wrote:

I think it's been there since about 972 or so. At first I thought I'd hate it, but it does come in handy.


0
Comment actions Permalink


This functionality is a part of IDEA itself.

0
Comment actions Permalink

But when I have an unused import or silly assignment from the built-in
inspections, I don't see an intention to go to the settings.

Jon

Dave Griffith wrote:

This functionality is a part of IDEA itself.


0
Comment actions Permalink

I got a NPE when doing the automatic resolution for 'Constant on right side of comparison'


java.lang.NullPointerException
at com.intellij.psi.impl.source.b.e.c(e.java:73)
at com.intellij.psi.impl.source.g.r.a(r.java:49)
at com.intellij.psi.impl.source.g.s.replace(s.java:75)
at com.siyeh.ig.BaseInspection.replaceExpression(BaseInspection.java:53)
at com.siyeh.ig.style.ConstantOnRHSOfComparisonInspection.access$200(ConstantOnRHSOfComparisonInspection.java:10)
at com.siyeh.ig.style.ConstantOnRHSOfComparisonInspection$SwapComparisonFix.applyFix(ConstantOnRHSOfComparisonInspection.java:57)
at com.intellij.codeInspection.o.r$2.run(r$2.java:7)
at com.intellij.openapi.application.a.b.runWriteAction(b.java:5)
at com.intellij.codeInspection.o.r$1.run(r$1.java:4)
at com.intellij.openapi.command.impl.a.executeCommand(a.java:55)
at com.intellij.codeInspection.o.r.a(r.java:38)
at com.intellij.codeInspection.o.r.actionPerformed(r.java:36)

0
Comment actions Permalink

I got an Assertion Failed with build1050 when doing 'Make conversion Explicit' for the 'Implicit numeric conversions' inspections.

Error message: Assertion failed: getManager() == null!
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:142)
at com.intellij.psi.impl.source.g.a.bf.multiResolve(bf.java:82)
at com.intellij.psi.impl.source.g.a.bf.advancedResolve(bf.java:156)
at com.intellij.psi.impl.source.g.a.bf.resolve(bf.java:136)
at com.intellij.psi.impl.source.g.a.z.resolveMethod(z.java)
at com.siyeh.ig.psiutils.ExpectedTypeUtils.findCalledMethod(ExpectedTypeUtils.java:204)
at com.siyeh.ig.psiutils.ExpectedTypeUtils.findExpectedType(ExpectedTypeUtils.java:104)
at com.siyeh.ig.confusing.ImplicitNumericConversionInspection$ImplicitNumericConversionFix.applyFix(ImplicitNumericConversionInspection.java:59)

0
Comment actions Permalink

When I do 'Simplify' automatic repair for 'Redundant boolean comparison' I get a NPE

java.lang.NullPointerException
at com.intellij.psi.impl.source.b.e.c(e.java:73)
at com.intellij.psi.impl.source.g.r.a(r.java:49)
at com.intellij.psi.impl.source.g.s.replace(s.java:75)
at com.siyeh.ig.BaseInspection.replaceExpression(BaseInspection.java:53)
at com.siyeh.ig.verbose.BooleanLiteralComparisonInspection.access$300(BooleanLiteralComparisonInspection.java:9)
at com.siyeh.ig.verbose.BooleanLiteralComparisonInspection$BooleanLiteralComparisonFix.applyFix(BooleanLiteralComparisonInspection.java:105)
at com.intellij.codeInspection.o.r$2.run(r$2.java:7)
at com.intellij.openapi.application.a.b.runWriteAction(b.java:5)
at com.intellij.codeInspection.o.r$1.run(r$1.java:4)
at com.intellij.openapi.command.impl.a.executeCommand(a.java:55)

0
Comment actions Permalink

I found out that some of the NPEs I was getting was when I tried to apply a fix to a read-only file. Even after I checked out the file, the NPE would still happen. It seems to have gotten into a bad state. The same fix could be applied to other files which were not read only.

After restarting IDEA, rerunning the inspection, then applying the fixworked.

0
Comment actions Permalink


Wierd, I thought I had code in to check for writable state. I'll look into it.

--Dave

0
Comment actions Permalink

Hey,

What version of intellij does this build correspond with? I tried to use it with 3.0.5 and I get the exception below. Any advice gratefully accepted!

(e.java:71)
	at com.intellij.openapi.application.b.f.f.java)
	at com.intellij.idea.v.(v.java:13)
	at com.intellij.idea.j.a(j.java)
	at com.intellij.idea.k.run(k.java:0)
	at com.intellij.ide.f.j.a(j.java:128)
	at com.intellij.ide.f.j.a(j.java:134)
	at com.intellij.idea.Main.a(Main.java:53)
	at com.intellij.idea.Main.start(Main.java:40)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.intellij.ide.j.d.run(d.java:8)
	at java.lang.Thread.run(Unknown Source)]]>

0
Comment actions Permalink


InspectionGadgets only works with the Aurora EAPs. The 3.0 version is not and will not be supported (indeed, it cannot, due to lack of an inspection API in 3.0).

--Dave Griffith

0
Comment actions Permalink

Try the latest Aurora (EAP @ www.intellij.net/eap) build, the plugin does
not work with Arianda (IDEA 3.0) builds.

HTH,
Andrei

Pavan Sandher wrote:

Hey,

What version of intellij does this build correspond with? I tried to use
it with 3.0.5 and I get the exception below. Any advice gratefully
accepted!

 [intellij.plugins.PluginManager - Original exception:
> java.lang.NoClassDefFoundError:
> com/intellij/codeInspection/InspectionToolProvider at
> java.lang.ClassLoader.defineClass0(Native Method) at
> java.lang.ClassLoader.defineClass(Unknown Source) at
> java.lang.ClassLoader.defineClass(Unknown Source) at
> com.intellij.ide.j.a.a.a(a.java:10) at
> com.intellij.ide.j.a.a.findClass(a.java:16) at
> com.intellij.ide.j.a.c.loadClass(c.java:8) at
> java.lang.ClassLoader.loadClass(Unknown Source) at
> com.intellij.ide.j.a.b.loadClass(b.java:31) at
> java.lang.ClassLoader.loadClass(Unknown Source) at
> java.lang.ClassLoader.loadClassInternal(Unknown Source) at
> java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown
> Source) at com.intellij.openapi.components.a.a.a(a.java:138)
> at com.intellij.idea.g.a(g.java:2)
> at com.intellij.openapi.application.b.e.(e.java:71)
> at com.intellij.openapi.application.b.f.f.java)
> at com.intellij.idea.v.(v.java:13)
> at com.intellij.idea.j.a(j.java)
> at com.intellij.idea.k.run(k.java:0)
> at com.intellij.ide.f.j.a(j.java:128)
> at com.intellij.ide.f.j.a(j.java:134)
> at com.intellij.idea.Main.a(Main.java:53)
> at com.intellij.idea.Main.start(Main.java:40)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at com.intellij.ide.j.d.run(d.java:8)
> at java.lang.Thread.run(Unknown Source)]]>


0
Comment actions Permalink

Hi,

I've had a chance to use the Inspection and the Error Highlighting some more. This is really a great tool. The original Error Highlighting seems like an initial prototype whereas the InspectionGadgets is the industrial strength commerical grade product.

Here are some comments.

1) I configured the error highlighting to show the warnings/errors I wanted. What I found was that on some files there were a ton of warnings. For those with automatic fixes, rather than hitting ALT+ENTER to run the intention to fix it, I would like to just run the inspection tool on the file because the inspection results let you fix all instances of a one problem in one click, e.g. 'Flip comparison'.

So, I can do Tools->Inspect Code.., Inspect file xxx,
but the problem I run into is that the Inspection Profile doesn't match what I had configured for the error highlighting. So, I need to create a profile which matches the error highlighting.

I was thinking an improvement would be for the Inspect Tool.. inspection profile settings shouldbe an item in IDE setttings, and then in Errors settings, the user should select which Inspection Profile to use for error hilighting. You would still mark inspections as Errors or Warnings, but the Profile would control whether each inspection item is shown or not. That way, you can switch between different profiles, and the error/warning presentation settings would still apply.

2) For some of the inspections, I found the Description to be very helpful. I initially turned on alot of inspections to try them out, and some of them I couldn't figure out completely based on the Problem Synopsis. It would be nice if the Description was accessible from the Inspection Results window.

3) Also in the inspection results window, I would like to be able to right-click on an inspection and say "Disable this inspection in the current profile".
Again, when I initially was experimenting with the inspections, I turned alot of them on, and as I browsed the results, I knew I didn't want alot of them. It would have been quicker for me to be able to disable them right then and there, and have them removed from the results tree. Currently, I have to run the Tools->Inspect Code.. dialog, and then scroll down until I find the inspection, and then turn it off.

4) For 'Serializable class without serialVersionUID' inspection. This was very useful, however since JComponent implements Serialable, all GUI classes like JPanel, JButton, etc. are all showing up as not having serialVersionUID.

Maybe it is possible to allow us to exclude all classes which are subclasses of a class, e.g. JComponent?

In general, all classes I plan to serialize I will explicitly mark them in the class as 'implements Serializable' even if they subclass another class which implements Serializable.

What I really want is to see all classes which explicitly say 'implements Serializable' in the class file or classes which are subclasses from non-library classes which 'implements Serializable'. But I could achieve almost the same by excluding all subclasses of certain classes, e.g. JComponent.

The reason for excluding JComponent is that unless you serialize your UI, you don't care about setting serialVersionUID on UI classes.

You could probably have a QuickFix for this item. Just
insert:
static final long serialVersionUID = 1;

0
Comment actions Permalink

The Error Hilighting seems to be throwing a statement on the following code. (The ^ marks where the caret is located). The error dialog says it is a plugin inspection. After I press ignore, it keeps popping up again and again.



0
Comment actions Permalink

Alex>>2) For some of the inspections, I found the Description to be very helpful. I initially turned on alot of inspections to try them out, and some of them I couldn't figure out completely based on the Problem Synopsis. It would be nice if the Description was accessible from the Inspection Results window.>>

One place to put the description is when you click on the inspection name in the Inspection Results Tree, e.g.
"Class structure->Utility class without private constructor (24 items)", the right side is blank. That would be a great place to show the Description.

0
Comment actions Permalink

+I've had a chance to use the Inspection and the Error Highlighting some more. This is really a great tool. The original Error Highlighting seems like an initial prototype whereas the InspectionGadgets is the industrial strength commerical grade product. +

Thanks, I'm glad you like it.


I was thinking an improvement would be for the Inspect Tool.. inspection profile settings shouldbe an item in IDE setttings, and then in Errors settings, the user should select which Inspection Profile to use for error hilighting. You would still mark inspections as Errors or Warnings, but the Profile would control whether each inspection item is shown or not. That way, you can switch between different profiles, and the error/warning presentation settings would still apply.

I like it a lot, although there are questions about some of the built-in inspections that aren't highlightable and built-in highlightings that aren't inspections. This is way outside the scope of what the inspections API lets me do, so you'll have to submit a tracker item to JetBrains

2) For some of the inspections, I found the Description to be very helpful. I initially turned on alot of inspections to try them out, and some of them I couldn't figure out completely based on the Problem Synopsis. It would be nice if the Description was accessible from the Inspection Results window.

Agreed, and I like your suggestion in another note on where to show it. Please submit a tracker item for that as well.

3)Also in the inspection results window, I would like to be able to right-click on an inspection and say "Disable this inspection in the current profile".

Cool idea, and I would guess it's pretty easy for JetBrains to do, but I cannot. Please submit a tracker item.



I've come across the issues you describe before, but didn't have an answer. I like your suggestions, and will be implementing most of them for the 0.0.9 release, sometime before the end of the month.

--Dave Griffith

0
Comment actions Permalink


Gah, that's an ugly one. I've got a fix for it, and it'll be in the 0.0.9 release.

--Dave

0
Comment actions Permalink

Is there a way to export the analysis into an XML formatted file?

0
Comment actions Permalink

As I understand it, the offline inspection tool dumps it's output as XML. However, the offline inspection tool doesn't support third-party inspections (there's an open SCR for that). So, in short, no. Getting such would require JetBrains to do so in the product, rather than me in the plugin

--Dave

0
Comment actions Permalink

Probably I am missing something (as always :)) but should the code in included picture cause warning?
See attachement and the warning message.

Btw, Dave - I have one request:
Sometimes something goes wrong with Inspection Gadgets and than I get the Exception popup and cannot do anything except for closing IDEA.

Previously InspectionGadgets on/off togle was in different, shorter menu and I was able to click and disable it, before the exception popup reappeared.
Could you provide a keyboard shortcut to do it? :)



Attachment(s):
Inspections.gif
0
Comment actions Permalink


Yes, there should be a warning, but not the one shown. The actual warning should be for a static final method, not a private final method ("final" is useless on both static and private methods). This will be fixed in 0.0.9, released sometime before the end of the month, possibly as soon as next week.

I love the keyboard shortcut idea (I see a lot more of that inspection panel than you do, believe me). It'll be in 0.0.9 as well, but until then you can map it yourself in Settings/Keymap. I just tried it and it works fine. Unless anyone has a better suggestion, the default mapping will be Alt-I.

--Dave

0
Comment actions Permalink

#26060- Error hilighting settings should use the inspect tool profiles
http://www.intellij.net/tracker/idea/viewSCR?publicId=26060

#26061- Display Inspection Description in the Inspection Results Tree.
http://www.intellij.net/tracker/idea/viewSCR?publicId=26061

#26063- Allow user to disable an inspection directly from the Inspection Results Tree
http://www.intellij.net/tracker/idea/viewSCR?publicId=26063

0

Please sign in to leave a comment.