Sonar

Checkstyle implementation only allows one check per Checkstyle class

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.2
  • Fix Version/s: 2.3
  • Component/s: Rules
  • Labels:
    None
  • Number of attachments :
    0

Description

The Sonar schema, or at least way it's used for CheckStyle, seems to limit the usefulness of CheckStyle.

Root cause is that class name appears to be used as a unique key for coding rules. However, it's not uncommon for a CheckStyle rule set to have several rules for the same class. GenericIllegalRegExp is a good example of this type of check, where a rule set may have multiple regexp being searched for, with different messages and possibly different priorities. IllegalToken is another.

The eclipse-cs project had a similar issue and included the ID for each check in the configuration GUI for checkstyle (http://eclipse-cs.sourceforge.net/releasenotes/4.3.2/release_notes.html)

Issue Links

Activity

Hide
Michel Pawlak added a comment -

Hello,

Just my "two cent". We wrote generic checkstyle extensions we can now instanciate by providing different parameters. However, as Sonar's profile manager only allows to have one extension per class name, we can only use each extension once.

Thus, we also need this issue to be fixed. Please make possible the registration of multiple extensions using the same class name OR allow users to instanciate a single extension multiple times at profile creation/update time.

Best regards,

Michel

Show
Michel Pawlak added a comment - Hello, Just my "two cent". We wrote generic checkstyle extensions we can now instanciate by providing different parameters. However, as Sonar's profile manager only allows to have one extension per class name, we can only use each extension once. Thus, we also need this issue to be fixed. Please make possible the registration of multiple extensions using the same class name OR allow users to instanciate a single extension multiple times at profile creation/update time. Best regards, Michel
Hide
Simon Brandhof added a comment - - edited

Planned for the version 1.5.

Show
Simon Brandhof added a comment - - edited Planned for the version 1.5.
Hide
Freddy Mallet added a comment -

We finally won't be able to deliver this functionnality in version 1.5. I'm increasing priority from Major to Critical.

Show
Freddy Mallet added a comment - We finally won't be able to deliver this functionnality in version 1.5. I'm increasing priority from Major to Critical.
Hide
Michel Pawlak added a comment -

Hi Freddy,

Will you be able to deliver this functionality for 1.6 ?

Show
Michel Pawlak added a comment - Hi Freddy, Will you be able to deliver this functionality for 1.6 ?
Hide
Freddy Mallet added a comment -

With Checkstyle, property name "id" can be used in order to filter error on different checks but on the same rule.

<property name="id" value="checkId"/>

First check on rule DescendantToken :

<module name="DescendantToken">
    <property name="id" value="stringEqual"/>
    <property name="tokens" value="EQUAL,NOT_EQUAL"/>
    <property name="limitedTokens" value="STRING_LITERAL"/>
    <property name="maximumNumber" value="0"/>
    <property name="maximumDepth" value="1"/>
</module>

Second check on rule DescendantToken :

<module name="DescendantToken">
    <property name="id" value="switchNoDefault"/>
    <property name="tokens" value="LITERAL_SWITCH"/>
    <property name="maximumDepth" value="2"/>
    <property name="limitedTokens" value="LITERAL_DEFAULT"/>
    <property name="minimumNumber" value="1"/>
</module>
Show
Freddy Mallet added a comment - With Checkstyle, property name "id" can be used in order to filter error on different checks but on the same rule. <property name="id" value="checkId"/> First check on rule DescendantToken :
<module name="DescendantToken">
    <property name="id" value="stringEqual"/>
    <property name="tokens" value="EQUAL,NOT_EQUAL"/>
    <property name="limitedTokens" value="STRING_LITERAL"/>
    <property name="maximumNumber" value="0"/>
    <property name="maximumDepth" value="1"/>
</module>
Second check on rule DescendantToken :
<module name="DescendantToken">
    <property name="id" value="switchNoDefault"/>
    <property name="tokens" value="LITERAL_SWITCH"/>
    <property name="maximumDepth" value="2"/>
    <property name="limitedTokens" value="LITERAL_DEFAULT"/>
    <property name="minimumNumber" value="1"/>
</module>
Hide
Michel Pawlak added a comment -

Last update to this ticket was made in April, do you have any visibility on when it will be resolved ?

This is a rather important issue for users developping their own checks.

Michel

Show
Michel Pawlak added a comment - Last update to this ticket was made in April, do you have any visibility on when it will be resolved ? This is a rather important issue for users developping their own checks. Michel
Hide
Centre de Suport de Canigó added a comment -

We have developed some custom rules with Checkstyle->RegexpMultiline but it doesn't work Sonar, only one rule is executed.

When we execute Checkstyle directly it works.

When is expected this issue to be resolved?

Thanks.

Show
Centre de Suport de Canigó added a comment - We have developed some custom rules with Checkstyle->RegexpMultiline but it doesn't work Sonar, only one rule is executed. When we execute Checkstyle directly it works. When is expected this issue to be resolved? Thanks.
Hide
Freddy Mallet added a comment -

This ticket is planned to be fixed in Sonar 2.3

Show
Freddy Mallet added a comment - This ticket is planned to be fixed in Sonar 2.3
Hide
Simon Brandhof added a comment -

The module id is not exported in the Checkstyle XML report.

Show
Simon Brandhof added a comment - The module id is not exported in the Checkstyle XML report.

People

Vote (16)
Watch (9)

Dates

  • Created:
    Updated:
    Resolved: