Announcing InspectionGadgets version 1.0


Announcing version 1.0 of the InspectionGadgets plugin, available via the PluginManageror at http://www.intellij.org/twiki/bin/view/Main/InspectionGadgets.

Changes in version 1.0

New inspections:

  • Infinite Recursion

  • Auto-Boxing

  • Auto-Unboxing

  • Unnecessary boxing

  • Unnecessary unboxing

  • Class without no-arg constructor

  • Unnecessary 'final' for method parameter

  • Unnecessarily qualified static method call

  • Unqualified static method call

  • setUp() with incorrect signature

  • tearDown() with incorrect signature

  • setUp() doesn't call super.setUp()

  • tearDown() doesn't call super.tearDown()

  • Test method with incorrect signature

  • 'assert' statement

  • Use of 'enum' as identifier

  • Use of '$' in identifier


plus huge numbers of bugfixes.

Special thanks go to Bas Leijdekkers and Keith Lea for their assistance on this release.

With the 1.0 release, development on InspectionGadgets will be going into "bugfixes-only" mode for the next several months. Thanks to everyone for your ideas, code, and criticism as I developed InspectionGadgets. It's thanks to your interest and support that InspectionGadgets has become the most full-featured and powerful Java static analysis tool available today, and the most-downloaded IDEA plugin. Most especial thanks to JetBrains in general and Maxim Shafirov in particular, for giving me this marvelous platform to build on.

I hope I've helped you kill a lot of bugs.

--Dave Griffith

31 comments

This plugin is really a killer plugin. It's the only plugin I use currently and I cannot imagine not using it anymore. :thumbsup:

0

Thanks a lot Dave for this amazing stuff.
Small bugreport though against Pointless Arithmetic Expression:

int x = 2;
int y = 2;
if (x < y - 1) {

}

Reports (y-1) can be replaced with y which is obviously not true.

--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Dave Griffith wrote:

Unchecking "include constants" in "class field count" doesn't work. One still reports 11 instead of 9 for this code:
private static final Icon EMPTY_ICON = new EmptyIcon(16, 16);
private static final String[] EMPTY_STRINGS_ARRAY = new String[0];

private JButton myRemoveActionButton;
private JButton myIncludeActionButton;
private JButton myMoveActionDownButton;
private JButton myMoveActionUpButton;
private JPanel myPanel;
private JTree myActionsTree;
private JList myActionsList;
private JTextField myDisplayName;
private JTextField myDescription;


--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0


The Icon isn't counted as a constant, as Icon is a modifiable class. Same with the String array, although I should probably put int special logic for shared empty arrays.

--Dave Griffith

0

Can't reproduce this, I'm afraid, and it's pretty clear from the code that that shouldn't happen. Did you just change the "-", maybe from a "*" or "/"?

--Dave Griffith

0

Dave Griffith wrote:

Can't reproduce this, I'm afraid, and it's pretty clear from the code that that shouldn't happen. Did you just change the "-", maybe from a "*" or "/"?

--

Dave Griffith

Nope... Just installed 1.0 version, checked on some inspections and saw this immediately on the file being opened. No
modifications were taken on that file at all since IDEA start.

--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

There's an issue of reconfiguring the IG again with every new build installation - is there any way I can keep all settings from both "Setting -> Error" and "Tools -> Inspect Code" intact ? Does backing up C:/Documents and Settings/]]>/.IntelliJIdea/config preserves them ?

Thank you !

0


This is an issue for JetBrains, rather than me, as they control all of that. What I do is be sure to copy over my plugins directory before launching the new build. That seems to work at least 9 times out out 10. Sorry I can't do better.

--Dave Griffith

0

to copy over my plugins directory before launching the
new build


You mean the "]]>/plugins" folders ? Out of curosity - how does it work then, do you store IG settings inside InspectionGadgets.jar somehow ?

Sorry I can't do better.


We all forgive you :) You've done more than enough already.

0

You mean the "<IDEA>/plugins" folders ? Out of curosity - how does it work
then, do you store IG settings inside InspectionGadgets.jar somehow ?


It's a problem with all plugins, AFAIK.
IDEA deletes the plugin settings stored in its project/module/workspace
files for all the plugins that are not installed when it starts.

So, if you want to preserve plugin settings between installations, be sure
you don't start IDEA without the plugins being in the IDEA/plugins
directory (note that IDEA deletes the custom plugins from that directory
when it installs over an existing version).

Right after installation, before starting IDEA for the first time, copy the
plugins from a backup directory (or another installation directory) rather
than relying on the plugin manager to get them. This way IDEA will leave
the settings in place.

HTH,
Andrei

0

IDEA deletes the plugin settings stored in its
project/module/workspace
files for all the plugins that are not installed when
it starts.


Ok, now I've finally got it. Thank's a lot !

0

Small bugreport though against Pointless Arithmetic
Expression:

int x = 2;
int y = 2;
if (x < y - 1) {

}

Reports (y-1) can be replaced with y which is
obviously not true.


It's Monday morning, so forgive if my brain hasn't
kicked into gear, but that sounds fine given the
code excerpt. 2 < 2 is false, 2 < 1 is false. So,
x < y - 1 is the same as x < y. (Of course, if there
is intervening code between x and y declarations and
the if statement then this may not hold.)

Looks like a pointless arithmetic expression to me.

0

True, but not the sort the inspection was supposed to catch. The built-in IDEA inspection for "Constant conditions and expressions" should, but the "Pointless arithmetic expressions shouldn't.

--Dave Griffith

0

I get warning on following method:

public void visitStaffPositions(OrgWalker visitor) {
OrgPosition[] staff = getImmediateStaffPositions();
for (int i = 0; i < staff.length; i++) {
boolean seeKids = visitor.visit(staff+);
if (seeKids) {
staff+.visitStaffPositions(visitor);
}
}
}

I am sure there are not any exceptions thrown, so it must be something wrong with the inspection.

I get this warning for a lot of correct looping methods.

0

Why are you looping over all elements of the staff array, only to use the array in its entirety on every iteration?

I don't know the rest of your code, but shouldn't the 4th line be something like

?

dunno if that's what InspectionGadgets was complaining about, but LukeGadgets did raise a warning on that one ;)

0

Sorry, this time the forums filtering of characters broken my code - if you look at previous example you can see it went with italics form some point.
Thank you for indicating it.

code once again, hope it is ok this time:
public void visitStaffPositions(OrgWalker visitor) {
OrgPosition[] staff = getImmediateStaffPositions();
for (int i = 0; i < staff.length; i++) {
boolean seeKids = visitor.visit(staff );
if (seeKids) {
staff[ i ].visitStaffPositions(visitor);
}
}
}

0

Thanks for a great plugin!

Bug when using "Unnecessary fully qualified name" quick fix.

Even though the quick fix works properly, it seem that it alters the PSI in an incorrect way making IDEA believe that the program is incorrect. The follwing status message occurs:

Incompatible types. Found 'java.net.MalformedURLException[]', required: 'java.lang.throwable'

Example program:


Regards
Anders Janmyr

0

Dave, I would just like to say that IG is without a doubt the best plugin for IDEA that I've seen so far. Excellent work and congrats on your first release build. Assuming you are still working on the Intention Power Pack, do you have any idea how long before that also progresses to release build (1.0)?

0


Thanks, glad you like it. It was quite fun to do.

On the subject of Intention Power Pack 1.0, it seems unlikely that it will be within the next month. There are no pressing issues on IPP, and no features I'm hot to implement. There are a handful of small fixes and polishes I'd like to make, but the effort that would go into implementing and QA'ing them is currently going into my next plugin instead. That plugin is an industrial-strength code-metrics suite. It acheived it's first visible output last night, and will go beta by the end of March, assuming my rudimentary Swing skills improve to the point where you guys won't laugh at my panels.

--Dave Griffith

0

Dave Griffith wrote:

That plugin is an industrial-strength code-metrics suite. It acheived it's first visible output last night, and will go beta by the end of March, assuming my rudimentary Swing skills improve to the point where you guys won't laugh at my panels.


Dave,

if you need any help with the Swing side of it (or any other part), please
let me know. I'd be happy to help & I'm sure plenty of others on this group
would be too.

Vil.
--
Vilya Harvey
vilya.harvey@digitalsteps.com / digital steps /
(W) +44 (0)1483 469 480
(M) +44 (0)7816 678 457 http://www.digitalsteps.com/

0

That plugin is an industrial-strength code-metrics suite.


What kinds of metrics does it gather? Any well-known metrics or some custom metrics?

--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"



0

Ditto :)

N.

Vilya Harvey wrote:

Dave Griffith wrote:

>> That plugin is an industrial-strength code-metrics suite. It acheived
>> it's first visible output last night, and will go beta by the end of
>> March, assuming my rudimentary Swing skills improve to the point where
>> you guys won't laugh at my panels.


Dave,

if you need any help with the Swing side of it (or any other part),
please let me know. I'd be happy to help & I'm sure plenty of others on
this group would be too.

Vil.

0

Like InspectionGadgets, the basic plan is to scour the existing products in the space for metrics to implement, and then copy 'em. This is workable since I've built a pluggablility layer, much like the InspectionsAPI. That makes the incremental cost of building a metric (or inspection) is so low that there's no reason not to throw one in if it looks interesting and well-defined. If you've got any pointers or ideas for metrics you'd like to see

Oh, and as of last night, the plugins got a name (thanks to my wife). Keep your eyes peeled for MetricsReloaded...

--Dave Griffith

0

lol nice one!

Dave Griffith wrote:

Like InspectionGadgets, the basic plan is to scour the existing products in the space for metrics to implement, and then copy 'em. This is workable since I've built a pluggablility layer, much like the InspectionsAPI. That makes the incremental cost of building a metric (or inspection) is so low that there's no reason not to throw one in if it looks interesting and well-defined. If you've got any pointers or ideas for metrics you'd like to see

Oh, and as of last night, the plugins got a name (thanks to my wife). Keep your eyes peeled for MetricsReloaded...

--Dave Griffith

0

Keep your eyes peeled for MetricsReloaded...


Damn cool! ROFL

Tom

0

Yes, I've always been bitten by this bug :(

0

Some ideas:

Number of Law of Demeter violations?
How many classes does this class call (average dependency?)
How many classes does this method call
How many classes call this class
Number of instance variables
Number of methods
Number of classes in a package
Number of inheritance levels
Some way of measuring packages interface (how many methods of how many classes are called outside the package)
Are the instance variables of the class used by most of the methods in the class (either directly or via getters/setters): if not perhaps the class should be split. Lack of cohesion of methods?
Weighted methods per class (sum of the complexities of methods in the class...) (should not include inherited methods...)
Coupling between objects? Cohesiveness?
Number of child classes
Size of the class when populated
Size of the method call parameters

0


Except for LOD violations, all of these are planned for inclusion in MetricsReloaded 0.1. Indeed, my internal build already has about two-thirds of them working, including tabular and graphical display.

--Dave Griffith

0

In article <7316236.1078733012155.JavaMail.itn@is.intellij.net>,
Dave Griffith <dave.griffith@cnn.com> wrote:

Except for LOD violations, all of these are planned for inclusion in
MetricsReloaded 0.1. Indeed, my internal build already has about two-thirds
of them working, including tabular and graphical display.


Damn, you are fast.

Have you taken a look at some of the dashboard graphics in Together? I
suspect they might have some nice gui goodies to consider, like the
dashboard view showing the metric status across the project.
(Personally, tabular is the most useful for me, followed by a pie or
line chart by class/package. High-low by package is kind of
interesting, but can be easily produced by Excel given tabular output.)

I am impressed - you only mentioned starting on this a few weeks ago -
wow.

Scott

0


>Damn, you are fast.

Naw, that was just a bit of swank because I was feeling good about the output side. On the input side, my metrics selection panel is a worthless piece of junk, persistence of metrics profiles is a big question mark, and I'm damned if I can figure out how to get IDEA to show a progress panel while metrics are being calculated. Between those and real work, don't expect anything before the end of the month.

(On the plus side, I will ship with difference overlay mode, where you can easily compare your current metrics results with a previous run, either tabular or graphic.)

>Have you taken a look at some of the dashboard graphics in Together? I suspect they might have some nice gui goodies to consider, like the dashboard view showing the metric status across the project.

Together has easily the most polished UI in this space, and I'll certainly be looking to learn from it. No promises beyond that for what will be in the first rev.

--Dave Griffith

0

Please sign in to leave a comment.