New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomImportControl bad document examples that could lead to false positive on 'special group' #3590

Closed
Vladlis opened this Issue Nov 28, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@Vladlis
Member

Vladlis commented Nov 28, 2016

vlad@vlad-W65-67SB ~/Documents $ java -jar checkstyle-7.3-all.jar -c my_check.xml Input.java
Starting audit...
[WARN] /home/vlad/Documents/Input.java:4: Import statement for 'com.github.checkstyle.publishers.SourceforgeRssPublisher' is in the wrong order. Should be in the 'SPECIAL_IMPORTS' group, expecting not assigned imports on this line. [CustomImportOrder]
Audit done.
vlad@vlad-W65-67SB ~/Documents $ cat Input.java 
package com.puppycrawl.tools.checkstyle.checks.imports;

import com.github.checkstyle.publishers.MailingListPublisher;
import com.github.checkstyle.publishers.SourceforgeRssPublisher;
import com.github.checkstyle.publishers.TwitterPublisher;
import com.github.checkstyle.publishers.XdocPublisher;

public class Input { }

vlad@vlad-W65-67SB ~/Documents $ cat my_check.xml 
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name = "Checker">
    <property name="charset" value="UTF-8"/>
    <property name="severity" value="warning"/>

    <module name="TreeWalker">
         <module name="CustomImportOrder">
             <property name="customImportOrderRules" value="STATIC###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS"/>
             <property name="specialImportsRegExp" value="org"/>
         </module>
    </module>
</module>

Expected: no violations.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@MEZk

This comment has been minimized.

Show comment
Hide comment
@MEZk

MEZk Dec 11, 2016

Contributor

@Vladlis @romani

It is not a false positive since @Vladlis specified regexp for specialImportsRegExp which matches the substring in SourceforgeRssPublisher. The correct regexp is ^org.*$ I think that such example should be in xdoc.

Contributor

MEZk commented Dec 11, 2016

@Vladlis @romani

It is not a false positive since @Vladlis specified regexp for specialImportsRegExp which matches the substring in SourceforgeRssPublisher. The correct regexp is ^org.*$ I think that such example should be in xdoc.

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Dec 11, 2016

Member

Yes, lets add it to xdoc for good example of regexp that is ready to use and not errorprone

Member

romani commented Dec 11, 2016

Yes, lets add it to xdoc for good example of regexp that is ready to use and not errorprone

@romani romani changed the title from CustomImportControl false positive on 'special group' to CustomImportControl bad document examples that could lead to false positive on 'special group' Dec 11, 2016

romani added a commit that referenced this issue Dec 11, 2016

Issue #3590: CustomImportControl bad document examples that could lea…
…d to false positive on 'special group'

@romani romani self-assigned this Dec 11, 2016

romani added a commit that referenced this issue Dec 11, 2016

Issue #3590: CustomImportControl bad document examples that could lea…
…d to false positive on 'special group'
@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Dec 11, 2016

Member

fix is merged

Member

romani commented Dec 11, 2016

fix is merged

@romani romani closed this Dec 11, 2016

@romani romani added this to the 7.4 milestone Dec 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment