开发者

does checkstyle for java propose modifications?

I'm using checkstyle within eclipse and when I activate it, the tool shows message about naming conventions and doesn't make proposals which should be very practical.

does this functionality exist ? how could I us开发者_运维知识库e it ? thanks


Java naming conventions are pretty easy to detect, to remember and to apply. A validator can detect violations but can't propose the correct name (in general) as this may depend on semantics. And: once you know the conventions, you immediatly realise the problem and see a "correct" alternative.

Examples:

int Person = null;  // should be person

class my_mouse_listener {   // should be MyMouseListener

private static int red = 1;  // should be RED

private String SUPERUSERPASSWORD = "secret";  // could be superuserPassword
                                              // -> good proposal impossible as
                                              // sUPERUSERPASSWORD would be 
                                              // valid too


Checkstyle does not propose the 'correct' name. The configuration for checkstyle is just a regular expression, so you can't say 'how do I transform the name so that it it will fit in with the regular expression'.

You can however add a personalised message for each type of error raised, so that you can suggest a better name, or give examples. Look in Window->Preferences->Checkstyle.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜