checkstyle

Using checkstyle to format code

╄→гoц情女王★ 提交于 2019-12-22 22:17:24
问题 I have just installed checkstyle in eclipse. It works by bringing up the appropriate errors in the part of the screen where you place break points. However, I was just wondering whether it actually will format the code for you and indeed add the empty comments etc for you to fill in? If it does, how do you get it to do it. Thanks 回答1: No, checkstyle doesn't format code, it only identifies violations of different types. You can configure Jalopy to format as per your checkstyle configuration.

How to write a Checkstyle custom check involving indirect inheritance?

谁说胖子不能爱 提交于 2019-12-22 10:26:55
问题 We need to write a checkstyle custom check that verifies a specific condition for classes that inherit—directly or indirectly—from a certain class A. Is it possible to identify the indirect inheritance using the checkstyle API? For example, suppose we have: Class C ---extends---> class B Class B ---extends---> class A In this case, it’s easy to check that C is a subclass of B by looking for the “extends” token ( TokenTypes.EXTENDS_CLAUSE ) and looking for B in the extends clause AST. But how

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

烈酒焚心 提交于 2019-12-22 06:03:08
问题 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

Disable all checkstyle checks for a specific java package

不羁岁月 提交于 2019-12-22 01:57:38
问题 I have two packages namely com/mydomain/abc/delegate/xyz/jaxws/managed and com/mydomain/abc/xyz/jaxws/managed I require checkstyle to be disabled only for the second package as these holds proxy classes that are autogenerated. I use a suppression.xml as shown below <?xml version="1.0"?> <!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN" "suppressions_1_1.dtd"> <suppressions> <!-- Suppress JavadocPackage in the test packages --> <suppress checks="JavadocPackage" files="[\

Generate Checkstyle HTML report with Gradle

送分小仙女□ 提交于 2019-12-21 06:58:34
问题 I'd like to get the output of running Checkstyle via Gradle as an HTML report. I've found nothing in the Checkstyle plugin documentation. I've added the following to my build.gradle file. checkstyleTask { reports { html { destination "build/reports/checkstyle.html" } } } but this yielded What went wrong: A problem occurred evaluating root project 'MyProject'. Could not find method checkstyleTask() for arguments [build_1vu33nc0ekgtoo19jt e86o8o42$_run_closure8@1d8ee20] on root project

How to set checkstyle configuration from Gradle in IDEA

岁酱吖の 提交于 2019-12-21 05:31:27
问题 I am using the Checkstyle plugin in IDEA. I want to set up different checkstyle configurations to my different modules. I am using gradle as build tool-version 4- and I want to write a task that modifies the corresponding .iml files of the modules. Any idea how to do that? My very first attempt in modifying the iml file looking over here apply plugin: 'idea' task setCheckStylePluginSettings { group = "Idea" description = "Copies CheckStyle plugin settings to Idea workspace." println "Step 1."

Checkstyle SuppressionCommentFilter not ignoring specified rule

ぃ、小莉子 提交于 2019-12-21 03:37:18
问题 I have a checkstyle.xml that looks something like this: <module name="Checker"> .... <module name="SuppressionCommentFilter"> <property name="offCommentFormat" value="CSOFF\: ([\w\|]+)"/> <property name="onCommentFormat" value="CSON\: ([\w\|]+)"/> <property name="checkFormat" value="$1"/> </module> <module name="TreeWalker"> <module name="LineLength"> <property name="max" value="200"/> </module> .... </module> </module> In one of my classes, I have a line longer than 200 characters and put

How to define suppressions-definitions for checkstyle, that work with both ant and eclipse

寵の児 提交于 2019-12-21 01:19:12
问题 I use in a project checkstyle and I have defined a SuppressionFilter in my checkstyle-configuration. I use Apache ant to make automatic builds via Continuous Integration. My problems comes from the following situation: I don't want to fill to much files into the project-basedir, so the checkstyle.xml and the suppressions.xml are both in a subdirectory named conf (for configuration for build). Now Ant and Eclipse work differently for finding the suppressions.xml. Ant use the project-basedir as

Is there a style checker for c++?

偶尔善良 提交于 2019-12-20 10:11:02
问题 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. 回答1: 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

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

爷,独闯天下 提交于 2019-12-20 04:24:17
问题 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=