checkstyle

Checkstyle and Findbugs for changed files only on Jenkins (and/or Hudson)

元气小坏坏 提交于 2019-12-06 03:26:23
问题 We work with a lot of legacy code and we think about introducing some metrics for new code. Is it possible to let Findbugs and Checkstyle run on changed files only instead of a complete project? It would be nice to assure that only file with a minimum of quality is checked in, but the code base itself is not (yet) touched and evaluated not to confuse people by thousands of issues. 回答1: In theory, it would be possible. You would use a shell script to parse the SVN (or whatever SCM) change logs

SonarQube - how is it used

孤者浪人 提交于 2019-12-06 00:11:13
问题 I have a simple problem, with a simple answer probably, but I can't find what is it. We want to deploy SonarQube along with Checkstyle and some other tools, but we can't find out is it meant for a centralized, server deployment, or on each developer machine? All tutorials show installations on separate machines and being used in the localhost, while there is a public instance example, and the requirements and specs certainly look service-like. On the other hand, I'm not getting how do the

How can I configure checkstyle in maven?

℡╲_俬逩灬. 提交于 2019-12-05 17:48:52
I am using Maven I have a parent module and some other modules. They look like: PARENT ├── pom.xml ├── ModulA | └── pom.xml └── ModulB ├── pom.xml └── folder └── checkstyle.xml I tried to replace the rules with my own rules. But it ignores my rules. I added the plug-in to parent pom.xml <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.9.1</version> <configuration> <includeTestSourceDirectory>true</includeTestSourceDirectory> <configLocation> ${basedir}/../ModulB/folder/checkstyle.xml </configLocation> </configuration> </plugin>

Is there any Checkstyle/PMD/Findbugs rule to force “else if” to be on the same line?

为君一笑 提交于 2019-12-05 10:04:24
In our project for chained if/else/if we would like to have following formatting: if (flag1) { // Do something 1 } else if (flag2) { // Do something 2 } else if (flag3) { // Do something 3 } And forbid following one: if (flag1) { // Do something 1 } else { if (flag2) { // Do something 2 } else { if (flag3) { // Do something 3 } } } Is there some predefined rule in either of listed above static code analysis tools to force this code style? If no - I know there is an ability to write custom rules in all of those tools, which one would you suggest to implement such a rule (not really familiar

Generate Coding guidelines from CheckStyle

岁酱吖の 提交于 2019-12-05 08:19:04
Is there a way to generate a 'nice' Coding conventions / guidelines document from existing CheckStyle configuration file? This document must contain the description of the rules enforced, and the configuration values (like the max line length, violation severity, etc). The benefit of having such a document is to ramp up a new team member faster, without reading CheckStyle configuration file. I would generally advise against generating even parts of a coding guidelines document, because that would cause acceptance problems with your software engineers. Also, the Checkstyle rules should, in my

converting an eclipse formatter file to a checkstyle file

拜拜、爱过 提交于 2019-12-05 05:44:39
I have an eclipse formatting file (which contains some configurations) and i want to make the same thing (these configurations) for a checkstyle file to use after with maven build. The Eclipse-Checkstyle plugin provides an export feature to export your preferences. crasp Unfortunately, there is no way to convert a formatter file to a checkstyle ruleset at the moment. You have to do it the other way around as explained here . Otherwise you have to adjust every setting in your formatter manually for checkstyle. 来源: https://stackoverflow.com/questions/8327498/converting-an-eclipse-formatter-file

Checkstyle rule to prevent invocation of some methods and constructors

余生长醉 提交于 2019-12-05 04:41:43
Is it possible to use Checkstyle to forbid usage of some constructors or method that use system-dependent defaults (locale, charset, etc..). I prefer to enforce a policy where the programmer should be explicit about system-dependent values. So I consider the following items to be dangerous: all the constructors of java.io.FielWriter using system-dependent encoding the OutputStreamWriter(OutputStream os) constructor of java.io.OutputStreamWriter using system-dependent encoding the java.lang.String.toLowerCase() method using system default locale The java.util.Calendar.getInstance() method using

用Gradle构建Spring Boot项目

我只是一个虾纸丫 提交于 2019-12-05 03:10:20
相比起Maven的XML配置方式,Gradle提供了一套简明的DSL用于构建Java项目,使我们就像编写程序一样编写项目构建脚本。本文将从无到有创建一个用Gradle构建的Spring Boot项目,并在此过程中讲到Gradle的一些典型用法。 本文Github代码:https://github.com/davenkin/gradle-spring-boot.git 创建Gradle工程 Gradle采用了与Maven相同的目录组织结构,你可以通过Spring Initializr网站创建Spring Boot工程。但是在本文中,我们将全部通过命令行操作创建Spring Boot工程。首先在命令行中创建如下目录结构: └── src ├── main │ └── java └── test └── java 然后在src同级目录中添加一个build.gradle文件,内容如下: apply plugin: 'java' 大功告成,一个用Gradle构建的Java项目创建好了,尽情用以下命令编译并打包咱们的Java项目吧: gradle build 只是现在咱们的Java项目还是一个空架子,不用急,在下文中我们将一步一步在这个空架子中搭建一个有血有肉的Spring Boot项目。 值得一提的是,虽然此时的build.gradle文件中只有一行配置( apply plugin:

玩转Eclipse — 自动代码规范检查工具Checkstyle

ε祈祈猫儿з 提交于 2019-12-05 02:24:58
http://blog.csdn.net/jmyue/article/details/11110857 大项目都需要小组中的多人共同完成,但是每个人都有自己的编码习惯,甚至很多都是不正确的。那么如何使小组所有开发人员都遵循某些编码规范,以保证项目代码风格的一致性呢?如果硬性地要求每个开发人员在提交代码之前,都要对照的编码规范将自己的代码检查一遍,将是一个非常枯燥而且耗时的任务。Checkstyle是一个开源代码分析工具,能够帮助开发人员保证他们的代码遵循一定的代码规范。Checkstyle通过不断地检查你的代码,一旦发现有违反定义的代码规范的地方就立马提示,以便开发人员能够及时发现和修改不规范代码。Checkstyle在Eclipse中的插件是 eclipse-cs 。 1. 安装Checkstyle插件 Eclipse菜单栏上选择 Help -> Install New Software...,进入如下安装界面: 点击“Add...”打开Add Repository对话框,如图输入Name和Location,点击“OK”。 选择刚刚添加的JAutodoc,一直点击“Next >”直到安装结束。 2. 配置Checkstyle Eclipse菜单栏上选择 Window -> Preferences -> Checkstyle,进入如下设置界面: 在Global Check

安装checkstyle eclipse插件

与世无争的帅哥 提交于 2019-12-05 02:24:44
安装checkstyle eclipse插件 输入框中,输入 checkstyle ,点击 Go ,选择 Checkstyle Plug-in 6.11.1 ,并安装 配置checkstyle Eclipse中,点击 Window -> Preferences 选择 Checkstyle 点击 New Type 选择 External Configuration File 点击 Browse 选择checkstyle的规则文件: checkstyle_custom.xml内容如下: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> <!-- This configuration file was written by the eclipse-cs plugin configuration editor --> <!-- Checkstyle-Configuration: checkstyle_custom Description: none --> <module name="Checker">