harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tony Wu" <wuyue...@gmail.com>
Subject Re: [classlib][tests] Junit best practice
Date Mon, 30 Oct 2006 02:33:38 GMT
Harmony-1997 raised :)
https://issues.apache.org/jira/browse/HARMONY-1997

On 10/27/06, Geir Magnusson Jr. <geir@pobox.com> wrote:
> can you put this into a JIRA, and maybe some docs, so we can put in SVN
> as a tool for others to use w/ docs on the website?
>
> geir
>
> Tony Wu wrote:
> > the configure file of CheckStyle in attachment, you can import it to
> > your eclipse plugin
> >
> > On 10/27/06, Tony Wu <wuyuehao@gmail.com> wrote:
> >> On 10/26/06, Mark Hindess <mark.hindess@googlemail.com> wrote:
> >> >
> >> > On 26 October 2006 at 19:16, "Tony Wu" <wuyuehao@gmail.com> wrote:
> >> > > I have scratched out the stand alone rules,
> >> > >
> >> > > should use assertNull,
> >> assertEquals\s*\((.*,\s*null\s*|\s*null\s*,.*)\)\s*;
> >> > > should use assertFalse,
> >> assertEquals\s*\((.*,\s*false\s*|\s*false\s*,.*)\)\s*
> >> > > ;
> >> > > should use assertTrue,
> >> assertEquals\s*\((.*,\s*true\s*|\s*true\s*,.*)\)\s*;
> >> > > last argument should not be a constant,
> >> > >
> >> assertEquals\s*\(.*,\s*("[^"]*"|'[^']'|[+-]?\d+[0-9a-fA-FLlPp]*|[A-Z_]*)\s*\)
> >>
> >> > > \s*;
> >> > > always true/false, assert(False|True)\s*\(\s*(false|true)\s*\)\s*;
> >> > > multiple assertion, assertTrue\s*\(.*\&\&.*\)\s*;
> >> > > multiple assertion, assertFalse\s*\(.*\|\|.*\)\s*;
> >> > > should use assertNull,
> >> assertTrue\s*\((.*==\s*null\s*|\s*null\s*==.*)\)\s*;
> >> > > should use assertTrue,
> >> assertTrue\s*\((.*==\s*true\s*|\s*true\s*==.*)\)\s*;
> >> > > should use assertFalse,
> >> assertTrue\s*\((.*==\s*false\s*|\s*false\s*==.*)\)\s*
> >> > > ;
> >> > > should use assertNotNull,
> >> assertTrue\s*\((.*!=\s*null\s*|\s*null\s*!=.*)\)\s*
> >> > > ;
> >> > > should use assertFalse,
> >> assertTrue\s*\((.*!=\s*true\s*|\s*true\s*!=.*)\)\s*;
> >> > > should use assertTrue,
> >> assertTrue\s*\((.*!=\s*false\s*|\s*false\s*!=.*)\)\s*;
> >> > > should use assertFalse, assertTrue\s*\(\s*!.*\)\s*;
> >> > > should use assertFalse, assertTrue\s*\("[^"]*"\s*,\s*!.*\)\s*;
> >> > > should use assertNotNull,
> >> assertFalse\s*\((.*==\s*null\s*|\s*null\s*==.*)\)\s
> >> > > *;
> >> > > should use assertFalse,
> >> assertFalse\s*\((.*!=\s*true\s*|\s*true\s*!=.*)\)\s*;
> >> > > should use assertTrue,
> >> assertFalse\s*\((.*!=\s*false\s*|\s*false\s*!=.*)\)\s*
> >> > > ;
> >> > > should use assertNull,
> >> assertFalse\s*\((.*!=\s*null\s*|\s*null\s*!=.*)\)\s*;
> >> > > should use assertFalse,
> >> assertFalse\s*\((.*==\s*true\s*|\s*true\s*==.*)\)\s*;
> >> > > should use assertTrue,
> >> assertFalse\s*\((.*==\s*false\s*|\s*false\s*==.*)\)\s*
> >> > > ;
> >> > > should use assertEquals, assertTrue\s*\(.*==.*\)\s*;
> >> > > should use assertEquals, assertTrue\s*\(.*\.euqals.*\)\s*;
> >> >
> >> > There's a typo in that last one.
> >> :p
> >> > But be careful with these.  For
> >> > example, the second last rule will match things like:
> >> >
> >> >
> >> modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java:
> >>
> >> >    assertTrue("Wrong bytes", in.read() == 6 && in.read() == 7);
> >> Oh, I know why you used [^|&] now.
> >>
> >> My problem is that the CheckStyle can not do multi-step check,  so I
> >> have to write rules in one line regexp. For one line regex, there are
> >> many restrictions. It should only be used for assisting manual check.
> >> Your script is better and stricter for auto fixing:)
> >>
> >> I tried assertTrue\s*\(.*(?===)&(?!true|false|null).*\)\s*; to match a
> >> string which have == and does not have true, false and null, but it
> >> did not work:(
> >> I know you are a regexp guru, do you have some tricks or tips to make
> >> one line regexp match more accurate?
> >>
> >> >
> >> > which is why the regular expressions in my script are a little stricter
> >> > (that is not using .* but a character class to avoid catching complex
> >> > cases).
> >> >
> >> > > any comments?
> >> >
> >> > If you fix any automatically, please check them over manual unless you
> >> > are really, really sure the fixes are not breaking anything.
> >>
> >> hmm...I decided to do it manually...
> >> >
> >> > Regards,
> >> >  Mark.
> >> >
> >> >
> >> >
> >>
> >>
> >> --
> >> Tony Wu
> >> China Software Development Lab, IBM
> >>
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <!--
> >       This configuration file was written by the eclipse-cs plugin configuration
editor
> > -->
> > <!--
> > Checkstyle-Configuration: test
> > Description:
> >
> > -->
> > <!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
> > <module name="Checker">
> >     <property name="severity" value="warning"/>
> >     <module name="TreeWalker">
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertNull"/>
> >             <property name="format" value="assertEquals\s*\((.*,\s*null\s*|\s*null\s*,.*)\);"/>
> >             <property name="message" value="should use assertNull"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertFalse"/>
> >             <property name="format" value="assertEquals\s*\((.*,\s*false\s*|\s*false\s*,.*)\);"/>
> >             <property name="message" value="should use assertFalse"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertTrue"/>
> >             <property name="format" value="assertEquals\s*\((.*,\s*true\s*|\s*true\s*,.*)\);"/>
> >             <property name="message" value="should use assertTrue"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="last
argument should not be a constant"/>
> >             <property name="format" value="assertEquals\s*\(.*,\s*(&quot;[^&quot;]*&quot;|'[^']'|[+-]?\d+[0-9a-fA-FLlPp]*)\s*\);"/>
> >             <property name="message" value="last argument should not be a constant"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="always
true/false"/>
> >             <property name="format" value="assert(False|True)\s*\(\s*(false|true)\s*\)\s*;"/>
> >             <property name="message" value="always true/false"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="multiple
assertion"/>
> >             <property name="format" value="assertTrue\s*\(.*\&amp;\&amp;.*\)\s*;"/>
> >             <property name="message" value="multiple assertion"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="multiple
assertion"/>
> >             <property name="format" value="assertFalse\s*\(.*\|\|.*\)\s*;"/>
> >             <property name="message" value="multiple assertion"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertNull"/>
> >             <property name="format" value="assertTrue\s*\((.*==\s*null\s*|\s*null\s*==.*)\)\s*;"/>
> >             <property name="message" value="should use assertNull"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertTrue"/>
> >             <property name="format" value="assertTrue\s*\((.*==\s*true\s*|\s*true\s*==.*)\)\s*;"/>
> >             <property name="message" value="should use assertTrue"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertFalse"/>
> >             <property name="format" value="assertTrue\s*\((.*==\s*false\s*|\s*false\s*==.*)\)\s*;"/>
> >             <property name="message" value="should use assertFalse"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertNotNull"/>
> >             <property name="format" value="assertTrue\s*\((.*!=\s*null\s*|\s*null\s*!=.*)\)\s*;"/>
> >             <property name="message" value="should use assertNotNull"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertFalse"/>
> >             <property name="format" value="assertTrue\s*\((.*!=\s*true\s*|\s*true\s*!=.*)\)\s*;"/>
> >             <property name="message" value="should use assertFalse"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertTrue"/>
> >             <property name="format" value="assertTrue\s*\((.*!=\s*false\s*|\s*false\s*!=.*)\)\s*;"/>
> >             <property name="message" value="should use assertTrue"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertFalse"/>
> >             <property name="format" value="assertTrue\s*\(\s*!.*\)\s*;"/>
> >             <property name="message" value="should use assertFalse"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertFalse"/>
> >             <property name="format" value="assertTrue\s*\(&quot;[^&quot;]*&quot;\s*,\s*!.*\)\s*;"/>
> >             <property name="message" value="should use assertFalse"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertNotNull"/>
> >             <property name="format" value="assertFalse\s*\((.*==\s*null\s*|\s*null\s*==.*)\)\s*;"/>
> >             <property name="message" value="should use assertNotNull"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertFalse"/>
> >             <property name="format" value="assertFalse\s*\((.*!=\s*true\s*|\s*true\s*!=.*)\)\s*;"/>
> >             <property name="message" value="should use assertFalse"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertTrue"/>
> >             <property name="format" value="assertFalse\s*\((.*!=\s*false\s*|\s*false\s*!=.*)\)\s*;"/>
> >             <property name="message" value="should use assertTrue"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertNull"/>
> >             <property name="format" value="assertFalse\s*\((.*!=\s*null\s*|\s*null\s*!=.*)\)\s*;"/>
> >             <property name="message" value="should use assertNull"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertFalse"/>
> >             <property name="format" value="assertFalse\s*\((.*==\s*true\s*|\s*true\s*==.*)\)\s*;"/>
> >             <property name="message" value="should use assertFalse"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertTrue"/>
> >             <property name="format" value="assertFalse\s*\((.*==\s*false\s*|\s*false\s*==.*)\)\s*;"/>
> >             <property name="message" value="should use assertTrue"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertEquals"/>
> >             <property name="format" value="assertTrue\s*\(.*==.*\)\s*;"/>
> >             <property name="message" value="should use assertEquals"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >         <module name="Regexp">
> >             <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="should
use assertEquals"/>
> >             <property name="format" value="assertTrue\s*\(.*\.euqals.*\)\s*;"/>
> >             <property name="message" value="should use assertEquals"/>
> >             <property name="illegalPattern" value="true"/>
> >             <property name="ignoreComments" value="true"/>
> >         </module>
> >     </module>
> > </module>
>


-- 
Tony Wu
China Software Development Lab, IBM

Mime
View raw message