Problems with RegexpMultiline Pattern for detecting windows line endings

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problems with RegexpMultiline Pattern for detecting windows line endings

Patrick Gottschaemmer
Hello,

the following checkstyle code

<module name="Checker">
    <module name="RegexpMultiline">
        <property name="format" value=".*(\r\n)(.*|\r\n|\n)*"/>
  </module>
</module>
should actually detect a single windows line ending in a textfile. However, my checkstyle-result looks like this:
(for a file with only windows new lines).

<error line="1" severity="error" message="Line matches the illegal pattern &apos;.*(\r\n)(.*|\r\n|\n)*&apos;." source="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpMultilineCheck"/>
<error line="2" severity="error" message="Line matches the illegal pattern &apos;.*(\r\n)(.*|\r\n|\n)*&apos;." source="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpMultilineCheck"/>
<error line="3" severity="error" message="Line matches the illegal pattern &apos;.*(\r\n)(.*|\r\n|\n)*&apos;." source="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpMultilineCheck"/>
...

So, what I actually want is:

    - Detect one (or more) windows line endings in a file and print out one error for it (e.g., with the first appeareance as error line).
    - NOT one error for each line with a windows line ending
    - Line endings in a file could be mixed (windows + unix new lines), so a simple
<module name="NewlineAtEndOfFile">
    <property name="lineSeparator" value="lf"/>
won't do the trick unfortunately.
I've tried some variations of the pattern above, but I just can't find the missing part.
Is this maybe due to the fact how checkstyle parses Regular Expressions?

Best regards
Patrick Gottschaemmer

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
Checkstyle-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user