checkstyle

Checkstyle config used by Maven and Eclipse

徘徊边缘 提交于 2019-12-02 11:21:08
问题 I am try to use the same Checkstyle configuration file with both Maven and Eclipse. The module SuppressionCommentFilter works as expected in Eclipse, but Maven reports TreeWalker is not allowed as a parent of SuppressionCommentFilter If I move it from TreeWalker to Checker the error goes away, but Checkstyle does not process the ignore comments. I am using Checkstyle 8.12 with Eclipse, but have not found a way to use other than 6.18 with Maven. Since this module had been part of Checkstyle

Getting the Checkstyle plug-in in Eclipse to use your custom check

淺唱寂寞╮ 提交于 2019-12-02 03:43:59
I've written a custom check MethodLimitCheck.java . I also have a custom configuration file myconfigurationfile.xml which contains the following: module name="Checker"> <!-- interfaces are limited to 10 methods --> <module name="com.mycompany.checks.MethodLimitCheck"> <property name="tokens" value="INTERFACE_DEF"/> <property name="max" value="10"/> </module> <!-- normal classes are limited to 25 methods --> <module name="com.mycompany.checks.MethodLimitCheck"> <property name="tokens" value="CLASS_DEF"/> <property name="max" value="15"/> </module> </module> </module> How do I get the checkstyle

Checkstyle rule to limit interactions between root packages (with ImportControl?)

南笙酒味 提交于 2019-12-02 03:33:22
问题 How can I create a Checkstyle rule to limit interactions between different root packages? I have the following 3 root packages: models views controllers (They are not something like com.mycompany.myproject.models . They are root packages .) I wanted to disallow access from models to views and from views to models (and some others). I try to use the ImportControl-Checker from Checkstyle: Try 1: Use one single import-control.xml . Problem: I can provide only one Root-XML-Element ( <import

Generating Checkstyle Reports (with extended checks)

人盡茶涼 提交于 2019-12-02 03:29:55
I have some own extended checks. I have exported them as plug-in and in Eclipse, they are showing warning/error. So the extended checks are working fine. Now I want to generate a report of the violations in HTML format . I have checked this , and this works fine if no extended checks are included in rule.xml file. But in case of extended checks, the ant build is giving the error. The error is: BUILD FAILED D:\Java_Work\JUnit_CheckStyle\buildCheckStyle.xml:12: Unable to create a Checker: cannot initialize module TreeWalker - Unable to instantiate InterfaceModifier InterfaceModifier is my

Is there a CheckStyle rule to force if else keywords to be on the same line in an if/else ladder?

帅比萌擦擦* 提交于 2019-12-02 01:40:53
Based on this question it appears that the default template for CheckStyle will allow if else ladders to separate the if and else with a line break. Meaning I would like this code to be flagged as a violation: if (true) { System.out.println("20"); } else if (true) { System.out.println("30"); } Is there a CheckStyle rule to prevent this? Looking over the docs, I don't see one, and I'd prefer not to use the generic regex rule, if I don't have to. Also, if I use the GenericIllegalRegexp module, multiline regex don't seem to work. Is there some remedy to this? VonC I am not sure you can easily

Checkstyle rule to limit interactions between root packages (with ImportControl?)

廉价感情. 提交于 2019-12-02 01:05:47
How can I create a Checkstyle rule to limit interactions between different root packages? I have the following 3 root packages: models views controllers (They are not something like com.mycompany.myproject.models . They are root packages .) I wanted to disallow access from models to views and from views to models (and some others). I try to use the ImportControl-Checker from Checkstyle: Try 1: Use one single import-control.xml . Problem: I can provide only one Root-XML-Element ( <import-control pkg="models"> ) and this contains only one Package (but I want to have more than one). Try 2: Use

Using Jenkins and Php Code Sniffer

六眼飞鱼酱① 提交于 2019-12-02 00:34:21
问题 I'm trying to use the Php Code Sniffer plugin in Jenkins. It generates a checkstyle.xml file but there are no errors inside, and I know that I should have. Here's the containt of my checkstyle.xml : <?xml version="1.0" encoding="UTF-8"?> <checkstyle version="1.5.0RC2"> </checkstyle> My build.xml file for Jenkins is : <target name="phpcs" > <exec executable="phpcs"> <arg line="--report=checkstyle --report-file=${project.basedir}/build/logs/checkstyle.xml --standard=Zend ${project.basedir}/*

Using Jenkins and Php Code Sniffer

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 22:22:01
I'm trying to use the Php Code Sniffer plugin in Jenkins. It generates a checkstyle.xml file but there are no errors inside, and I know that I should have. Here's the containt of my checkstyle.xml : <?xml version="1.0" encoding="UTF-8"?> <checkstyle version="1.5.0RC2"> </checkstyle> My build.xml file for Jenkins is : <target name="phpcs" > <exec executable="phpcs"> <arg line="--report=checkstyle --report-file=${project.basedir}/build/logs/checkstyle.xml --standard=Zend ${project.basedir}/*.php" /> </exec> </target> And when i do it in command line, I have a different result. My command : phpcs

Java代码规范、格式化和checkstyle检查配置文档

元气小坏坏 提交于 2019-12-01 21:16:08
为便于规范各位开发人员代码、提高代码质量,研发中心需要启动代码评审机制。为了加快代码评审的速度,减少不必要的时间,可以加入一些代码评审的静态检查工具,另外需要为研发中心配置统一的编码模板和代码格式化模板。 Java代码规范、格式化和checkstyle检查配置文档下载地址: http://www.blogjava.net/Files/amigoxie/Java 代码规范、格式化和checkstyle检查配置文档.rar 1 、配置统一的编码模板 1.1 配置编码模板 在 Eclipse 或 MyEclipse 中点击 Window -> Preferences 菜单,点击左侧的“ Java ” -> “ Code Style ” -> “ Code Templates ”,界面如下图所示: 点击上图右侧的“ Import ”按钮,在弹出的文件选择窗口选择公司自己的编码模板,例如 eclipse_templates.xml 文件(仅提供参考,可自行修改)。在“ Configure generated code and comments ”区域有“ Comments ”和“ Code ”两个菜单,点开后可以看到各种类型的注释和编码模板定义: 可以点击上面的各种类型查看该模板文件的定义。 例如文件注释定义: 文件注释定义中的文件作者取自所在系统登录用户,若不正确时,可点击“ Edit

Checkstyle equivalent for JSPs?

泄露秘密 提交于 2019-12-01 20:53:39
Is there any tool to do for JSP files what checkstyle does for Java files? The ideal would be to include JSP checking on checkstyle, but as far as I can see, this isn't possible. I would like for example to check JSP files for : Indentation style Right placements of certain constructs Tab / space check Check for use of scriplets Thanks Emerson Yes, there is something similar (but not for exactly those checks): You can use IntelliJ IDEA's "Inspection" functionality to inspect JSPs for various problems, and those inspections can be run from the command line too (use inspect.bat in IntelliJ's