[ANN] InspectionGadgets 0.0.2 released


Announcing version 0.0.2 of InspectionGadgets. Version 0.0.2 fixes a variety of bugs, and adds enough new inspections, options, and quick fixes to move IDEA+InspectionGadgets into the top rank of Java static analysis tools (Parasoft JTest and CodePro Instantiations still trump it, but only barely.)

New Inspections

*Static variable may not be initialized in class construction
*Instance variable may not be initialized in object construction
*Abstract method called in constructor
*Overridable method called in constructor
*Return of null literal
*Abstract class extends concrete class
*Abstract class without abstract methods
*Abstract method overrides concrete method
*Non-synchronized method overrides synchronized method
*Protected member in final class
*Utility class with public constructor
*Utility class without private constructor

New Options
*Empty catch block inspections now optionally considers comments
*Abstract class without private constructor now optionally ignores non-public classes

New QuickFixes
*Quick fix for "String literal as arg of .equals(), rather than target"

Bugs fixed
*Fix for package-visible variables in "Local variable hides member variable" and "Parameter hides member variable"
*Fix for associativity bug in "Remove unnecessary parentheses"
*"Unnecessary this" inspection now ignores qualified "this" inspections
*Fixed bug in "Single character string concatenation" that resulted in uncompilable code
*Collection inspections now understand generics
*UI change: errors now show up as generic errors, not as unused symbols.
*Fixed an NPE bug in "Missorted Modifiers"
*All inspections should now work correctly on class initializers.

--Dave Griffith

21 comments
Comment actions Permalink

Whoops, missed the most important part. InspectionGadgets is available at http://www.intellij.org/twiki/bin/view/Main/InspectionGadgets, and requires Aurora build 873 or greater.

0
Comment actions Permalink

Dave Griffith wrote:

Announcing version 0.0.2 of InspectionGadgets. Version 0.0.2 fixes a variety of bugs, and adds enough new inspections, options, and quick fixes to move IDEA+InspectionGadgets into the top rank of Java static analysis tools (Parasoft JTest and CodePro Instantiations still trump it, but only barely.)


Thanks! Already looking forward to the next one :)

I get recurring NullPointerExceptions in one of my classes. It uses
generics but I don't know if that has anything to do with it. I turned
off "unnecessary interface modifier" and now it seems to work fine.

2003-07-29 17:24:13,265 ERROR -
intellij.plugins.PluginManager -
2003-07-29 17:24:13,265 ERROR -
intellij.plugins.PluginManager - IntelliJ IDEA (Aurora) Build #876
2003-07-29 17:24:13,265 ERROR -
intellij.plugins.PluginManager - JDK: 1.4.2
2003-07-29 17:24:13,265 ERROR -
intellij.plugins.PluginManager - VM: Java HotSpot(TM) Client VM
2003-07-29 17:24:13,265 ERROR -
intellij.plugins.PluginManager - Vendor: Sun Microsystems Inc.
2003-07-29 17:24:13,265 ERROR -
intellij.plugins.PluginManager - OS: Windows XP
2003-07-29 17:24:13,265 ERROR -
intellij.plugins.PluginManager - Last Action: EditorDown
2003-07-29 17:24:13,265 ERROR -
intellij.plugins.PluginManager -
java.lang.NullPointerException
at
com.siyeh.ig.verbose.UnnecessaryInterfaceModifierInspection$UnnecessaryInterfaceModifierVisitor.visitClass(UnnecessaryInterfaceModifierInspection.java:108)
at
com.intellij.psi.JavaElementVisitor.visitClassParameter(JavaElementVisitor.java:76)
at com.intellij.psi.impl.source.b.a.cp.accept(cp.java:28)
at com.siyeh.ig.ClassInspection.checkClass(ClassInspection.java:17)
at com.intellij.codeInsight.a.a.bw.a(bw.java:19)
at com.intellij.codeInsight.a.a.cn.run(cn.java:4)
at com.intellij.openapi.application.b.d.runReadAction(d.java:283)
at com.intellij.codeInsight.a.a.cy.a(cy.java:19)
at com.intellij.codeInsight.a.a.cy.a(cy.java:28)
at com.intellij.codeInsight.a.a.cm.run(cm.java)
at com.intellij.progress.c.a(c.java:23)
at com.intellij.codeInsight.a.a.cy.run(cy.java:27)


0
Comment actions Permalink

The settings panel talks about cyclotomic complexity and the warning
message shown for overly complex methods talks about cyclomatic
complexity. Is this intentional? What's the difference?

0
Comment actions Permalink

Probably not generics, just one more place I wasn't checking for null. A fix will go in the next release.

0
Comment actions Permalink


My error. Should be "cyclomatic" in both places, but I've got an annoying mental block about the word. Fixed in the next release.

0
Comment actions Permalink

Beautiful. Extremely useful.

Since I turned on auto-highlighting for a bunch of these new inspections, I've noticed my Idea performance getting worse (go figure). Is there an easy way to add a rough computation cost to the documentation of each inspection, so I could identify and disable the auto-highlighting of any high-cost/low-value inspections?

(Yes, I could just get a faster machine. :)

0
Comment actions Permalink


I'm noticing this bad performance on 876 as well, which I hadn't gotten earlier. I'm tracking it down now, and considering a variety of performance enhancements. Once I do that, I'll have a better handle on just which inspections are the most expensive.

Sorry I can't say more yet.

0
Comment actions Permalink

Hi, congratulations!

One small issue: Considering naming conventions I would suggest to make some exceptions possible:

Local variable naming convention ("ignore loop indexes")

- for-loop indexes may be nameable without respect
to the local variable naming convention (configurable)
(for example: i without the prefix defined in the naming convention)

Parameter naming convention ("ignore catch parameters")

- Exception arguments to catch blocks may be nameable without respect
to the parameter naming convention (configurable)
(for example: e without the prefix defined in the naming convention)

Regards
Frank Bruch

0
Comment actions Permalink

Good ideas, and easily implemented. They'll be in the next version.

--Dave

0
Comment actions Permalink

I guess this has been already reported and (?) fixed but still:
we have

private static final Logger LOG = Logger.getInstance("#"); particually in every class that uses logging. Inspection says "Field LOG hides field in superclass". I feel this is not necessary since field in super class is private as well so nothing to hide here. -- Best regards, Maxim Shafirov JetBrains, Inc / IntelliJ Software http://www.intellij.com "Develop with pleasure!" "Dave Griffith" wrote in message news:2690274.1059489599740.JavaMail.itn@is.intellij.net... >]]>

Announcing version 0.0.2 of InspectionGadgets. Version 0.0.2 fixes a

variety of bugs, and adds enough new inspections, options, and quick fixes
to move IDEA+InspectionGadgets into the top rank of Java static analysis
tools (Parasoft JTest and CodePro Instantiations still trump it, but only
barely.)
>

New Inspections

>

*Static variable may not be initialized in class construction
*Instance variable may not be initialized in object construction
*Abstract method called in constructor
*Overridable method called in constructor
*Return of null literal
*Abstract class extends concrete class
*Abstract class without abstract methods
*Abstract method overrides concrete method
*Non-synchronized method overrides synchronized method
*Protected member in final class
*Utility class with public constructor
*Utility class without private constructor

>

New Options
*Empty catch block inspections now optionally considers comments
*Abstract class without private constructor now optionally ignores

non-public classes
>

New QuickFixes
*Quick fix for "String literal as arg of .equals(), rather than target"

>

Bugs fixed
*Fix for package-visible variables in "Local variable hides member

variable" and "Parameter hides member variable"

*Fix for associativity bug in "Remove unnecessary parentheses"
*"Unnecessary this" inspection now ignores qualified "this" inspections
*Fixed bug in "Single character string concatenation" that resulted in

uncompilable code

*Collection inspections now understand generics
*UI change: errors now show up as generic errors, not as unused

symbols.

*Fixed an NPE bug in "Missorted Modifiers"
*All inspections should now work correctly on class initializers.

>

--Dave Griffith



0
Comment actions Permalink

Happened on the file with generics class defined.

ERROR - intellij.plugins.PluginManager -
ERROR - intellij.plugins.PluginManager - IntelliJ IDEA (Aurora)
Bu
ild #__BUILD_NUMBER__
ERROR - intellij.plugins.PluginManager - Internal version.
Compiled
01 August 2003 14:18
ERROR - intellij.plugins.PluginManager - JDK: 1.4.2-beta
ERROR - intellij.plugins.PluginManager - VM: Java HotSpot(TM)
Client
VM
ERROR - intellij.plugins.PluginManager - Vendor: Sun
Microsystems In
c.
ERROR - intellij.plugins.PluginManager - OS: Windows XP
ERROR - intellij.plugins.PluginManager - Last Action:
GotoDeclaratio
n
ERROR - intellij.plugins.PluginManager -
java.lang.NullPointerException
at
com.siyeh.ig.verbose.UnnecessaryInterfaceModifierInspection$Unnecessa
ryInterfaceModifierVisitor.visitClass(UnnecessaryInterfaceModifierInspection
.jav
a:108)
at
com.intellij.psi.JavaElementVisitor.visitClassParameter(JavaElementVi
sitor.java:365)
at
com.intellij.psi.impl.source.tree.java.PsiTypeParameterImpl.accept(Ps
iTypeParameterImpl.java:280)
at com.siyeh.ig.ClassInspection.checkClass(ClassInspection.java:17)
at
com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.collectInfo
rmation(LocalInspectionsPass.java:87)
at
com.intellij.codeInsight.daemon.impl.UpdateThread$2.run(UpdateThread.
java:141)
at
com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(A
pplicationImpl.java:343)
at
com.intellij.codeInsight.daemon.impl.UpdateThread.doRun(UpdateThread.
java:134)
at
com.intellij.codeInsight.daemon.impl.UpdateThread.access$000(UpdateTh
read.java:15)
at
com.intellij.codeInsight.daemon.impl.UpdateThread$1.run(UpdateThread.
java:116)
at
com.intellij.progress.ProgressManager.runProcess(ProgressManager.java
:56)
at
com.intellij.codeInsight.daemon.impl.UpdateThread.run(UpdateThread.ja
va:113)

--

Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Dave Griffith" <dave.griffith@cnn.com> wrote in message
news:2690274.1059489599740.JavaMail.itn@is.intellij.net...
>

Announcing version 0.0.2 of InspectionGadgets. Version 0.0.2 fixes a

variety of bugs, and adds enough new inspections, options, and quick fixes
to move IDEA+InspectionGadgets into the top rank of Java static analysis
tools (Parasoft JTest and CodePro Instantiations still trump it, but only
barely.)
>

New Inspections

>

*Static variable may not be initialized in class construction
*Instance variable may not be initialized in object construction
*Abstract method called in constructor
*Overridable method called in constructor
*Return of null literal
*Abstract class extends concrete class
*Abstract class without abstract methods
*Abstract method overrides concrete method
*Non-synchronized method overrides synchronized method
*Protected member in final class
*Utility class with public constructor
*Utility class without private constructor

>

New Options
*Empty catch block inspections now optionally considers comments
*Abstract class without private constructor now optionally ignores

non-public classes
>

New QuickFixes
*Quick fix for "String literal as arg of .equals(), rather than target"

>

Bugs fixed
*Fix for package-visible variables in "Local variable hides member

variable" and "Parameter hides member variable"

*Fix for associativity bug in "Remove unnecessary parentheses"
*"Unnecessary this" inspection now ignores qualified "this" inspections
*Fixed bug in "Single character string concatenation" that resulted in

uncompilable code

*Collection inspections now understand generics
*UI change: errors now show up as generic errors, not as unused

symbols.

*Fixed an NPE bug in "Missorted Modifiers"
*All inspections should now work correctly on class initializers.

>

--Dave Griffith




0
Comment actions Permalink

I have a request: for the Collection Declared by Class not Interface
inspection, could the plugin do a cursory search for use of non-interface
methods on the member even if it is just locally? This should cover most
scenarios; Interfaces are generally badly written if it uses concrete
collection classes, but internally you often want to declare a field as a
concrete class to get at specific api - e.g. clone().

Cheers,
N.

Dave Griffith wrote:

Announcing version 0.0.2 of InspectionGadgets. Version 0.0.2 fixes a
variety of bugs, and adds enough new inspections, options, and quick
fixes to move IDEA+InspectionGadgets into the top rank of Java static
analysis tools (Parasoft JTest and CodePro Instantiations still
trump it, but only barely.)

>

New Inspections

>

*Static variable may not be initialized in class construction
*Instance variable may not be initialized in object construction
*Abstract method called in constructor
*Overridable method called in constructor
*Return of null literal
*Abstract class extends concrete class
*Abstract class without abstract methods
*Abstract method overrides concrete method
*Non-synchronized method overrides synchronized method
*Protected member in final class
*Utility class with public constructor
*Utility class without private constructor

>

New Options
*Empty catch block inspections now optionally considers comments
*Abstract class without private constructor now optionally ignores
non-public classes

>

New QuickFixes
*Quick fix for "String literal as arg of .equals(), rather than
target"

>

Bugs fixed
*Fix for package-visible variables in "Local variable hides member
variable" and "Parameter hides member variable"
*Fix for associativity bug in "Remove unnecessary parentheses"
*"Unnecessary this" inspection now ignores qualified "this"
inspections
*Fixed bug in "Single character string concatenation" that
resulted in uncompilable code
*Collection inspections now understand generics
*UI change: errors now show up as generic errors, not as unused
symbols.
*Fixed an NPE bug in "Missorted Modifiers"
*All inspections should now work correctly on class initializers.

>

--Dave Griffith



0
Comment actions Permalink

Out of the thread
http://www.intellij.net/forums/thread.jsp?forum=22&thread=36947&message=521789&q=737472323d3d6e756c6c#521789
has popped the highly elegant:

object1 == null ? object1 == object2 : object1.equals(object2)

for evaluation of equality.

But unfortunately inspection gadgets highlights the "object1 == object2"
part if object1 and object2 are both Strings, even though the entire
statement is ok.

Any way you could get round this? I suppose you could be smart and deduce
that object1 must be null therefore ok to equate using equals...

Cheers,
N.


0
Comment actions Permalink

InspectionGadgets shouldn't flag the (even more elegant, IMHO)

object1 == null ? object2 == null: object1.equals(object2)

since it explicitly allows checks for == with null.

0
Comment actions Permalink

Aha! sold :)

Dave Griffith wrote:

InspectionGadgets shouldn't flag the (even more elegant, IMHO)

>

object1 == null ? object2 == null: object1.equals(object2)

>

since it explicitly allows checks for == with null.



0
Comment actions Permalink

Small bug: I'm getting an "overrides concrete method" warning if an
interface redeclares a parent interfaces method.

Cheers,
N.


0
Comment actions Permalink


Thanks. This one's easy enough to fix, but I'm tempted to make a separate inspection that catches precisely that case. Strikes me that that sort of "override" is a bug waiting to happen if either interface changes.

--Dave

0
Comment actions Permalink

Yes, although you could say the same for the implementing classes! :) As
long as whatever tool you use to alter the signature of your method
implementations alters the signature of derived interfaces too you're ok,
and thankfully IDEA does.

The only reason I've done it is to re-javadoc the method, specifying more
concrete info than the base class does.

Cheers,
N.

Dave Griffith wrote:

Thanks. This one's easy enough to fix, but I'm tempted to make a
separate inspection that catches precisely that case. Strikes me
that that sort of "override" is a bug waiting to happen if either
interface changes.

>

--Dave



0
Comment actions Permalink

Seems like the OpenAPI (or the semi-open API) changed in #896. I'm
getting the following error trying to configure the settings through the
error configuration page:

ERROR - intellij.plugins.PluginManager -
ERROR - intellij.plugins.PluginManager - IntelliJ IDEA
(Aurora) Build #896
ERROR - intellij.plugins.PluginManager - JDK: 1.4.2
ERROR - intellij.plugins.PluginManager - VM: Java HotSpot(TM)
Client VM
ERROR - intellij.plugins.PluginManager - Vendor: Sun
Microsystems Inc.
ERROR - intellij.plugins.PluginManager - OS: Windows XP
ERROR - intellij.plugins.PluginManager - Last Action:
ERROR - intellij.plugins.PluginManager -
java.lang.NoSuchMethodError:
com.intellij.psi.util.PsiUtil.isDescendant(Lcom/intellij/psi/PsiClass;Lcom/intellij/psi/PsiClass;ZZ)Z
at com.siyeh.ig.psiutils.ClassUtils.isSubclass(ClassUtils.java:39)
at
com.siyeh.ig.naming.ExceptionNameDoesntEndWithExceptionInspection$ExceptionNameDoesntEndWithExceptionVisitor.visitClass(ExceptionNameDoesntEndWithExceptionInspection.java:62)
at com.intellij.psi.impl.source.bj.accept(bj.java:29)
at com.siyeh.ig.ClassInspection.checkClass(ClassInspection.java:17)
at com.intellij.codeInsight.f.a.bv.a(bv.java:68)
at com.intellij.codeInsight.f.a.cm.run(cm.java:12)
at com.intellij.openapi.application.a.d.runReadAction(d.java:14)
at com.intellij.codeInsight.f.a.cx.a(cx.java:19)
at com.intellij.codeInsight.f.a.cx.b(cx.java:36)
at com.intellij.codeInsight.f.a.cl.run(cl.java:3)
at com.intellij.progress.d.a(d.java:5)
at com.intellij.codeInsight.f.a.cx.run(cx.java:43)
ERROR - intellij.plugins.PluginManager
-java.lang.NoSuchMethodError:
com.intellij.psi.util.PsiUtil.isDescendant(Lcom/intellij/psi/PsiClass;Lcom/intellij/psi/PsiClass;ZZ)Z
at com.siyeh.ig.psiutils.ClassUtils.isSubclass(ClassUtils.java:39)
at
com.siyeh.ig.naming.ExceptionNameDoesntEndWithExceptionInspection$ExceptionNameDoesntEndWithExceptionVisitor.visitClass(ExceptionNameDoesntEndWithExceptionInspection.java:62)
at com.intellij.psi.impl.source.bj.accept(bj.java:29)
at com.siyeh.ig.ClassInspection.checkClass(ClassInspection.java:17)
at com.intellij.codeInsight.f.a.bv.a(bv.java:68)
at com.intellij.codeInsight.f.a.cm.run(cm.java:12)
at com.intellij.openapi.application.a.d.runReadAction(d.java:14)
at com.intellij.codeInsight.f.a.cx.a(cx.java:19)
at com.intellij.codeInsight.f.a.cx.b(cx.java:36)
at com.intellij.codeInsight.f.a.cl.run(cl.java:3)
at com.intellij.progress.d.a(d.java:5)
at com.intellij.codeInsight.f.a.cx.run(cx.java:43)


0
Comment actions Permalink

Jonas Kvarnström wrote:

Seems like the OpenAPI (or the semi-open API) changed in #896. I'm
getting the following error trying to configure the settings through the
error configuration page:


Maybe it wasn't related to the error configuration page. No dialog
popped up so I didn't see exactly when it happened, and now it's
happening all the time when I'm looking at various source files and
using F2 to move to the next warning.

0
Comment actions Permalink

Aw, hell. Well, I see what they broke, and I see how to fix it, but it's gonna be at least until Friday (more likely Sunday) until I can get out 0.0.3 (which will have a few other goodies as well). Until then, you can either yank InspectionGadgets.jar, or turn off the 11 inspections that depend on the call that broke. These include:

"Exception name doesn't end with Exception"
"Non-Exception class name ends with Exception"
"Checked Exception class"
"Unchecked Exception class"
"Thread.run"
"Ignore result of InputStream.read()"
and all 5 of the JUnit inspections.

Sorry I can't be more help.

0

Please sign in to leave a comment.