You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xmlgraphics.apache.org by Vincent Hennebert <vh...@gmail.com> on 2012/04/25 17:44:01 UTC

Re: Checkstyle, Reloaded

Ok, reviving a thread that has been dormant for too long.

Attached is an updated version of the proposed Checkstyle configuration.
I removed/relaxed the following rules:
• EmptyBlock (allow comments)
• ExplicitInitialization (not automatically fixable)
• NoWhitespaceAfter with ARRAY_INIT token
• ParenPad

Note that I’m not happy with removing that last rule. I agree with
Alexios that a consistent style makes reading and debugging easier. That
wouldn’t be too bad if the original style were preserved in every source
file, but this will clearly not happen. In fact, the mixing of styles
has already started after the complex scripts patch was applied. I still
removed the rule though.

However, I left the MethodParamPad rule in order to remain compliant
with Sun’s recommendations:
http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141388.html#475
I’d also like to keep the NoWhitespaceAfter rule, as whitespace after
unary operators increases too much the risk of misreading the statement
IMO.

Finally, I left the LineLength rule to 110. Long lines impede code
readability too much IMO. They also make side-by-side comparison harder.
I note that some even recommend to leave the check to 100. I think 110
should be an acceptable compromise.

Please let me know what you think.
Thanks,
Vincent


On 03/02/12 17:45, Vincent Hennebert wrote:
> Hi All,
> 
> it is well-known that people are not happy with the Checkstyle file we
> have in FOP. And there’s no point enforcing the application of
> Checkstyle rules if we don’t agree with them in the first place.
> 
> I’ve finally taken on me to create a new Checkstyle file that follows
> modern development practices. I’ve been testing it on my own projects
> for a few months now and I’m happy with it, so I’d like to share it with
> the community. The idea is that once we’ve reached consensus on the
> Checkstyle rules we want to apply, we could set up a no warning policy
> and enforce it by running Checkstyle in CI.
> 
> I’m also taking this as an opportunity to propose that we adopt a common
> Checkstyle policy to all the sub-projects of XML Graphics. So once we’ve
> agreed on a set of rules we would apply them to FOP and XGC immediately,
> and eventually also to Batik, and keep them in sync.
> 
> We would also apply the rules to the test files as well as the main
> code. Tests are as important as the actual code and there is no reason
> why they shouldn’t be checked.
> 
> It is likely that the current code will not be compliant with the new
> rules. However, most of them are really just about the syntax, so
> I believe it should be fairly straightforward to make the code at least
> 90% compliant just by applying Eclipse’s command-line code formatter.
> 
> Please find the Checkstyle file attached. It is based on Checkstyle 5.5
> and basically follows Sun’s recommendations for Java styling with a few
> adaptations. What’s noteworthy is the following:
> 
> • Removed checks for Javadoc. What we want is quality Javadoc, and that
>   is not something that Checkstyle can check. Having Javadoc checks is
>   counter-productive as it forces us to put {@inheritDoc} everywhere, or
>   to create truly useless doc like the following:
>   /**
>    * Returns the thing.
>    * @return the thing
>    */
>   public Thing getThing() {
>       return thing;
>   }
>   This is just clutter really. I think it should be left to peer review
>   to check whether a Javadoc comment is properly written, or whether the
>   lack thereof is justified. There’s an excellent blog entry from
>   Torsten Curdt about this:
>   http://vafer.org/blog/20050323095453/
> • Removed check for file and method lengths. I don’t think it makes
>   sense to define a maximum size for files and methods. Sometimes
>   a 10-line method is way too big, sometimes it makes sense to have it
>   reach 20 lines. Same for files: it’s ok to reach 1000 lines if the
>   class contains several inner classes. If it doesn’t, then it’s
>   probably too big. I don’t think there is any definite figure we can
>   agree on and blindly follow, so I think sizes should be left to peer
>   review.
> • However, I left the check for maximum line length because unreasonably
>   long lines make the code hard to follow. I increased it to 110
>   though to follow the evolution of monitor sizes. But as Peter
>   suggested me, we probably want to keep it low in order to make
>   side-by-side comparison easy.
> • I added a check for the order of imports; this is to reduce noise in
>   diffs when committing. I think most of us have configured their IDE to
>   automatically organise imports when saving changes to a file. This is
>   a great feature because it allows to keep the list of imports
>   up-to-date. But in order to avoid constant back and forth changes when
>   different committers change the same file, I think it makes sense that
>   we all have the same configuration. I modeled this list after
>   Jeremias’ one, that I progressively inferred from his commits.
> 
> Please let me know what you think. I’m inclined to follow lazy consensus
> on this, and apply the proposed changes if nobody has objected within
> 2 weeks. If anybody feels that a formal vote is necessary, feel free to
> say so.
> 
> Thanks,
> Vincent

Re: Checkstyle, Reloaded

Posted by Glenn Adams <gl...@skynav.com>.
On Thu, Apr 26, 2012 at 9:19 AM, Vincent Hennebert <vh...@gmail.com>wrote:

> On 25/04/12 20:01, Glenn Adams wrote:
> > On Wed, Apr 25, 2012 at 12:29 PM, Vincent Hennebert <
> vhennebert@gmail.com>wrote:
> >
> >> On 25/04/12 19:03, Glenn Adams wrote:
> >>> On Wed, Apr 25, 2012 at 11:46 AM, Vincent Hennebert <
> >> vhennebert@gmail.com>wrote:
> >>>
> >>>> On 25/04/12 17:03, Glenn Adams wrote:
> >>>>> how does this differ from the current checkstyle-5.5.xml rules that
> are
> >>>> the
> >>>>> current default in fop?
> >>>>
> >>>> The following rules have been removed:
> >> <snip/>
> >>
> >>>> • CSOFF and CSOK
> >>>>
> >>>
> >>> i do not accept removing these unless you are willing to remove all
> rules
> >>> that trigger a warning/error in the absence of these pragmas
> >>
> >> Those are essentially the rules about whitespace. I’ve given reasons
> >> what I think we should keep some of them. Could you comment on them?
> >>
> >
> > i did; see my responses at [1-5]:
> >
> > [1] Re: Checkstyle,
> > Reloaded<
> http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+fuosd_5W09LDnNeCbo-rN+2kpsdqnbH752iH1-N+HJdQ@mail.gmail.com%3e
> >
> > [2] Re: Checkstyle,
> > Reloaded<
> http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+f6A+iuDhLYbqgGAmim-eqnMgyD3azvwQ0D8a6HH8bQkw@mail.gmail.com%3e
> >
> > [3] Re: Checkstyle,
> > Reloaded<
> http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+cEunN8_d0O=dUPCHmMsK9+71Pj3f4VYk23xZMrxuMuuA@mail.gmail.com%3e
> >
> > [4] Re: Checkstyle,
> > Reloaded<
> http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+c3ygYneGjUJP+6xXeMW4yS=79De=48xSZ=EqvuR0ofAw@mail.gmail.com%3e
> >
> > [5] Re: Checkstyle,
> > Reloaded<
> http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+fqPEePgSxkQ_c01vdAoN7scRcjytcHuw4FvbhzYBmvog@mail.gmail.com%3e
> >
>
> I saw that. What I would like to know is what you think about the
> readability concerns that have been raised?
>

please provide a link to whichever messages discusses those concerns


>
>
> <snip/>
> >>>> • ConstantName: removed log exception
> >>>>
> >>>
> >>> could you elaborate?
> >>
> >> Static final log fields will have to be made uppercase.
> >>
> >
> > I would prefer to leave it as is currently used.
>
> Why? We might as well convert them to the prescribed convention.
>

the current convention in FOP is lower case; you are proposing a new
convention; i would prefer to stay with the current convention for log


>
>
> <snip/>
> >>> i also don't accept changing LineLength back to 110; i believe
> >>> someone
> >>> proposed 130, which I can accept as long as i can disable entirely
> using
> >>> CSOFF; i would prefer *no* limit
> >>
> >> I (and others) have given good reasons why the line length should be
> >> limited. Surely those reasons prevail over mere style preference, don’t
> >> they?
> >>
> >
> > as i have stated numerous times, i use an editor (emacs) that makes long
> > lines easy to handle, so i don't have a problem with them; on my (15"
> > laptop) screen, i get 200 columns before a wrap; i prefer to *not* break
> a
> > statement artificially into lines simply due to an arbitrary line length
> > limit;
>
> Again this is a mere style preference. I’m afraid it doesn’t count
> compared to reasons of readability and convenience for side-by-side
> comparison.
>

sorry, but i disagree; you are arguing your convenience against my
convenience; you are going to insist that is more convenient for you to use
short lines, and i am going to insist that it is more convenient for me to
use long lines;

i proposed a compromise i can live with: 130 line length plus use of CSOFF
in files that do not follow this rule; i will not agree to anything less; i
would suggest you follow the advice given by Chris in [1]:

"I propose that we remove this rule as Glenn suggests and it will avoid lines
being broken in awkward places too."

[1]
http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cBLU0-SMTP420D413C8764CC374545B5BFB7B0@phx.gbl%3e



>
>
> > if you don't mind me using my style in files i author (with CSOFF to
> > disable), then i can accept a shorter limit, e.g., i believe someone
> > proposed 130
>
> The goal is to remove CSOFF altogether. There’s no point having
> Checkstyle rules if anybody can disable them using CSOFF comments.
>

that may be your goal, but it is not my goal; if you want to insist on
applying a style rule that i disagree with in principle, then you will have
to allow for exceptions; a better approach would be to not insist on
applying any rule for which there is not unanimous agreement; however, i am
offering a compromise, which is that you may add a rule which i do no agree
with as long as you do not object to me disabling that rule in files i
author; you can't do both (apply the rule and rule out exclusions)


>
> Files your authored will sooner or later be read and modified by other
> people, so they shouldn’t receive any special treatment.
>

in that case, you should not insist on applying a style rule for which
there is not unanimous agreement


> I could agree to raise the limit to 120, but that’s the absolute
> maximum.
>

i can agree to one of the following regarding line length:

(1) default rule enforces 130, but allows exceptions via CSOFF/CSOK; [i
would point out that one of the most popular IBM 1403 printer, Model 2,
introduced in the early 60s and used with both IBM System/360 and
System/370 had 132 print positions]

or

(2) no rule for line length


>
>
> > but personally, i think it best not to enforce any limit
> >
> >
> >>
> >> Thanks,
> >> Vincent
> >>
> >>
> >>>>> On Wed, Apr 25, 2012 at 9:44 AM, Vincent Hennebert <
> >> vhennebert@gmail.com
> >>>>> wrote:
> >>>>>
> >>>>>> Ok, reviving a thread that has been dormant for too long.
> >>>>>>
> >>>>>> Attached is an updated version of the proposed Checkstyle
> >> configuration.
> >>>>>> I removed/relaxed the following rules:
> >>>>>> • EmptyBlock (allow comments)
> >>>>>> • ExplicitInitialization (not automatically fixable)
> >>>>>> • NoWhitespaceAfter with ARRAY_INIT token
> >>>>>> • ParenPad
> >>>>>>
> >>>>>> Note that I’m not happy with removing that last rule. I agree with
> >>>>>> Alexios that a consistent style makes reading and debugging easier.
> >> That
> >>>>>> wouldn’t be too bad if the original style were preserved in every
> >> source
> >>>>>> file, but this will clearly not happen. In fact, the mixing of
> styles
> >>>>>> has already started after the complex scripts patch was applied. I
> >> still
> >>>>>> removed the rule though.
> >>>>>>
> >>>>>> However, I left the MethodParamPad rule in order to remain compliant
> >>>>>> with Sun’s recommendations:
> >>>>>>
> >>>>>>
> >>>>
> >>
> http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141388.html#475
> >>>>>> I’d also like to keep the NoWhitespaceAfter rule, as whitespace
> after
> >>>>>> unary operators increases too much the risk of misreading the
> >> statement
> >>>>>> IMO.
> >>>>>>
> >>>>>> Finally, I left the LineLength rule to 110. Long lines impede code
> >>>>>> readability too much IMO. They also make side-by-side comparison
> >> harder.
> >>>>>> I note that some even recommend to leave the check to 100. I think
> 110
> >>>>>> should be an acceptable compromise.
> >>>>>>
> >>>>>> Please let me know what you think.
> >>>>>> Thanks,
> >>>>>> Vincent
>
>
> Vincent
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: general-help@xmlgraphics.apache.org
>
>

Re: Checkstyle, Reloaded

Posted by Vincent Hennebert <vh...@gmail.com>.
On 25/04/12 20:01, Glenn Adams wrote:
> On Wed, Apr 25, 2012 at 12:29 PM, Vincent Hennebert <vh...@gmail.com>wrote:
> 
>> On 25/04/12 19:03, Glenn Adams wrote:
>>> On Wed, Apr 25, 2012 at 11:46 AM, Vincent Hennebert <
>> vhennebert@gmail.com>wrote:
>>>
>>>> On 25/04/12 17:03, Glenn Adams wrote:
>>>>> how does this differ from the current checkstyle-5.5.xml rules that are
>>>> the
>>>>> current default in fop?
>>>>
>>>> The following rules have been removed:
>> <snip/>
>>
>>>> • CSOFF and CSOK
>>>>
>>>
>>> i do not accept removing these unless you are willing to remove all rules
>>> that trigger a warning/error in the absence of these pragmas
>>
>> Those are essentially the rules about whitespace. I’ve given reasons
>> what I think we should keep some of them. Could you comment on them?
>>
> 
> i did; see my responses at [1-5]:
> 
> [1] Re: Checkstyle,
> Reloaded<http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+fuosd_5W09LDnNeCbo-rN+2kpsdqnbH752iH1-N+HJdQ@mail.gmail.com%3e>
> [2] Re: Checkstyle,
> Reloaded<http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+f6A+iuDhLYbqgGAmim-eqnMgyD3azvwQ0D8a6HH8bQkw@mail.gmail.com%3e>
> [3] Re: Checkstyle,
> Reloaded<http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+cEunN8_d0O=dUPCHmMsK9+71Pj3f4VYk23xZMrxuMuuA@mail.gmail.com%3e>
> [4] Re: Checkstyle,
> Reloaded<http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+c3ygYneGjUJP+6xXeMW4yS=79De=48xSZ=EqvuR0ofAw@mail.gmail.com%3e>
> [5] Re: Checkstyle,
> Reloaded<http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+fqPEePgSxkQ_c01vdAoN7scRcjytcHuw4FvbhzYBmvog@mail.gmail.com%3e>

I saw that. What I would like to know is what you think about the
readability concerns that have been raised?


<snip/>
>>>> • ConstantName: removed log exception
>>>>
>>>
>>> could you elaborate?
>>
>> Static final log fields will have to be made uppercase.
>>
> 
> I would prefer to leave it as is currently used.

Why? We might as well convert them to the prescribed convention.


<snip/>
>>> i also don't accept changing LineLength back to 110; i believe 
>>> someone
>>> proposed 130, which I can accept as long as i can disable entirely using
>>> CSOFF; i would prefer *no* limit
>>
>> I (and others) have given good reasons why the line length should be
>> limited. Surely those reasons prevail over mere style preference, don’t
>> they?
>>
> 
> as i have stated numerous times, i use an editor (emacs) that makes long
> lines easy to handle, so i don't have a problem with them; on my (15"
> laptop) screen, i get 200 columns before a wrap; i prefer to *not* break a
> statement artificially into lines simply due to an arbitrary line length
> limit;

Again this is a mere style preference. I’m afraid it doesn’t count
compared to reasons of readability and convenience for side-by-side
comparison.


> if you don't mind me using my style in files i author (with CSOFF to
> disable), then i can accept a shorter limit, e.g., i believe someone
> proposed 130

The goal is to remove CSOFF altogether. There’s no point having
Checkstyle rules if anybody can disable them using CSOFF comments.

Files your authored will sooner or later be read and modified by other
people, so they shouldn’t receive any special treatment.

I could agree to raise the limit to 120, but that’s the absolute
maximum.


> but personally, i think it best not to enforce any limit
> 
> 
>>
>> Thanks,
>> Vincent
>>
>>
>>>>> On Wed, Apr 25, 2012 at 9:44 AM, Vincent Hennebert <
>> vhennebert@gmail.com
>>>>> wrote:
>>>>>
>>>>>> Ok, reviving a thread that has been dormant for too long.
>>>>>>
>>>>>> Attached is an updated version of the proposed Checkstyle
>> configuration.
>>>>>> I removed/relaxed the following rules:
>>>>>> • EmptyBlock (allow comments)
>>>>>> • ExplicitInitialization (not automatically fixable)
>>>>>> • NoWhitespaceAfter with ARRAY_INIT token
>>>>>> • ParenPad
>>>>>>
>>>>>> Note that I’m not happy with removing that last rule. I agree with
>>>>>> Alexios that a consistent style makes reading and debugging easier.
>> That
>>>>>> wouldn’t be too bad if the original style were preserved in every
>> source
>>>>>> file, but this will clearly not happen. In fact, the mixing of styles
>>>>>> has already started after the complex scripts patch was applied. I
>> still
>>>>>> removed the rule though.
>>>>>>
>>>>>> However, I left the MethodParamPad rule in order to remain compliant
>>>>>> with Sun’s recommendations:
>>>>>>
>>>>>>
>>>>
>> http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141388.html#475
>>>>>> I’d also like to keep the NoWhitespaceAfter rule, as whitespace after
>>>>>> unary operators increases too much the risk of misreading the
>> statement
>>>>>> IMO.
>>>>>>
>>>>>> Finally, I left the LineLength rule to 110. Long lines impede code
>>>>>> readability too much IMO. They also make side-by-side comparison
>> harder.
>>>>>> I note that some even recommend to leave the check to 100. I think 110
>>>>>> should be an acceptable compromise.
>>>>>>
>>>>>> Please let me know what you think.
>>>>>> Thanks,
>>>>>> Vincent


Vincent

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


Re: Checkstyle, Reloaded

Posted by Glenn Adams <gl...@skynav.com>.
On Wed, Apr 25, 2012 at 12:29 PM, Vincent Hennebert <vh...@gmail.com>wrote:

> On 25/04/12 19:03, Glenn Adams wrote:
> > On Wed, Apr 25, 2012 at 11:46 AM, Vincent Hennebert <
> vhennebert@gmail.com>wrote:
> >
> >> On 25/04/12 17:03, Glenn Adams wrote:
> >>> how does this differ from the current checkstyle-5.5.xml rules that are
> >> the
> >>> current default in fop?
> >>
> >> The following rules have been removed:
> <snip/>
>
> >> • CSOFF and CSOK
> >>
> >
> > i do not accept removing these unless you are willing to remove all rules
> > that trigger a warning/error in the absence of these pragmas
>
> Those are essentially the rules about whitespace. I’ve given reasons
> what I think we should keep some of them. Could you comment on them?
>

i did; see my responses at [1-5]:

[1] Re: Checkstyle,
Reloaded<http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+fuosd_5W09LDnNeCbo-rN+2kpsdqnbH752iH1-N+HJdQ@mail.gmail.com%3e>
[2] Re: Checkstyle,
Reloaded<http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+f6A+iuDhLYbqgGAmim-eqnMgyD3azvwQ0D8a6HH8bQkw@mail.gmail.com%3e>
[3] Re: Checkstyle,
Reloaded<http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+cEunN8_d0O=dUPCHmMsK9+71Pj3f4VYk23xZMrxuMuuA@mail.gmail.com%3e>
[4] Re: Checkstyle,
Reloaded<http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+c3ygYneGjUJP+6xXeMW4yS=79De=48xSZ=EqvuR0ofAw@mail.gmail.com%3e>
[5] Re: Checkstyle,
Reloaded<http://mail-archives.apache.org/mod_mbox/xmlgraphics-general/201202.mbox/%3cCACQ=j+fqPEePgSxkQ_c01vdAoN7scRcjytcHuw4FvbhzYBmvog@mail.gmail.com%3e>


>
>
> >> • Double (No idea what it is about. It doesn’t appear in the list of
> >>  available checks for Checkstyle 5.5.)
> >>
> >
> > the full name is DoubleCheckedLocking, which is documented at
> >
> >
> http://checkstyle.sourceforge.net/config_coding.html#DoubleCheckedLocking
>
> Ha, ok. I think it’s not Checkstyle’s job to check for that.
>
>
> <snip/>
> >> • EqualsHashCode
> >>
> >
> > i think this should stay, since it is part of the object contract, and
> > exceptions (via CSOFF/CSOK) need to be explicitly documented
>
> Same here. I think Checkstyle should be restricted to, well, checking
> style.
>
>
> <snip/>
> >> • ConstantName: removed log exception
> >>
> >
> > could you elaborate?
>
> Static final log fields will have to be made uppercase.
>

I would prefer to leave it as is currently used.


> >> • WhitespaceAfter: added typecast to follow Sun’s conventions
> >>
> >
> > i don't accept this, particularly since it is widely used in FOP code
> (and
> > I always use whitespace after typecast)
>
> ?? Using a whitespace after a cast is precisely what this rule enforces.


ah, then i guess i noticed many existing uses that did not put whitespace
after the typecast; if you wish to enforce this and also will make the
changes to existing code, then i can agree


>
> > i also don't accept changing LineLength back to 110; i believe someone
> > proposed 130, which I can accept as long as i can disable entirely using
> > CSOFF; i would prefer *no* limit
>
> I (and others) have given good reasons why the line length should be
> limited. Surely those reasons prevail over mere style preference, don’t
> they?
>

as i have stated numerous times, i use an editor (emacs) that makes long
lines easy to handle, so i don't have a problem with them; on my (15"
laptop) screen, i get 200 columns before a wrap; i prefer to *not* break a
statement artificially into lines simply due to an arbitrary line length
limit;

if you don't mind me using my style in files i author (with CSOFF to
disable), then i can accept a shorter limit, e.g., i believe someone
proposed 130

but personally, i think it best not to enforce any limit


>
> Thanks,
> Vincent
>
>
> >>> On Wed, Apr 25, 2012 at 9:44 AM, Vincent Hennebert <
> vhennebert@gmail.com
> >>> wrote:
> >>>
> >>>> Ok, reviving a thread that has been dormant for too long.
> >>>>
> >>>> Attached is an updated version of the proposed Checkstyle
> configuration.
> >>>> I removed/relaxed the following rules:
> >>>> • EmptyBlock (allow comments)
> >>>> • ExplicitInitialization (not automatically fixable)
> >>>> • NoWhitespaceAfter with ARRAY_INIT token
> >>>> • ParenPad
> >>>>
> >>>> Note that I’m not happy with removing that last rule. I agree with
> >>>> Alexios that a consistent style makes reading and debugging easier.
> That
> >>>> wouldn’t be too bad if the original style were preserved in every
> source
> >>>> file, but this will clearly not happen. In fact, the mixing of styles
> >>>> has already started after the complex scripts patch was applied. I
> still
> >>>> removed the rule though.
> >>>>
> >>>> However, I left the MethodParamPad rule in order to remain compliant
> >>>> with Sun’s recommendations:
> >>>>
> >>>>
> >>
> http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141388.html#475
> >>>> I’d also like to keep the NoWhitespaceAfter rule, as whitespace after
> >>>> unary operators increases too much the risk of misreading the
> statement
> >>>> IMO.
> >>>>
> >>>> Finally, I left the LineLength rule to 110. Long lines impede code
> >>>> readability too much IMO. They also make side-by-side comparison
> harder.
> >>>> I note that some even recommend to leave the check to 100. I think 110
> >>>> should be an acceptable compromise.
> >>>>
> >>>> Please let me know what you think.
> >>>> Thanks,
> >>>> Vincent
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: general-help@xmlgraphics.apache.org
>
>

Re: Checkstyle, Reloaded

Posted by Vincent Hennebert <vh...@gmail.com>.
On 25/04/12 19:03, Glenn Adams wrote:
> On Wed, Apr 25, 2012 at 11:46 AM, Vincent Hennebert <vh...@gmail.com>wrote:
> 
>> On 25/04/12 17:03, Glenn Adams wrote:
>>> how does this differ from the current checkstyle-5.5.xml rules that are
>> the
>>> current default in fop?
>>
>> The following rules have been removed:
<snip/>

>> • CSOFF and CSOK
>>
> 
> i do not accept removing these unless you are willing to remove all rules
> that trigger a warning/error in the absence of these pragmas

Those are essentially the rules about whitespace. I’ve given reasons
what I think we should keep some of them. Could you comment on them?


>> • Double (No idea what it is about. It doesn’t appear in the list of
>>  available checks for Checkstyle 5.5.)
>>
> 
> the full name is DoubleCheckedLocking, which is documented at
> 
> http://checkstyle.sourceforge.net/config_coding.html#DoubleCheckedLocking

Ha, ok. I think it’s not Checkstyle’s job to check for that.


<snip/>
>> • EqualsHashCode
>>
> 
> i think this should stay, since it is part of the object contract, and
> exceptions (via CSOFF/CSOK) need to be explicitly documented

Same here. I think Checkstyle should be restricted to, well, checking
style.


<snip/>
>> • ConstantName: removed log exception
>>
> 
> could you elaborate?

Static final log fields will have to be made uppercase.


>> • WhitespaceAfter: added typecast to follow Sun’s conventions
>>
> 
> i don't accept this, particularly since it is widely used in FOP code (and
> I always use whitespace after typecast)

?? Using a whitespace after a cast is precisely what this rule enforces.


> i also don't accept changing LineLength back to 110; i believe someone
> proposed 130, which I can accept as long as i can disable entirely using
> CSOFF; i would prefer *no* limit

I (and others) have given good reasons why the line length should be
limited. Surely those reasons prevail over mere style preference, don’t
they?


Thanks,
Vincent


>>> On Wed, Apr 25, 2012 at 9:44 AM, Vincent Hennebert <vhennebert@gmail.com
>>> wrote:
>>>
>>>> Ok, reviving a thread that has been dormant for too long.
>>>>
>>>> Attached is an updated version of the proposed Checkstyle configuration.
>>>> I removed/relaxed the following rules:
>>>> • EmptyBlock (allow comments)
>>>> • ExplicitInitialization (not automatically fixable)
>>>> • NoWhitespaceAfter with ARRAY_INIT token
>>>> • ParenPad
>>>>
>>>> Note that I’m not happy with removing that last rule. I agree with
>>>> Alexios that a consistent style makes reading and debugging easier. That
>>>> wouldn’t be too bad if the original style were preserved in every source
>>>> file, but this will clearly not happen. In fact, the mixing of styles
>>>> has already started after the complex scripts patch was applied. I still
>>>> removed the rule though.
>>>>
>>>> However, I left the MethodParamPad rule in order to remain compliant
>>>> with Sun’s recommendations:
>>>>
>>>>
>> http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141388.html#475
>>>> I’d also like to keep the NoWhitespaceAfter rule, as whitespace after
>>>> unary operators increases too much the risk of misreading the statement
>>>> IMO.
>>>>
>>>> Finally, I left the LineLength rule to 110. Long lines impede code
>>>> readability too much IMO. They also make side-by-side comparison harder.
>>>> I note that some even recommend to leave the check to 100. I think 110
>>>> should be an acceptable compromise.
>>>>
>>>> Please let me know what you think.
>>>> Thanks,
>>>> Vincent

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


Re: Checkstyle, Reloaded

Posted by Glenn Adams <gl...@skynav.com>.
On Wed, Apr 25, 2012 at 11:46 AM, Vincent Hennebert <vh...@gmail.com>wrote:

> On 25/04/12 17:03, Glenn Adams wrote:
> > how does this differ from the current checkstyle-5.5.xml rules that are
> the
> > current default in fop?
>
> The following rules have been removed:
> • prohibiting the usage of @author but we can add it back
>

i'm fine with keeping this in, since I already removed all existing usage
of @author (in FOP files)


> • CSOFF and CSOK
>

i do not accept removing these unless you are willing to remove all rules
that trigger a warning/error in the absence of these pragmas


> • Double (No idea what it is about. It doesn’t appear in the list of
>  available checks for Checkstyle 5.5.)
>

the full name is DoubleCheckedLocking, which is documented at

http://checkstyle.sourceforge.net/config_coding.html#DoubleCheckedLocking


> • FileContentsHolder (same)
>

this is needed for CSOFF/CSOK to work


> • InnerAssignments
>

i don't mind removing this, particularly since I use inner assignments
(with CSOFF/CSOK as needed)


> • EqualsHashCode
>

i think this should stay, since it is part of the object contract, and
exceptions (via CSOFF/CSOK) need to be explicitly documented


>
> The following rules have been modified:
> • AvoidStarImport: severity changed from error to warning
>

ok


> • ConstantName: removed log exception
>

could you elaborate?


> • WhitespaceAfter: added typecast to follow Sun’s conventions
>

i don't accept this, particularly since it is widely used in FOP code (and
I always use whitespace after typecast)

i also don't accept changing LineLength back to 110; i believe someone
proposed 130, which I can accept as long as i can disable entirely using
CSOFF; i would prefer *no* limit



>
>
> Vincent
>
>
> > On Wed, Apr 25, 2012 at 9:44 AM, Vincent Hennebert <vhennebert@gmail.com
> >wrote:
> >
> >> Ok, reviving a thread that has been dormant for too long.
> >>
> >> Attached is an updated version of the proposed Checkstyle configuration.
> >> I removed/relaxed the following rules:
> >> • EmptyBlock (allow comments)
> >> • ExplicitInitialization (not automatically fixable)
> >> • NoWhitespaceAfter with ARRAY_INIT token
> >> • ParenPad
> >>
> >> Note that I’m not happy with removing that last rule. I agree with
> >> Alexios that a consistent style makes reading and debugging easier. That
> >> wouldn’t be too bad if the original style were preserved in every source
> >> file, but this will clearly not happen. In fact, the mixing of styles
> >> has already started after the complex scripts patch was applied. I still
> >> removed the rule though.
> >>
> >> However, I left the MethodParamPad rule in order to remain compliant
> >> with Sun’s recommendations:
> >>
> >>
> http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141388.html#475
> >> I’d also like to keep the NoWhitespaceAfter rule, as whitespace after
> >> unary operators increases too much the risk of misreading the statement
> >> IMO.
> >>
> >> Finally, I left the LineLength rule to 110. Long lines impede code
> >> readability too much IMO. They also make side-by-side comparison harder.
> >> I note that some even recommend to leave the check to 100. I think 110
> >> should be an acceptable compromise.
> >>
> >> Please let me know what you think.
> >> Thanks,
> >> Vincent
> >>
> >>
> >> On 03/02/12 17:45, Vincent Hennebert wrote:
> >>> Hi All,
> >>>
> >>> it is well-known that people are not happy with the Checkstyle file we
> >>> have in FOP. And there’s no point enforcing the application of
> >>> Checkstyle rules if we don’t agree with them in the first place.
> >>>
> >>> I’ve finally taken on me to create a new Checkstyle file that follows
> >>> modern development practices. I’ve been testing it on my own projects
> >>> for a few months now and I’m happy with it, so I’d like to share it
> with
> >>> the community. The idea is that once we’ve reached consensus on the
> >>> Checkstyle rules we want to apply, we could set up a no warning policy
> >>> and enforce it by running Checkstyle in CI.
> >>>
> >>> I’m also taking this as an opportunity to propose that we adopt a
> common
> >>> Checkstyle policy to all the sub-projects of XML Graphics. So once
> we’ve
> >>> agreed on a set of rules we would apply them to FOP and XGC
> immediately,
> >>> and eventually also to Batik, and keep them in sync.
> >>>
> >>> We would also apply the rules to the test files as well as the main
> >>> code. Tests are as important as the actual code and there is no reason
> >>> why they shouldn’t be checked.
> >>>
> >>> It is likely that the current code will not be compliant with the new
> >>> rules. However, most of them are really just about the syntax, so
> >>> I believe it should be fairly straightforward to make the code at least
> >>> 90% compliant just by applying Eclipse’s command-line code formatter.
> >>>
> >>> Please find the Checkstyle file attached. It is based on Checkstyle 5.5
> >>> and basically follows Sun’s recommendations for Java styling with a few
> >>> adaptations. What’s noteworthy is the following:
> >>>
> >>> • Removed checks for Javadoc. What we want is quality Javadoc, and that
> >>>   is not something that Checkstyle can check. Having Javadoc checks is
> >>>   counter-productive as it forces us to put {@inheritDoc} everywhere,
> or
> >>>   to create truly useless doc like the following:
> >>>   /**
> >>>    * Returns the thing.
> >>>    * @return the thing
> >>>    */
> >>>   public Thing getThing() {
> >>>       return thing;
> >>>   }
> >>>   This is just clutter really. I think it should be left to peer review
> >>>   to check whether a Javadoc comment is properly written, or whether
> the
> >>>   lack thereof is justified. There’s an excellent blog entry from
> >>>   Torsten Curdt about this:
> >>>   http://vafer.org/blog/20050323095453/
> >>> • Removed check for file and method lengths. I don’t think it makes
> >>>   sense to define a maximum size for files and methods. Sometimes
> >>>   a 10-line method is way too big, sometimes it makes sense to have it
> >>>   reach 20 lines. Same for files: it’s ok to reach 1000 lines if the
> >>>   class contains several inner classes. If it doesn’t, then it’s
> >>>   probably too big. I don’t think there is any definite figure we can
> >>>   agree on and blindly follow, so I think sizes should be left to peer
> >>>   review.
> >>> • However, I left the check for maximum line length because
> unreasonably
> >>>   long lines make the code hard to follow. I increased it to 110
> >>>   though to follow the evolution of monitor sizes. But as Peter
> >>>   suggested me, we probably want to keep it low in order to make
> >>>   side-by-side comparison easy.
> >>> • I added a check for the order of imports; this is to reduce noise in
> >>>   diffs when committing. I think most of us have configured their IDE
> to
> >>>   automatically organise imports when saving changes to a file. This is
> >>>   a great feature because it allows to keep the list of imports
> >>>   up-to-date. But in order to avoid constant back and forth changes
> when
> >>>   different committers change the same file, I think it makes sense
> that
> >>>   we all have the same configuration. I modeled this list after
> >>>   Jeremias’ one, that I progressively inferred from his commits.
> >>>
> >>> Please let me know what you think. I’m inclined to follow lazy
> consensus
> >>> on this, and apply the proposed changes if nobody has objected within
> >>> 2 weeks. If anybody feels that a formal vote is necessary, feel free to
> >>> say so.
> >>>
> >>> Thanks,
> >>> Vincent
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
> >> For additional commands, e-mail: general-help@xmlgraphics.apache.org
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: general-help@xmlgraphics.apache.org
>
>

Re: Checkstyle, Reloaded

Posted by Vincent Hennebert <vh...@gmail.com>.
On 25/04/12 17:03, Glenn Adams wrote:
> how does this differ from the current checkstyle-5.5.xml rules that are the
> current default in fop?

The following rules have been removed:
• prohibiting the usage of @author but we can add it back
• CSOFF and CSOK
• Double (No idea what it is about. It doesn’t appear in the list of
  available checks for Checkstyle 5.5.)
• FileContentsHolder (same)
• InnerAssignments
• EqualsHashCode

The following rules have been modified:
• AvoidStarImport: severity changed from error to warning
• ConstantName: removed log exception
• WhitespaceAfter: added typecast to follow Sun’s conventions


Vincent


> On Wed, Apr 25, 2012 at 9:44 AM, Vincent Hennebert <vh...@gmail.com>wrote:
> 
>> Ok, reviving a thread that has been dormant for too long.
>>
>> Attached is an updated version of the proposed Checkstyle configuration.
>> I removed/relaxed the following rules:
>> • EmptyBlock (allow comments)
>> • ExplicitInitialization (not automatically fixable)
>> • NoWhitespaceAfter with ARRAY_INIT token
>> • ParenPad
>>
>> Note that I’m not happy with removing that last rule. I agree with
>> Alexios that a consistent style makes reading and debugging easier. That
>> wouldn’t be too bad if the original style were preserved in every source
>> file, but this will clearly not happen. In fact, the mixing of styles
>> has already started after the complex scripts patch was applied. I still
>> removed the rule though.
>>
>> However, I left the MethodParamPad rule in order to remain compliant
>> with Sun’s recommendations:
>>
>> http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141388.html#475
>> I’d also like to keep the NoWhitespaceAfter rule, as whitespace after
>> unary operators increases too much the risk of misreading the statement
>> IMO.
>>
>> Finally, I left the LineLength rule to 110. Long lines impede code
>> readability too much IMO. They also make side-by-side comparison harder.
>> I note that some even recommend to leave the check to 100. I think 110
>> should be an acceptable compromise.
>>
>> Please let me know what you think.
>> Thanks,
>> Vincent
>>
>>
>> On 03/02/12 17:45, Vincent Hennebert wrote:
>>> Hi All,
>>>
>>> it is well-known that people are not happy with the Checkstyle file we
>>> have in FOP. And there’s no point enforcing the application of
>>> Checkstyle rules if we don’t agree with them in the first place.
>>>
>>> I’ve finally taken on me to create a new Checkstyle file that follows
>>> modern development practices. I’ve been testing it on my own projects
>>> for a few months now and I’m happy with it, so I’d like to share it with
>>> the community. The idea is that once we’ve reached consensus on the
>>> Checkstyle rules we want to apply, we could set up a no warning policy
>>> and enforce it by running Checkstyle in CI.
>>>
>>> I’m also taking this as an opportunity to propose that we adopt a common
>>> Checkstyle policy to all the sub-projects of XML Graphics. So once we’ve
>>> agreed on a set of rules we would apply them to FOP and XGC immediately,
>>> and eventually also to Batik, and keep them in sync.
>>>
>>> We would also apply the rules to the test files as well as the main
>>> code. Tests are as important as the actual code and there is no reason
>>> why they shouldn’t be checked.
>>>
>>> It is likely that the current code will not be compliant with the new
>>> rules. However, most of them are really just about the syntax, so
>>> I believe it should be fairly straightforward to make the code at least
>>> 90% compliant just by applying Eclipse’s command-line code formatter.
>>>
>>> Please find the Checkstyle file attached. It is based on Checkstyle 5.5
>>> and basically follows Sun’s recommendations for Java styling with a few
>>> adaptations. What’s noteworthy is the following:
>>>
>>> • Removed checks for Javadoc. What we want is quality Javadoc, and that
>>>   is not something that Checkstyle can check. Having Javadoc checks is
>>>   counter-productive as it forces us to put {@inheritDoc} everywhere, or
>>>   to create truly useless doc like the following:
>>>   /**
>>>    * Returns the thing.
>>>    * @return the thing
>>>    */
>>>   public Thing getThing() {
>>>       return thing;
>>>   }
>>>   This is just clutter really. I think it should be left to peer review
>>>   to check whether a Javadoc comment is properly written, or whether the
>>>   lack thereof is justified. There’s an excellent blog entry from
>>>   Torsten Curdt about this:
>>>   http://vafer.org/blog/20050323095453/
>>> • Removed check for file and method lengths. I don’t think it makes
>>>   sense to define a maximum size for files and methods. Sometimes
>>>   a 10-line method is way too big, sometimes it makes sense to have it
>>>   reach 20 lines. Same for files: it’s ok to reach 1000 lines if the
>>>   class contains several inner classes. If it doesn’t, then it’s
>>>   probably too big. I don’t think there is any definite figure we can
>>>   agree on and blindly follow, so I think sizes should be left to peer
>>>   review.
>>> • However, I left the check for maximum line length because unreasonably
>>>   long lines make the code hard to follow. I increased it to 110
>>>   though to follow the evolution of monitor sizes. But as Peter
>>>   suggested me, we probably want to keep it low in order to make
>>>   side-by-side comparison easy.
>>> • I added a check for the order of imports; this is to reduce noise in
>>>   diffs when committing. I think most of us have configured their IDE to
>>>   automatically organise imports when saving changes to a file. This is
>>>   a great feature because it allows to keep the list of imports
>>>   up-to-date. But in order to avoid constant back and forth changes when
>>>   different committers change the same file, I think it makes sense that
>>>   we all have the same configuration. I modeled this list after
>>>   Jeremias’ one, that I progressively inferred from his commits.
>>>
>>> Please let me know what you think. I’m inclined to follow lazy consensus
>>> on this, and apply the proposed changes if nobody has objected within
>>> 2 weeks. If anybody feels that a formal vote is necessary, feel free to
>>> say so.
>>>
>>> Thanks,
>>> Vincent
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: general-help@xmlgraphics.apache.org
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


Re: Checkstyle, Reloaded

Posted by Glenn Adams <gl...@skynav.com>.
how does this differ from the current checkstyle-5.5.xml rules that are the
current default in fop?

On Wed, Apr 25, 2012 at 9:44 AM, Vincent Hennebert <vh...@gmail.com>wrote:

> Ok, reviving a thread that has been dormant for too long.
>
> Attached is an updated version of the proposed Checkstyle configuration.
> I removed/relaxed the following rules:
> • EmptyBlock (allow comments)
> • ExplicitInitialization (not automatically fixable)
> • NoWhitespaceAfter with ARRAY_INIT token
> • ParenPad
>
> Note that I’m not happy with removing that last rule. I agree with
> Alexios that a consistent style makes reading and debugging easier. That
> wouldn’t be too bad if the original style were preserved in every source
> file, but this will clearly not happen. In fact, the mixing of styles
> has already started after the complex scripts patch was applied. I still
> removed the rule though.
>
> However, I left the MethodParamPad rule in order to remain compliant
> with Sun’s recommendations:
>
> http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141388.html#475
> I’d also like to keep the NoWhitespaceAfter rule, as whitespace after
> unary operators increases too much the risk of misreading the statement
> IMO.
>
> Finally, I left the LineLength rule to 110. Long lines impede code
> readability too much IMO. They also make side-by-side comparison harder.
> I note that some even recommend to leave the check to 100. I think 110
> should be an acceptable compromise.
>
> Please let me know what you think.
> Thanks,
> Vincent
>
>
> On 03/02/12 17:45, Vincent Hennebert wrote:
> > Hi All,
> >
> > it is well-known that people are not happy with the Checkstyle file we
> > have in FOP. And there’s no point enforcing the application of
> > Checkstyle rules if we don’t agree with them in the first place.
> >
> > I’ve finally taken on me to create a new Checkstyle file that follows
> > modern development practices. I’ve been testing it on my own projects
> > for a few months now and I’m happy with it, so I’d like to share it with
> > the community. The idea is that once we’ve reached consensus on the
> > Checkstyle rules we want to apply, we could set up a no warning policy
> > and enforce it by running Checkstyle in CI.
> >
> > I’m also taking this as an opportunity to propose that we adopt a common
> > Checkstyle policy to all the sub-projects of XML Graphics. So once we’ve
> > agreed on a set of rules we would apply them to FOP and XGC immediately,
> > and eventually also to Batik, and keep them in sync.
> >
> > We would also apply the rules to the test files as well as the main
> > code. Tests are as important as the actual code and there is no reason
> > why they shouldn’t be checked.
> >
> > It is likely that the current code will not be compliant with the new
> > rules. However, most of them are really just about the syntax, so
> > I believe it should be fairly straightforward to make the code at least
> > 90% compliant just by applying Eclipse’s command-line code formatter.
> >
> > Please find the Checkstyle file attached. It is based on Checkstyle 5.5
> > and basically follows Sun’s recommendations for Java styling with a few
> > adaptations. What’s noteworthy is the following:
> >
> > • Removed checks for Javadoc. What we want is quality Javadoc, and that
> >   is not something that Checkstyle can check. Having Javadoc checks is
> >   counter-productive as it forces us to put {@inheritDoc} everywhere, or
> >   to create truly useless doc like the following:
> >   /**
> >    * Returns the thing.
> >    * @return the thing
> >    */
> >   public Thing getThing() {
> >       return thing;
> >   }
> >   This is just clutter really. I think it should be left to peer review
> >   to check whether a Javadoc comment is properly written, or whether the
> >   lack thereof is justified. There’s an excellent blog entry from
> >   Torsten Curdt about this:
> >   http://vafer.org/blog/20050323095453/
> > • Removed check for file and method lengths. I don’t think it makes
> >   sense to define a maximum size for files and methods. Sometimes
> >   a 10-line method is way too big, sometimes it makes sense to have it
> >   reach 20 lines. Same for files: it’s ok to reach 1000 lines if the
> >   class contains several inner classes. If it doesn’t, then it’s
> >   probably too big. I don’t think there is any definite figure we can
> >   agree on and blindly follow, so I think sizes should be left to peer
> >   review.
> > • However, I left the check for maximum line length because unreasonably
> >   long lines make the code hard to follow. I increased it to 110
> >   though to follow the evolution of monitor sizes. But as Peter
> >   suggested me, we probably want to keep it low in order to make
> >   side-by-side comparison easy.
> > • I added a check for the order of imports; this is to reduce noise in
> >   diffs when committing. I think most of us have configured their IDE to
> >   automatically organise imports when saving changes to a file. This is
> >   a great feature because it allows to keep the list of imports
> >   up-to-date. But in order to avoid constant back and forth changes when
> >   different committers change the same file, I think it makes sense that
> >   we all have the same configuration. I modeled this list after
> >   Jeremias’ one, that I progressively inferred from his commits.
> >
> > Please let me know what you think. I’m inclined to follow lazy consensus
> > on this, and apply the proposed changes if nobody has objected within
> > 2 weeks. If anybody feels that a formal vote is necessary, feel free to
> > say so.
> >
> > Thanks,
> > Vincent
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: general-help@xmlgraphics.apache.org
>