[ checkstyle-Feature Requests-934551 ] indentation - support extra indent for throws clause

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[ checkstyle-Feature Requests-934551 ] indentation - support extra indent for throws clause

SourceForge.net
Feature Requests item #934551, was opened at 2004-04-13 15:00
Message generated for change (Comment added) made by
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=397081&aid=934551&group_id=29721

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Priority: 5
Private: No
Submitted By: Mike Perham (mperham)
Assigned to: Nobody/Anonymous (nobody)
Summary: indentation - support extra indent for throws clause

Initial Comment:
It's pretty standard for a method to have a throws
clause on the next line indented two levels to
differentiate it from the method body:

public static void foo()
        throws RemoteException {

    for (int i = 0; i < 10; i++) {
        doSomething();
    }
}

However the Indentation check forces the throws to line
up with the method body.  I would like another config
parameter like the current 3 that would allow for
deeper nesting of the throws clause.

----------------------------------------------------------------------

Comment By: Matt Swift ()
Date: 2012-04-17 02:44

Message:
Here's the examples again with hyphens instead of spaces to highlight the
indentation, since Sourceforge seems to strip whitespace.

// This is not allowed - the Checkstyle complains that "throws Exception"
should be indented only 4 chars.
public void foo()
--------throws Exception {
----// Method body
}

// This is what Checkstyle wants:
public void foo()
----throws Exception {
----// Method body
}

// But Checkstyle accepts this, which seems contradictory, a bug?
public void foo() throws
--------Exception {
----// Method body
}


----------------------------------------------------------------------

Comment By: Matt Swift ()
Date: 2012-04-17 02:37

Message:
This is hitting us too.

The Checkstyle indentation checker seems to work pretty well overall,
especially with Sun conventions, with this one exception:

public void foo()
        throws Exception {
    // Method body
}

Fails with "method def throws at indentation level 16 not at correct
indentation, 12". Obviously I don't want to have the "throws Exception"
part of the declaration with the same indentation as the method body
because it will make the code harder to read - the throws will look like
the first line of the method.

The only workaround I have found is to put the throws on the same line as
the method parameters and the exception on the new line, but that's ugly
too:

public void foo() throws
        Exception {
    // Method body
}

The workaround implies that this is a bug in Checkstyle's indentation
engine. Why would it be happy for "Exception" to be indented twice but
"throws Exception" only once?


----------------------------------------------------------------------

Comment By: Nicholas T. Daley (ntdaley)
Date: 2006-05-10 20:28

Message:
Logged In: YES
user_id=853820

Oops, ignore the pre and code tags, I assumed the comment field took html
tags.

----------------------------------------------------------------------

Comment By: Nicholas T. Daley (ntdaley)
Date: 2006-05-10 20:27

Message:
Logged In: YES
user_id=853820

It should also allow less indent than the method body.
I prefer to have the throws clause starting at the same column as the line

above it, and the method body indented by 4.

e.g.
<code><pre>
public static void foo()
throws RemoteException {
    doSomething();
}
</pre></code>

as opposed to
<code><pre>
public static void foo()
        throws RemoteException {
    doSomething();
}
</pre></code>
which is suggested above, or
<code><pre>
public static void foo()
    throws RemoteException {
    doSomething();
}
</pre></code>
which is what checkstyle currently requires.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=397081&aid=934551&group_id=29721

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Checkstyle-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-devel
Loading...