commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Neidhart <thomas.neidh...@gmail.com>
Subject Re: [math] Checkstyle
Date Tue, 19 Mar 2013 20:30:10 GMT
On 03/19/2013 09:22 PM, Luc Maisonobe wrote:
> Hi Thomas,
> 
> Le 19/03/2013 20:49, Thomas Neidhart a écrit :
>> On 03/19/2013 08:43 PM, Thomas Neidhart wrote:
>>> On 03/19/2013 08:18 PM, Luc Maisonobe wrote:
>>>> Hi Jared,
>>>>
>>>> Le 19/03/2013 17:14, Becksfort, Jared a écrit :
>>>>> Hello,
>>>>>
>>>>> I am using the Apache Common XML file to format my code submissions
>>>>> in Eclipse.  Gilles says my last submission has some CheckStyle
>>>>> warnings, so I installed the CheckStyle plugin.  It gives tons of
>>>>> warnings, including some that go against the posted style guidelines,
>>>>> such as "All public methods must advertise all exceptions they
>>>>> generate...".  It also complains about lines being too wide, but the
>>>>> XML file configuration does not wrap certain types of lines.  There
>>>>> are lots of others, including spaces following the asterisks in the
>>>>> javadocs, which surely the autoformatter could handle.
>>>>
>>>> The problem you encounter is known. Basically, it is due to the eclipse
>>>> checkstyle plugin configuration ignoring the checkstyle.xml file. When
>>>> you ask eclipse to run checkstyle, it uses a completely different
>>>> default configuration, and of course will raise thousands of warnings.
>>>>
>>>> We have set up the appropriate setting for the maven checkstyle plugin
>>>> (see the pom.xml which specifies that ${basedir}/checkstyle.xml and
>>>> ${basedir}/license-header.txt should be used).
>>>>
>>>> Configuring the eclipse checkstyle plugin is completely different. I
>>>> tried to make it use the same files, but failed up to now. I will
>>>> perhaps give it another try later on.
>>>
>>> Go to Project Properties | Checkstyle | Local Check Configurations
>>>
>>> Create a new Project Relative Configuration, select the checkstyle.xml
>>> file. Give it a meaningful name.
>>>
>>> Click on protect Checkstyle configuration file.
> 
> Great!
> 
>>>
>>> For math this is not necessary, but normally you would need to resolve
>>> some properties, like location of header template file.
> 
> I followed your advice, but the plugin complained about the license
> header file missing. I had to set the checkstyle.header.file additional
> property to ${basedir}/license-header.txt for the plugin to work correctly.

ah right, I disabled the header check locally, we should also consider
adding the severity override by default.

>>>
>>> When you are done, click on the Main tab, and select the newly created
>>> configuration, otherwise the default one is used which creates lots of
>>> warnings.
>>>
>>> Something that I usually add to the checkstyle.xml:
>>>
>>>   <property name="severity" value="warning"/>
>>>
>>> As the warnings are otherwise reported as errors, which is annyoing.
>>
>> to only check the src/main/java folder, do the following:
>>
>> On the Main tab of Checkstyle configuration, disable simple
>> configuration checkbox, then edit the existing file set, and use a
>> pattern like this:
>>
>> src/main/java/.*\.java
> 
> Many thanks Thomas, this really helped a lot!

You are welcome, that way I have always seen in my eclipse environment
where there are checkstyle warnings, and when I had the time/interest
could fix them right away.

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message