Questions tagged [checkstyle]

Checkstyle is a static analysis tool for checking compliance of Java code to standards. It can be configured with various sets of coding standards. It is integrated in various other tools, such as IDEs (like Eclipse, NetBeans or IntelliJ), Maven, Gradle, or the continuous inspection platform SonarQube.

From the official website:

Overview

Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard.

Checkstyle is highly configurable and can be made to support almost any coding standard. An example configuration file is supplied supporting the Sun Code Conventions. As well, other sample configuration files are supplied for other well known conventions.

A good example of a report that can be produced using Checkstyle and Maven can be seen here.

Features

Checkstyle can check many aspects of your source code. Historically it's main functionality has been to check code layout issues, but since the internal architecture was changed in version 3, more and more checks for other purposes have been added. Now Checkstyle provides checks that find class design problems, duplicate code, or bug patterns like double checked locking.

For a detailed list of available checks please refer to the Standard Checks page.

Links

1320 questions
-1
votes
1 answer

How to incorporate checkstyle on a website?

I am creating an real-time code compiler web app and I am wanting to incorporate checkstyle into the text editor. Does anyone know how to do this or where to start?
-1
votes
2 answers

java ListResourceBundle checkstyle

I am trying to use ListResourceBundle for localizing my web app. It works well but checkstyle shows warning public class Locale_en_US extends ListResourceBundle { @Override protected final Object[][] getContents() { return new…
-1
votes
1 answer

Google rules for FindBugs

I noticed that Google uses/supports FindBugs. Does anybody know about a rules file they use, and can share a link? Similarly to their checkstyle rules, maybe there would be something for FindBugs?
wujek
  • 10,112
  • 12
  • 52
  • 88
-1
votes
1 answer

How to achieve hard-code voilations with CodePro?

I have to check some voilations like this if(emp.companyName="MyCompany") ie. Here there should not "MyComapany" hard-code in expression or condition checking. which rule of CodePro do this.
Sun
  • 3,444
  • 7
  • 53
  • 83
-1
votes
1 answer

Is there a way to do WhitespaceBefore in CheckStyle?

In Checkstyle (I'm using the maven plugin), I can use WhitespaceAfter to ensure whitespace after specific tokens. Is there a way to use something that would have the effect of WhitespaceBefore? I want to enforce whitespace before some open-parens…
Inbl
  • 630
  • 2
  • 5
  • 18
-1
votes
1 answer

How to fix "Cursor hides a field"?

I have a SQLite query: private String showAllType = "select * from tbl_Type"; And I call it as shown below: Cursor mCursor = mSQLiteDB.rawQuery(showAllType, null); But when I check codestyle, it gives a warning: 'mCursor' hides a field' How can I…
-1
votes
1 answer

what is the internal working of code quality check tools?

On which principal do the code quality check tools work? For example PMD, FindBugs, CheckStyle etc. Do they use some kind of computer science principals?
Sam
  • 2,352
  • 4
  • 32
  • 45
-2
votes
0 answers

How can I run checkstyle-10.12.2 on Ubuntu16.04?

I'm trying to run checkstyle on ubuntu by command line. I've tried java -jar checkstyle-10.12.2-all.jar -c ./google_checks.xml but kept encountering Error: A JNI error has occurred, please check your installation and try again. So I…
-2
votes
1 answer

What is the best way to check "method call" match format using checkstyle?

I have a group of methods that belong a single class that should contain at-least 2 parameters. The first one should be of type "literal" string (e.g. instance.do("literal_string", obj) - should be specified just right in the method call line…
sereGkaluv
  • 31
  • 6
-2
votes
1 answer

Expecting EOF found 'Exception'

I m new to java. I have been trying to make somecode to school, this code is just part of program, it works but checkstyle has a problem. Do anyone know what is wrong? I matched it with ******* . Thanks. public void vypis() { …
Filip Glemba
  • 23
  • 1
  • 6
-2
votes
3 answers

Checkstyle : Why as a developer we should worry about it?

I am not sure whether it is right forum or not. I just want to ask, what is there in checkstyle for developer. PMD is useful because it improve our coding skills but checkstyle I am not sure. Some checkstyle warning are too restrict like you can…
sauumum
  • 1,638
  • 1
  • 19
  • 36
-2
votes
1 answer

check ruby code for NoMethodError or NameError

Is there a way to check ruby code to prevent 'NoMethodError' or 'NameError'? I tried some gems: rubocop, reek, roodi. Useful tools for ruby best practices but not for my need. I use vim so a cli tool will be welcome. Thanks
AVVD
  • 19
  • 3
-5
votes
2 answers

Regex to match /src/main/{any_package}/*.java

I need a Regex for a set including only files from /src/main/java/{any_package}/*.java to apply CheckStyle rules only to these files in Eclipse. All other files, e.g.: none *.java files, src/test/ should be ignored.
blekione
  • 10,152
  • 3
  • 20
  • 26
1 2 3
87
88