checkstyle

Gradle Checkstyle Plugin Console Output

早过忘川 提交于 2019-12-10 19:24:29
问题 The Gradle Checkstyle plugin produces a lot of console output when Gradle is run with the -info option. This output tends to swamp more useful output from other tasks. The plugin is configured as follows: checkstyle { toolVersion = '6.15' configFile = file("$rootProject.projectDir/config/checkstyle/checkstyle.xml") } To see the problem, the build can be launched like this: ./gradlew clean checkStyleMain -info The output then shows in the console as follows (edited for brevity!): :core

Duplicate checkstyle warnings in a jenkins maven multimodule job

你说的曾经没有我的故事 提交于 2019-12-10 19:17:19
问题 I have a jenkins maven job with an aggregator pom and a bunch of submodules. When jenkins displays the checkstyle warnings it does it like so: submodule 1: 10 warnings submodule 2: 10 warnings Aggregator module: 20 warnings Total: 40 warnins In other words, the aggregator (rightfully?) aggregates the warnings found in the submodules, which wouldn't be such a big problem if it weren't because the total then becomes double what it should be. Does any one know what the problem is? Thanks! 回答1:

Dependencies added in pluginManagement not considered during reporting

我怕爱的太早我们不能终老 提交于 2019-12-10 16:23:39
问题 I am trying to configure the Maven Checkstyle Plugin for reporting and would like to change the dependency of Checkstyle to 7.5 instead of the default 6.11.2. To achieve this I, have pluginManagement declared in parent pom with the dependency. In the child project, I am just referencing the plugin in the reporting tag. However I see that default Checkstyle (6.11.2) is being downloaded into the repository. Please see below parent and child pom. <?xml version="1.0" encoding="UTF-8"?> <project

How to ignore CheckStyle warning for missing @throws for test method?

瘦欲@ 提交于 2019-12-10 14:29:44
问题 I'm being plagued by CheckStyle warnings about missing @throws in the JavaDoc of test methods. I'm using writing a test method like this: /** * Check that something works. <== CheckStyle wants @throws here */ @Test public void testSomething() throws Exception { ... } Is there a configurable way to tell CheckStyle to ignore this ? The "throws" clause is there especially because it is a test method; where typically exception handling is ignored. 回答1: Yes. You can specify a suppression filter

Difference with Checkstyle and PMD configuration in maven parent module

别等时光非礼了梦想. 提交于 2019-12-10 14:01:56
问题 I have a java application with maven having below structure: parent | - pom.xml | - child | - pom.xml | - analyzers | - pmdrules.xml | - checkstyle.xml I have configured both PMD and checkstyle in parent pom.xml. For PMD the rulesets are configured as below, and it works fine both for parent and child modules: <configuration> <rulesets> <ruleset>${basedir}/../analyzers/pmdrules.xml</ruleset> </rulesets> </configuration> However, for checkstyle if I configure configLocation in the same way, it

Resolve Java Checkstyle Error: Name 'logger' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'

廉价感情. 提交于 2019-12-10 13:38:00
问题 Using the Eclipse Checkstyle plugin I see this error: Name 'logger' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$' . I resolved this error by changing: private static final Logger logger = Logger.getLogger(someClass.class); to private static final Logger LOGGER = Logger.getLogger(someClass.class); Why is this a checkstyle warning? 回答1: Because the field is marked final and static which implies that it's a constant and should be named with uppercase letters. From this link, you can see

Checkstyle Plugin does not add gradle tasks

旧时模样 提交于 2019-12-10 12:38:09
问题 i want to use checkstyle plugin in my gradle project, the gradle documentation says that it will add a few tasks: https://docs.gradle.org/current/userguide/checkstyle_plugin.html checkstyleMain, checkstyleTest, checkstyleSourceSet I added this into my app build.gradle file: apply plugin: 'checkstyle' I want to run gradle task from cmd to perform code style check, but there are no one checkstyle task. I checked the whole list by typing: ./gradlew tasks I also tried to add checkstyle jar as

Generate Coding guidelines from CheckStyle

南笙酒味 提交于 2019-12-10 04:26:48
问题 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. 回答1: I would generally advise against generating even parts of a coding guidelines document, because

Checkstyle rule to prevent invocation of some methods and constructors

Deadly 提交于 2019-12-10 04:24:50
问题 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

Checkstyle rules for Google Java Style

痴心易碎 提交于 2019-12-10 02:19:12
问题 Is there a Checkstyle rule file with the Google Java Style? 回答1: The checkstyle team added it several days ago. Here it is : https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml 回答2: If you have a maven-project, you can easily integrate google_checks (you have to use at least maven-checkstyle-plugin version 2.17) <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.17</version> <configuration>