checkstyle

Checkstyle's PackageHtml-rule ignores package-info.java

I use checkstyle to analyze my code. A useful rule is PackageHtml, that checks, if a package contains a Javadoc-description. But with newer java-version it's recommended to use package-info.java instead of package.html. Problem is, checkstyle ignores the package-info.java and reports a rule violation. How can checkstyle be configured to ...

Checkstyle vs. PMD

We are introducing static analysis tools into the build system for our Java product. We are using Maven2 so Checkstyle and PMD integration come for free. However it looks like there is a large overlap in functionality between these two tools, in terms of enforcing basic style rules. Is there a benefit from utilizing both of these? I don...

checkstyle + suppression filters

I have a checkstyle suppression filter setup (e.g. ignore magic numbers in unit test code). The suppression xml file resides in the same folder as the checkstyle xml file. However, where this file actually is varies: on my windows dev box it is in d:\dev\shared\checkstyle\config on the Linux CI server it will be in /root/repo/shared/che...

Can the CheckStyle module "NeedBraces" work with nested if/else blocks?

We are using CheckStyle to enforce our style standards. One of the style rules we opted to include was the NeedBraces module. NeedBraces specifies that every block type statement (such as if, else, for) must have opening and closing curly braces. However, as far as I can tell it isn't working entirely correctly. This example will tri...

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

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 Ch...

Maven 2 Checkstyle configLocation

Hi, i have a project which has as maven dependency a jar file which includes a xml file where i stored my rules for checkstyle. I thought it would be ok to just use this configuration: <configLocation>mycheckstyle.xml</configLocation>. My understanding is that the file should be searched on the classpath and my jar file is a Maven depen...

Detect changing value of object passed as parameter

I'm now working with code that looks like this public String getName(User user) { user.setSth(...); return user.getName(); } I think it's bad practice to change objects passed as parameters. Is there a tool that detects that kind of code? I looked at findbugs, pmd and checkstyle, but could not find any check for this. P.S....

Do you know of pmd or checkstyle definition files that will enforce hibernate best practices?

For example, not to build queries by string manipulation, and the like. ...

Using checkstyle with Ant during an automated eclipse build

For the last months I've been slowly improved the Eclipse automated PDE build process for our application. The first thing I tried was automating the test cases. The next step was some scripting code to generate an installer automatically, for both linux and windows. Now I want to add some static code analysis reports to the process. ...

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

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...

Checkstyle for XML, text, properties file formats

Can checkstyle be configured to check xml, text, properties file formats. I have a requirment wherein I need to check for certain keywords in java, xml, text etc. file formats. For e.g. if in a text file the text "danger" appears, then I need to inform the user that the text danger appears in this line, please remove it. ...

Problems occurred when invoking code from plug-in: "org.eclipse.jface" when using Checkstyle Plugin

Hi guys, I am trying to use the eclipse-cs plugin on Rational Software Architect 7.0.0.4. I recently uninstalled the older beta2 version and installed beta3. The plug-in itself works as was previously configured. But whenever I attempt to re-configure the check rules via Windows->Preferences->Checkstyle, I get the following error: Pro...

Using CheckStyle in NetBeans and configuring the CheckStyle rules

I am using NetBeans 6.5. For CheckStyle, I have downloaded and installed the nbcheckstyle.nbm plugin. I am able to use CheckStyle with this plugin. I want to configure the rules to be checked. I am not able to do it as it is an .nbm file. Any suggestion on how to configures the rules? Thanks ...

Checkstyle and Eclipse; Java string continuation

(I know this is a sort of lazy question, but it's oddly hard to search for...especially since checkstyle does so much, and Google search results are littered with checkstyle reports.) Can someone tell me which checkstyle check reports "+ should be on a new line" when splitting long strings over multiple lines in Java? On an aside, thi...

How to generate an Eclipse formatter configuration from a checkstyle configuration?

I have a checkstyle configuration XML file and want to automatically generate an Eclipse formatter configuration from this. Is there any tool that can do this? ...

How to get rid of Checkstyle Message 'File does not end with a newline.'

I'm working with a maven (jar) Project in Netbeans(Windows), which creates Checkstyle Reports with the maven checkstyle Plugin. No Matter what i do, i always get the message: File does not end with a newline. for Java Class Files. What can i do/configure in either Netbeans (Formatter) or for the checkstyle plugin to get rid of the Mess...

How do I suppress all checks for a file in checkstyle?

I'm doing an override for a third party class and I want to suppress all checks for it (since I'm only keeping it around until the patch is accepted). Is there a way to suppress all checks for a file? I tried using "*" but that fails. ...

Checkstyle Error in Eclipse - Could not instantiate Tab character

Got this error today while trying to build a project with checkstyle. This works for other people in my office but I would rather not reinstall Eclipse yet again. Any idea what this error actually means? Errors occurred during the build. Errors running builder 'Checkstyle Builder' on project 'myproject'. cannot initialize module Tree...

How can I automatically validate that I have an HTML Id on every element?

The testers on my project want a unique HTML ID on every page element to make their automated testing easier. It's hard for me to remember to do this, because I don't need the IDs for development. How can I ensure that I don't forget? I thought maybe something like Checkstyle could tell me, or even the "inspections" in IntelliJ - but ...

Best coding Style - Checking if a character is a valid character

I am coding a method that returns whether a given character is valid, which looks like this: - private static boolean isValid(char c) { return c == '.' || c == ',' || c == '+' || c == '/' || c == ';' || c == ':'; } Check style flagged this up as the boolean complexity is too great (5 when it should be no more than 3). My developme...