#103 More Unused checks!

release_3.3
closed
Check (274)
7
2012-10-10
2002-09-15
No

Please add checks for

  1. Unused private methods in a class
  2. Unused local variables

thanks
Vivek

Discussion

  • Oliver Burn

    Oliver Burn - 2003-02-02

    Logged In: YES
    user_id=218824

    I agree

     
  • Tim Tyler

    Tim Tyler - 2003-06-09

    Logged In: YES
    user_id=796025

    Eclipse's compiler already does both of these.

    If you use checkstyle within Eclipse this doesn't seem
    so important.

    What /would/ be useful is project-wide checks for unused
    methods/field - like RefactorIT has. However, that is
    clearly a significantly bigger job.

     
  • Rick Giles

    Rick Giles - 2003-06-09

    Logged In: YES
    user_id=539926

    Just a note so that we don't duplicate effort - I am
    currently working on these kinds of checks, including
    project-wide ones.

     
  • Tim Tyler

    Tim Tyler - 2003-06-10

    Logged In: YES
    user_id=796025

    In which case, perhaps I should mention another feature
    in RefactorIT - which I would love to use from within Eclipse.

    Often I want to "minimise access restrictions".

    I.e. if a "public" method is only used in the class where it
    is defined, I often want to make it "private" - and if it's
    only used in the same package I'll often want to make it
    "protected".

    RefactorIT detects such cases - and lets you minimise the
    access restrictions by automatically changing the code.

    Code modification might be a bit beyond Checkstyle's
    current scope - but nontheless, simply identifying cases
    where encapsulation could potentially be improved by
    further restricting access would still be very helpful.

     
  • Dale King

    Dale King - 2003-06-10

    Logged In: YES
    user_id=130378

    That would be nice, Tim, but is not easily doable with
    Checkstyle's model of operation. Checkstyle for the most part
    looks only at the current file by itself. It does not know
    anything about the information in other files while it is
    examining the current file. The only exception I know about
    is the check for thrown exceptions where it uses reflection to
    know if an exception is a checked exception or not.

    You are better off submitting that as an Eclipse feature
    request.

     
  • Tim Tyler

    Tim Tyler - 2003-06-11

    Logged In: YES
    user_id=796025

    Rick just said he was working on "project-wide"
    checks for unused methods/fields.

    Clearly he's going to have to be using a FileSetCheck to do
    this - in which case what I was describing would
    be more of the same.

    It /could/ go into Eclipse - but then only Eclipse users
    would benefit (at least while Eclipse's compiler is not
    available as a stand-alone product).

     
  • Oleg Sukhodolsky

    Logged In: YES
    user_id=746148

    I think we should close this RFE as implemented since we
    have checks for unused provate methods and local variables.
    If we want to have checks Tim described we should file a new
    RFE. IMHO it would be easier to work with, because you will
    not have to read all comments to find out what do we want
    now in this RFE.

     
  • Rick Giles

    Rick Giles - 2003-12-23

    Logged In: YES
    user_id=539926

    +1

     
  • Oleg Sukhodolsky

    Logged In: YES
    user_id=746148

    Close this rfe as implemented, because we already have
    checks which were originally requested.
    If you need more unused checks, please file separate rfes
    about them.

     
  • Benjamin POCHAT

    Benjamin POCHAT - 2008-02-08

    Logged In: YES
    user_id=1855304
    Originator: NO

    I'm sorry o_sukhodolsky, but I tried to find the checks originally requested by Vivek by reading checkstyle manual again and again (http://checkstyle.sourceforge.net/availablechecks.html) : I could not find these checks !

    Would the documentation be no up to date ?

     
  • Oliver Burn

    Oliver Burn - 2008-02-08

    Logged In: YES
    user_id=218824
    Originator: NO

    A decision was made a while back to remove these types of usage checks. The reason is that the Checkstyle architecture is not suited to these sorts of checks. I'd recommend you look at FindBugs or PMD for these types of checks.

     
  • Benjamin POCHAT

    Benjamin POCHAT - 2008-02-11

    Logged In: YES
    user_id=1855304
    Originator: NO

    That's regrettable.
    I use CheckStyle with Maven wich generates a weekly report. I just try to get rid of PMD because the developers in my team don't want to ckeck several reports. Having one single plugin is nice because every warning is presented into one single report.

    I found CheckStyle was better than PMD because it seemed to be the most complete : for instance, it includes the copy/paste detection...

    I think the only thing I have to do now is looking for a plugin that generates one single homogeneous report including warnings from both CheckStyle and PMD.

     

Log in to post a comment.