checkstyle

Maven 2 checkstyle plugin version 2.5 - Problem with configLocation

匿名 (未验证) 提交于 2019-12-03 00:48:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using checkstyle plugin in maven 2. I now want to switch my config file, from the default one to a) an online file, or b) a local file. I tried the following two things, which both didnt work. Any suggestions? A) Local file, which is directly in my project folder next to the pom.xml <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <configLocation>checkstyle.xml</configLocation> </configuration> </plugin> B) Remote file, that is stored on a server <plugin> <groupId>org

checkStyle 常见错误分析

匿名 (未验证) 提交于 2019-12-03 00:22:01
要求用CheckStyle工具对代码进行自动的静态代码分析。 第一次运行checkStyle就头大了 居然有1.5w个除错误标记。 从网上下了google的编码风格文件导入eclipse的formatter后再次运行后结果稍微好了一些。 开始一个错误一个错误分析的时候很多错误仅仅看提示完全理解不了,于是就整理了一下。 这里列出的错误只包含了在我代码中出现的6k处错误中部分出现过的。 'X' 缩进了X个 checkStyle要求2个空格缩进 'X' 修饰符顺序weifan违反JLS建议 修饰符没有按照JLS建议排序(e.g. abstract public 应写成public abstract) Javadoc 的第一句缺少一个结束时期 Javadoc 的第一行内容应该加上'.' 从switch块的前一个分支落入 查资料说是default分支不是最后一个分支, 然而我这里是由于前一个case少了break。【丢人】 'X' 子元素缩进了X个 checkStyle要求2个空格缩进 每一个变量的定义必须在它的声明处,且在同一行 要求同一行只声明一个变量。 变量'X 行)若需要存储该变量的值,请将其声明为final 从未改变值的变量应声明为final 数组大括号位置错误 String[ ] args 应改为 String args[ ] 导入语句'X' 的字典顺序错误,应在X前

Maven check style as a part of the build

夙愿已清 提交于 2019-12-02 22:17:18
Is there a possibility to somehow force maven to fail the build if there are some checkstyle errors? Now I have to run site goal to generate javadocs and checkstyle reports. I want to make it on install goal and if checkstyle has some error I need build to fail. Is this possible to achieve? Now I have my checkstyle in reporting block of maven: <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.9.1</version> <configuration> <configLocation>src/test/resources/checkstyle.xml</configLocation> </configuration> <

Empty new line at the end of the java source files

…衆ロ難τιáo~ 提交于 2019-12-02 21:37:45
In my current project we always insert empty new line at the end of the java source files. We also enforce this with CheckStyle (with error level). I was searching for this topic for a long time, but unfortunately I can't find any convincing reason for this. Seems that other developers are pretty indifferent about this because they just checked one checkbox in eclipse formatter and it's done automatically. But I still don't know why is it needed and why is it can be important). So my question is: Why are empty lines at the end of Java source files need? Is it a current need or a relic of the

Is there a style checker for c++?

社会主义新天地 提交于 2019-12-02 21:14:59
I have worked with java for a while now, and I found checkstyle to be very useful. I am starting to work with c++ and I was wondering if there is a style checker with similar functionality. I am mainly looking for the ability to write customized checks. What about Vera++ ? Vera++ is a programmable tool for verification, analysis and transformation of C++ source code. Vera++ is mainly an engine that parses C++ source files and presents the result of this parsing to scripts in the form of various collections - the scripts are actually performing the requested tasks. Click here to see a more

Ignoring of Checkstyle warnings with annotation @SuppressWarnings

感情迁移 提交于 2019-12-02 17:51:54
I try to ignore or disable some useless warnings in eclipse by checkstyle with annotation @SuppressWarnings like How to disable a particular checkstyle rule for a particular line of code? but this don't work for me. Here is the checkstyle.xml <module name="Checker"> <property name="severity" value="warning"/> <module name="SuppressWarningsFilter"/> <module name="TreeWalker"> <property name="tabWidth" value="4"/> <module name="FileContentsHolder"/> <module name="SuppressWarningsHolder"/> <module name="CyclomaticComplexity"/> ... and here the java code: @SuppressWarnings("checkstyle

IDEA插件之CheckStyle

你离开我真会死。 提交于 2019-12-02 16:33:39
1、是个啥?   CheckStyle是一个检测代码格式是否满足规范的工具,其中用得比较多的是Google和Sun 2、下载安装插件   File -> Settings -> Plugins -> Marketplace 搜索安装“CheckStyle” 点击下载checkstyle插件。安装完重启IDEA 3、checkStyle的使用 在代码编辑框右键,选择“Check Current File”可以检查当前文件: 之后底栏会出现窗口,显示结果: 可以选择sun 格式还是google格式: 来源: https://www.cnblogs.com/GuixinChan/p/11754644.html

Is SonarQube Replacement for Checkstyle, PMD, FindBugs?

独自空忆成欢 提交于 2019-12-02 13:54:12
We are working on a web project from scratch and are looking at the following static code analysis tools. Conventions (Checkstyle) Bad practices (PMD) Potential bugs (FindBugs) The project is built on Maven. Instead of using multiple tools for the purpose, I was looking at a single flexible solution and came across SonarQube. Is it true that we can achieve the results from Checkstyle, PMD and Findbugs with SonarQube? Sonar will run CheckStyle, FindBugs and PMD, as well as a few other "plugins" such as Cobertura (code coverage) by default for Java projects. The main added value, however, is

Checkstyle config used by Maven and Eclipse

試著忘記壹切 提交于 2019-12-02 13:16:58
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 since 3.5 I don't see how that could be the problem. Any suggestions what is wrong? <module name="Checker

Generating Checkstyle Reports (with extended checks)

五迷三道 提交于 2019-12-02 13:11:57
问题 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