如何告诉Checkstyle检查所有行中的换行符/换行符LF而不是CRLF? [英] How to tell Checkstyle to check all lines for linefeed / newline LF and not CRLF?

查看:250
本文介绍了如何告诉Checkstyle检查所有行中的换行符/换行符LF而不是CRLF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以检查文件是否仅使用LF而在检查样式中没有使用CRLF,反之亦然?

Is there a way to check if the file is using LFs only and no CRLFs or vice versa in checkstyle?

我发现的唯一支票是

NewlineAtEndOfFile

但是我只搜索文件末尾的内容吗?

But I search for more as only at the end of the file?

推荐答案

仅用于补充Michal Kordas的好答案.

以下是经过稍微修改的配置,它将仅与第一个错误的换行符匹配,并且也禁止Mac OS行尾(CR):

Below is a slightly modified configuration, which will only match the first wrong newline and forbid also the Mac OS Line Endings (CR):

<module name="RegexpMultiline">
    <property name="format" value="(?s:(\r\n|\r).*)"/>
    <property name="message" value="CRLF and CR line endings are prohibited, but this file uses them."/>
</module>

它已由Michael Vorburger在本次讨论中发布,,所以对他表示敬意-为了完整起见,我将其发布在这里.

It has been posted by Michael Vorburger in this discussion, so kudos for him - I've posted it here for completeness.

这篇关于如何告诉Checkstyle检查所有行中的换行符/换行符LF而不是CRLF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆