Empty line check

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Empty line check

mgryszko
Hi,

As far I know from the documentation there is no check that checks if there is more than 1 empty line in a method or class definition.

Has anybody already wrote such a check? I'd like to include it in a project I'm currently in; I hate seeing 6-8 empty lines just because somebody doesn't bothet to write clean code.

Best,

Marcin
Reply | Threaded
Open this post in threaded view
|

Re: Empty line check

Lars Kühne-3
On Fri, Feb 6, 2009 at 12:57 PM, mgryszko wrote:

Hi,

As far I know from the documentation there is no check that checks if there
is more than 1 empty line in a method or class definition.

Has anybody already wrote such a check? I'd like to include it in a project
I'm currently in; I hate seeing 6-8 empty lines just because somebody
doesn't bothet to write clean code.

Best,

Marcin

Correct, there is no such check in the checkstyle distribution. I assume you mean more then 1 *consecutive* empty line? Anyway, if no one has this check already, this is super-easy to write as a FileSetCheck:
http://checkstyle.sourceforge.net/writingchecks.html#Writing%20FileSetChecks.

Cheers,
Lars

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Checkstyle-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user
Reply | Threaded
Open this post in threaded view
|

Re: Empty line check

mgryszko
Exactly, I mean one or more consecutive lines. Is there a way to differentiate between methods and e.g. class members? AbstractFileSetCheck gets a File array as input.

Marcin

Lars Kühne-3 wrote
On Fri, Feb 6, 2009 at 12:57 PM, mgryszko wrote:

>
> Hi,
>
> As far I know from the documentation there is no check that checks if there
> is more than 1 empty line in a method or class definition.
>
> Has anybody already wrote such a check? I'd like to include it in a project
> I'm currently in; I hate seeing 6-8 empty lines just because somebody
> doesn't bothet to write clean code.
>
> Best,
>
> Marcin
>

Correct, there is no such check in the checkstyle distribution. I assume you
mean more then 1 *consecutive* empty line? Anyway, if no one has this check
already, this is super-easy to write as a FileSetCheck:
http://checkstyle.sourceforge.net/writingchecks.html#Writing%20FileSetChecks
.

Cheers,
Lars

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Checkstyle-user mailing list
Checkstyle-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/checkstyle-user
Reply | Threaded
Open this post in threaded view
|

Re: Empty line check

Lars Kühne-3


On Fri, Feb 6, 2009 at 8:32 PM, mgryszko <[hidden email]> wrote:

Exactly, I mean one or more consecutive lines. Is there a way to
differentiate between methods and e.g. class members? AbstractFileSetCheck
gets a File array as input.

Marcin

If you need to account for the java syntax structure, FileSetCheck won't cut it - you'll need to implment a Check then. This makes things a bit more complicated, but still relatively easy. You can then register your check for the node types that are interesting for you, like METHOD_DEF. Have a look at checkstyle's MethodLengthCheck code for a simple example.

Cheers,
Lars

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Checkstyle-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user