checkstyle

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

只谈情不闲聊 提交于 2019-12-20 03:43:13
问题 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,

Intellij checkstyle - setting path relative to the module

只愿长相守 提交于 2019-12-20 03:24:15
问题 My company is switching from Eclipse to IntelliJ. In Eclipse we had a following configuration for suppression filters in checkstyle.xml <module name="SuppressionFilter"> <property name="file" value="${checkstyle.config.dir}/suppressions.xml"/> </module> <module name="SuppressionFilter"> <property name="file" value="${common.checkstyle.config.dir}/global-suppressions.xml"/> </module> Where: common.checkstyle.config.dir was an absolute path to the common project(module in IntelliJ). checkstyle

Checkstyle equivalent for JSPs?

限于喜欢 提交于 2019-12-20 01:33: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 回答1: Yes, there is something similar (but not for exactly those checks): You can use IntelliJ IDEA's "Inspection" functionality to inspect JSPs for

maven eclipse checkstyle plugin

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-19 08:13:19
问题 I have custom checkstyle checks file (called checks.xml), and I'm trying to use that same file in both maven and eclipse. It all works well, except for the SuppressionFilter . In this checks.xml file, I have <module name="SuppressionFilter"> <property name="file" value="src/main/resources/checkstyle/checkstyle-suppressions.xml"/> </module> This works when I run through maven. However, when I run through eclipse, I need to change the config to be <module name="SuppressionFilter"> <property

maven eclipse checkstyle plugin

懵懂的女人 提交于 2019-12-19 08:13:18
问题 I have custom checkstyle checks file (called checks.xml), and I'm trying to use that same file in both maven and eclipse. It all works well, except for the SuppressionFilter . In this checks.xml file, I have <module name="SuppressionFilter"> <property name="file" value="src/main/resources/checkstyle/checkstyle-suppressions.xml"/> </module> This works when I run through maven. However, when I run through eclipse, I need to change the config to be <module name="SuppressionFilter"> <property

Import checkstyle-configuration from sonar into eclipse-checkstyle-plugin

[亡魂溺海] 提交于 2019-12-19 03:36:46
问题 I want to export checkstyle rules from sonar and import them into the checkstyle eclipse plugin. Unfortunately sonar exports the checkstyle rules to a csv file. But the checkstyle plugin only accepts import of xml files. Is there any way to do that? 回答1: You can get it in checkstyle xml format by navigating to Configuration Quality Profiles -> select your Profile activate "Permalinks" tab This should give you access to the checkstyle config as xml. In Eclipse you can even configure the

Import checkstyle-configuration from sonar into eclipse-checkstyle-plugin

安稳与你 提交于 2019-12-19 03:36:12
问题 I want to export checkstyle rules from sonar and import them into the checkstyle eclipse plugin. Unfortunately sonar exports the checkstyle rules to a csv file. But the checkstyle plugin only accepts import of xml files. Is there any way to do that? 回答1: You can get it in checkstyle xml format by navigating to Configuration Quality Profiles -> select your Profile activate "Permalinks" tab This should give you access to the checkstyle config as xml. In Eclipse you can even configure the

Why usage of prefix incrementation is considered better than postfix incrementation in standard for construction

怎甘沉沦 提交于 2019-12-18 20:02:09
问题 I recently installed Checkstyle plugin for Eclipse and personally think that it is awesome. But one of the warnings it gives me is a bit obscure. The exact warning is "Using ++ is not allowed". It is about postfix ++ in some row like for(int i = 0; i < SOMETHING; i++) Ok, I 'm aware that foreach is the better construction for iteration, but it can't be applied everywhere, sometimes old-school ++ is the only alternative. When I change the row to for(int i = 0; i < SOMETHING; ++i) the warning

Why are protected variables not allowed by default in Checkstyle?

前提是你 提交于 2019-12-18 18:37:08
问题 I get a lot of warnings in eclipse like these: Variable 'myVariable' must be private and have accessor methods. I think I get them because I didn't set protectedAllowed manually to true in eclipse. But why is it set to false by default? Shouldn't I use protected attributes? 回答1: Theoretically, protected attributes (variables) are an anti-pattern in object-oriented languages. If only subclasses need to access member attributes of its superclass, define the attributes themselves as private and

CheckStyle plugin for IDEA - java way of warnings presentation and automatic fixes?

旧时模样 提交于 2019-12-18 13:32:29
问题 Is it possible to make it present the list of warnings java/spellchecker style as opposed to a old school list of errors with line numbers? Can it automatically fix things like missed space near '=' etc? Maybe I need a different plugin, which one then? 回答1: Try QAPlug - Checkstyle plugin. Then go Analyze - Analyze Code (not the standard Analyze!) then click "..." near Run with chosen profile select a concrete profile and press the import button. In the next dialog select the checkstyle rules