[ANN] InspectionGadgets 0.0.4 released


Announcing InspectionGadgets version 0.0.4, available at
http://www.intellij.org/twiki/bin/view/Main/InspectionGadgets

Changes in 0.0.4

New Inspections



Let me know if there are in problems. I intend this to be the last release of InspectionGadgets for a while, but that's what I said last release, and I've still got a list of about 30 inspections I'd like to see, so who knows.

--Dave "Well I was on hiatus, but the staff meetings were so dull, and the laptop was just sitting there" Griffith

6 comments
Comment actions Permalink

Hey nice one!

Some comments:

Overloaded methods with the same number of parameters

I appear to get this warning with every method in my class whether or
not it's overloaded!

Accessing an instance variable more than 2 times in a method

The algorithm should take into account only access, not modification,
but it seems to be counting both. Also, it also counts static constants
- is the same optimization rationale applicable to those too?

Cheers,
Nathan.

0
Comment actions Permalink

Looking at it, and some more ideas:

Visibility issues -> Parameter hides member variable:

-> New option: "Ignore overriding parameter with same name"


When overriding a constructor/method from a superclass, I like to leave
parameters with the same name they have in the super constructor/method -
this simplifies both the javadoc and the implementation.

The problem is that third party libraries many times have parameters equal
to member names. This makes me either have a bunch of yellow markers or
rename the new method parameters :(



Also:

class TestComboBoxModel extends DefaultComboBoxModel {
public TestComboBoxModel(final Vector v) {
super(v);
}
}

-> Warning: Declaration of Vector should probably be weakened to list.


Carlos


0
Comment actions Permalink

I'm also getting warnings for static inner class fields which 'hide'
outer class fields, although they don't really hide them as they aren't
accessible anyway.

Dave Griffith wrote:

Announcing InspectionGadgets version 0.0.4, available at
http://www.intellij.org/twiki/bin/view/Main/InspectionGadgets

Changes in 0.0.4

New Inspections

Overloaded methods with the same number of parameters > Overly broad catch clauses > Accessing an instance variable more than 2 times in a method > Package Import > Unnecessary import from current package > Unnecessary import from java.lang > Nested try statements > Multiple variables in a single declaration > Multiple types of variables in a declaration > Standard variable names for simple types (i, j, k should be "int"; c and ch should be "char", etc.) > Static inheritance (i.e. implementing an interface containing only constants) > Classes without .toString() > Public inner classes > Package-visible inner classes > Protected inner classes > startsWith() or endsWith() with single character argumnet > ThreadDeath caught but not rethrown > Error or it's subclasses caught but not rethrown > Constants defined in an interface > Constants defined in an abstract class > Chained equality tests > Non-final static fields > Transient field in non-Serializable class > > Significant performance improvements > Bugfixes]]>

Let me know if there are in problems. I intend this to be the last release of InspectionGadgets for a while, but that's what I said last release, and I've still got a list of about 30 inspections I'd like to see, so who knows.

--Dave "Well I was on hiatus, but the staff meetings were so dull, and the laptop was just sitting there" Griffith


0
Comment actions Permalink

first, great plugin, thanks a lot.

I have the following exception, if I switch on the
"Return of collection or array field" inspection and run the Inspecions explicitly:

2003-09-11 11:16:46,514 ERROR - pection.ex.InspectionManagerEx - IntelliJ IDEA (Aurora) Build #922
2003-09-11 11:16:46,514 ERROR - pection.ex.InspectionManagerEx - JDK: 1.4.2
2003-09-11 11:16:46,514 ERROR - pection.ex.InspectionManagerEx - VM: Java HotSpot(TM) Client VM
2003-09-11 11:16:46,514 ERROR - pection.ex.InspectionManagerEx - Vendor: Sun Microsystems Inc.
2003-09-11 11:16:46,514 ERROR - pection.ex.InspectionManagerEx - OS: Windows 2000
2003-09-11 11:16:46,514 ERROR - pection.ex.InspectionManagerEx - Last Action: InspectCode
2003-09-11 11:16:46,544 ERROR - pection.ex.InspectionManagerEx -
java.lang.ClassCastException
at com.siyeh.ig.encapsulation.ReturnOfCollectionFieldInspection.buildErrorString(ReturnOfCollectionFieldInspection.java:33)
at com.siyeh.ig.BaseInspectionVisitor.registerError(BaseInspectionVisitor.java:45)
at com.siyeh.ig.encapsulation.ReturnOfCollectionFieldInspection$ReturnOfCollectionFieldVisitor.visitReturnStatement(ReturnOfCollectionFieldInspection.java:69)
at com.intellij.psi.impl.source.e.a.bj.accept(bj.java:11)
at com.intellij.psi.impl.source.e.u.acceptChildren(u.java:9)
at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java:2)
at com.intellij.psi.JavaElementVisitor.visitCodeBlock(JavaElementVisitor.java:72)
at com.intellij.psi.impl.source.e.a.bt.accept(bt.java:6)
at com.intellij.psi.impl.source.e.u.acceptChildren(u.java:9)
at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java:2)
at com.intellij.psi.JavaElementVisitor.visitStatement(JavaElementVisitor.java:81)
at com.intellij.psi.JavaElementVisitor.visitBlockStatement(JavaElementVisitor.java:165)
at com.intellij.psi.impl.source.e.a.i.accept(i.java:14)
at com.intellij.psi.impl.source.e.u.acceptChildren(u.java:9)
at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java:2)
at com.intellij.psi.JavaElementVisitor.visitStatement(JavaElementVisitor.java:81)
at com.intellij.psi.JavaElementVisitor.visitIfStatement(JavaElementVisitor.java:119)
at com.intellij.psi.impl.source.e.a.v.accept(v.java:24)
at com.intellij.psi.impl.source.e.u.acceptChildren(u.java:9)
at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java:2)
at com.intellij.psi.JavaElementVisitor.visitCodeBlock(JavaElementVisitor.java:72)
at com.intellij.psi.impl.source.e.a.bt.accept(bt.java:6)
at com.intellij.psi.impl.source.bg.acceptChildren(bg.java:86)
at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java:2)
at com.intellij.psi.JavaElementVisitor.visitMethod(JavaElementVisitor.java:168)
at com.intellij.psi.impl.source.bt.accept(bt.java:76)
at com.siyeh.ig.ExpressionInspection.checkMethod(ExpressionInspection.java:45)
at com.intellij.codeInspection.n.ca.visitMethod(ca.java:8)
at com.intellij.psi.impl.source.bt.accept(bt.java:76)
at com.intellij.psi.impl.source.bg.acceptChildren(bg.java:86)
at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java:2)
at com.intellij.psi.JavaElementVisitor.visitClass(JavaElementVisitor.java:170)
at com.intellij.codeInspection.n.ca.visitClass(ca.java:6)
at com.intellij.psi.impl.source.bj.accept(bj.java:170)
at com.intellij.psi.impl.source.bg.acceptChildren(bg.java:86)
at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java:2)
at com.intellij.psi.JavaElementVisitor.visitFile(JavaElementVisitor.java:133)
at com.intellij.psi.JavaElementVisitor.visitJavaFile(JavaElementVisitor.java:23)
at com.intellij.psi.impl.source.bq.accept(bq.java:167)
at com.intellij.codeInspection.n.be.a(be.java:19)
at com.intellij.codeInspection.n.bz.visitJavaFile(bz.java:3)
at com.intellij.psi.impl.source.bq.accept(bq.java:167)
at com.intellij.codeInspection.n.bb.processFile(bb.java:1)
at com.intellij.openapi.roots.a.m.a(m.java:6)
at com.intellij.openapi.roots.a.m.a(m.java:1)
at com.intellij.openapi.roots.a.m.a(m.java:1)
at com.intellij.openapi.roots.a.m.a(m.java:1)
at com.intellij.openapi.roots.a.m.a(m.java:1)
at com.intellij.openapi.roots.a.m.a(m.java:1)
at com.intellij.openapi.roots.a.m.a(m.java:1)
at com.intellij.openapi.roots.a.bd.iterateContent(bd.java:13)
at com.intellij.codeInspection.n.ba.a(ba.java:3)
at com.intellij.codeInspection.n.bn.a(bn.java:281)
at com.intellij.codeInspection.n.bn.a(bn.java:103)
at com.intellij.codeInspection.n.j.run(j.java:1)
at com.intellij.openapi.application.a.d.runReadAction(d.java:181)
at com.intellij.codeInspection.n.bn.c(bn.java:109)
at com.intellij.codeInspection.n.bn.c(bn.java:244)
at com.intellij.codeInspection.n.h.run(h.java)
at com.intellij.progress.c.a(c.java:36)
at com.intellij.progress.a.i.b(i.java:12)
at com.intellij.progress.a.i.b(i.java:20)
at com.intellij.progress.a.i.c(i.java:28)
at com.intellij.progress.a.u.run(u.java:1)


Thanks
thomas

0
Comment actions Permalink

In the following class I get a warning that foo may not be initialized
during object construction. It is, but you need to follow the this()
call to determine this.

package test;
/* Initially created by Jonas Kvarnström at 2003-sep-13 00:43:17 */
public class TestConstructorInit
{
final int foo;
TestConstructorInit(final int foo) { this.foo = foo; }
TestConstructorInit() { this(1); }
}

0
Comment actions Permalink

Exception in a syntactically incorrect class (cutting and pasting a lot):

java.lang.NullPointerException
at
com.siyeh.ig.psiutils.CollectionUtils.isArrayOrCollectionField(CollectionUtils.java:139)
at
com.siyeh.ig.encapsulation.AssignmentToCollectionFieldFromParameterInspection$AssignmentToCollectionFieldFromParameterVisitor.visitAssignmentExpression(AssignmentToCollectionFieldFromParameterInspection.java:77)
at com.intellij.psi.impl.source.c.a.g.accept(g.java:22)
at com.intellij.psi.impl.source.c.u.acceptChildren(u.java:47)
at
com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java)
at
com.intellij.psi.JavaElementVisitor.visitStatement(JavaElementVisitor.java:176)
at
com.intellij.psi.JavaElementVisitor.visitExpressionStatement(JavaElementVisitor.java:141)
at com.intellij.psi.impl.source.c.a.t.accept(t.java:5)
at com.intellij.psi.impl.source.c.u.acceptChildren(u.java:47)
at
com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java)
at
com.intellij.psi.JavaElementVisitor.visitCodeBlock(JavaElementVisitor.java:76)
at com.intellij.psi.impl.source.c.a.bt.accept(bt.java:13)
at com.intellij.psi.impl.source.bg.acceptChildren(bg.java:15)
at
com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java)
at
com.intellij.psi.JavaElementVisitor.visitMethod(JavaElementVisitor.java:82)
at com.intellij.psi.impl.source.bt.accept(bt.java:102)
at
com.siyeh.ig.ExpressionInspection.checkMethod(ExpressionInspection.java:45)
at com.intellij.codeInsight.f.a.bu.a(bu.java:12)
at com.intellij.codeInsight.f.a.cl.run(cl.java:10)
at com.intellij.openapi.application.a.d.runReadAction(d.java:8)
at com.intellij.codeInsight.f.a.cy.a(cy.java:19)
at com.intellij.codeInsight.f.a.cy.b(cy.java:22)
at com.intellij.codeInsight.f.a.ck.run(ck.java:0)
at com.intellij.progress.c.a(c.java:31)
at com.intellij.codeInsight.f.a.cy.run(cy.java:35)

0

Please sign in to leave a comment.