checkstyle
Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. By default it supports the Google Java Style Guide and Sun Code Conventions, but is highly configurable. It can be invoked with an ANT task and a command line program.
checkstyle – Checkstyle 6.12.1
I'm using Checkstyle and am getting an error about this method:
public final String getAdmitCodeStatus() {
return admitCodeStatus;
}
Here's the error I get:
Method 'getAdmitCodeStatus' is not designed for extension - needs to be abstract, final, or empty.
How is that method not compliant? Is there something I'm doing wrong that Checkstyle would bark at me about this method?
Source: (StackOverflow)
I run checkstyle on my Java code , it gives me this error:
variable access definition in wrong order
Can somebody tell me what that means?
Source: (StackOverflow)
Where I work, we use mostly Java. We've always made extensive use of CheckStyle to enforce our coding standards for Java.
We're now branching out into Scala. Many of the same considerations as in Java apply (indentation/whitespace, naming conventions, ...) - and arguably having a consistent coding style is even more important given the power of the language.
However, there does not seem to be a Checkstyle equivalent for Scala.
Does anyone know of one?
Source: (StackOverflow)
I have a Java class with a generic type P. I want to document it in Javadoc. Normally I just do this:
/**
* ...
* @param <P> the type of publisher
*/
This shows up fine in actual Javadoc. However, CheckStyle is warning me that I need to document the type P because it renders <P> as a HTML paragraph. Also, the Eclipse formatter interprets it as a paragraph as well, so it messes up the formatting.
Is there a better way of documenting type parameters with type P? I know I can disable the Eclipse formatter to no longer auto format javadoc, but I'd rather not (and it wouldn't solve the checkstyle problem anyway).
I also know I can just rename P to something else, but given the number of generic types I am working with here, it would make things a lot less readable.
Source: (StackOverflow)
My company has sonar set up to with various plugins (PMD, FindBugs, CheckStyle), and although it is very useful as is (it runs after every Jenkins build that was triggered by a check-in to SVN), I would like it if I could run these various plugins on my local machine before I check the code in.
We have a set of rules already set up in Sonar, so ideally I would like to be able to export that ruleset, perhaps do some munging of the data, and then import the resulting rules into my IDE (Netbeans 7.0.1) into the respective plugins. Is there any way to do this? I've searched all over and short of going through and manually adding each rule to the various plugins, there doesn't appear to be a way to do this. Is there something I'm missing?
TL;DR (Summary): I'd like to export a profile from sonar and import the rule settings into the PMD, Findbugs, and CheckStyle plugins in Netbeans.
Source: (StackOverflow)
I am trying to create a rule for checkstyle, that will prevent writing inline annotations usage, like this:
@Entity MyClass someEntity;
@Foo(a="B") public void bar(Baz baz) {
}
but will not prevent thinks like that:
public void bar(@Param Baz baz) {
}
Is there any way to achieve that?
Source: (StackOverflow)
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:
Problems occurred when invoking code from plug-in: "org.eclipse.jface".
This occurs when I click the configure button and attempt to reconfigure a specific selected check rule on the UI.
Has anyone ever encountered this issue before and how can it be fixed?
The full error listing and stack trace is shown below:
Stack trace:
java.lang.NoSuchMethodError: org/eclipse/swt/widgets/Text.setMessage(Ljava/lang/String;)V
at net.sf.eclipsecs.ui.config.RuleConfigurationEditDialog.createAdvancedSection(Unknown Source)
at net.sf.eclipsecs.ui.config.RuleConfigurationEditDialog.createDialogArea(Unknown Source)
at org.eclipse.jface.dialogs.TitleAreaDialog.createContents(Unknown Source)
at org.eclipse.jface.window.Window.create(Unknown Source)
at org.eclipse.jface.dialogs.Dialog.create(Unknown Source)
at net.sf.eclipsecs.ui.config.RuleConfigurationEditDialog.create(Unknown Source)
at org.eclipse.jface.window.Window.open(Unknown Source)
at net.sf.eclipsecs.ui.config.CheckConfigurationConfigureDialog$PageController.openModule(Unknown Source)
at net.sf.eclipsecs.ui.config.CheckConfigurationConfigureDialog$PageController.doubleClick(Unknown Source)
at org.eclipse.jface.viewers.StructuredViewer$1.run(Unknown Source)
at org.eclipse.core.runtime.SafeRunner.run(Unknown Source)
at org.eclipse.core.runtime.Platform.run(Unknown Source)
at org.eclipse.ui.internal.JFaceUtil$1.run(Unknown Source)
at org.eclipse.jface.util.SafeRunnable.run(Unknown Source)
at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(Unknown Source)
at org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect(Unknown Source)
at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(Unknown Source)
at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(Unknown Source)
at org.eclipse.jface.util.OpenStrategy.access$0(Unknown Source)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at org.eclipse.jface.window.Window.runEventLoop(Unknown Source)
at org.eclipse.jface.window.Window.open(Unknown Source)
at net.sf.eclipsecs.ui.config.CheckConfigurationWorkingSetEditor.configureCheckConfig(Unknown Source)
at net.sf.eclipsecs.ui.config.CheckConfigurationWorkingSetEditor.access$6(Unknown Source)
at net.sf.eclipsecs.ui.config.CheckConfigurationWorkingSetEditor$PageController.doubleClick(Unknown Source)
at org.eclipse.jface.viewers.StructuredViewer$1.run(Unknown Source)
at org.eclipse.core.runtime.SafeRunner.run(Unknown Source)
at org.eclipse.core.runtime.Platform.run(Unknown Source)
at org.eclipse.ui.internal.JFaceUtil$1.run(Unknown Source)
at org.eclipse.jface.util.SafeRunnable.run(Unknown Source)
at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(Unknown Source)
at org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect(Unknown Source)
at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(Unknown Source)
at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(Unknown Source)
at org.eclipse.jface.util.OpenStrategy.access$0(Unknown Source)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at org.eclipse.jface.window.Window.runEventLoop(Unknown Source)
at org.eclipse.jface.window.Window.open(Unknown Source)
at org.eclipse.ui.internal.OpenPreferencesAction.run(Unknown Source)
at org.eclipse.jface.action.Action.runWithEvent(Unknown Source)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(Unknown Source)
at org.eclipse.jface.action.ActionContributionItem.access$2(Unknown Source)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at org.eclipse.ui.internal.Workbench.runEventLoop(Unknown Source)
at org.eclipse.ui.internal.Workbench.runUI(Unknown Source)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Unknown Source)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(Unknown Source)
at org.eclipse.ui.internal.ide.IDEApplication.run(Unknown Source)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(Unknown Source)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(Unknown Source)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Unknown Source)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(Unknown Source)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Unknown Source)
at org.eclipse.core.launcher.Main.basicRun(Unknown Source)
at org.eclipse.core.launcher.Main.run(Unknown Source)
at org.eclipse.core.launcher.Main.main(Unknown Source)
And the session data:
Session Data:
eclipse.buildId=unknown
java.fullversion=J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32 j9vmwi3223ifx-20070323 (JIT enabled)
J9VM - 20070322_12058_lHdSMR
JIT - 20070109_1805ifx3_r8
GC - WASIFIX_2007
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_GB
Framework arguments: -product com.ibm.rational.rsa.product.ide
Command-line arguments: -os win32 -ws win32 -arch x86 -product com.ibm.rational.rsa.product.ide
Source: (StackOverflow)
I have checkstyle plugin installed in my eclipse. How do I disable check style for a specific project in my workspace? If that is not feasible I would like to turn off checkstyle. Please advice.
Source: (StackOverflow)
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 or Checkstyle to get rid of the message ?
Versions of used software:
- WinXP SP3
- Netbeans 6.7 RC1 (happens with 6.5 too)
- Maven 2.0.9
- Maven Checkstyle Plugin 2.2
- Java 1.6 (Update 14)
Source: (StackOverflow)
I'm using Checkstyle for Java in Eclipse IDE. I don't know in every java file, at second line, I always receive warning in Checkstyle : (although I'm pretty sure that I don't press tab key)
File contains tab characters (this is the first instance).
public class Percolation {
private boolean[][] grid;
...
}
When I have typed : public class Percolation {
, press enter, Eclipse will make an indent for me, after that, I type private boolean[][] grid;
. But, I still receive this warning.
Please tell me how to fix this. (I don't want to turn off this warning, because this is a must. Another people will check again my file).
Thanks :)
Source: (StackOverflow)
This question already has an answer here:
I'm using the CheckStyle plugin for Eclipse.
It's great at finding things I didn't intend 99% of the time, but the 1% of the time I actually did intend to knowingly violate a rule, I would like to let CheckStyle know it need not concern itself with flagging a warning.
Example: the Missing a Javadoc comment rule. Most of the time I want Javadoc comments on my methods. However, a method such as:
public boolean isValid() {
return valid;
}
can probably get by without one.
Is there anything like the @SuppressWarnings
annotation which can be used to flag a specific CheckStyle rule violation as acceptable? Some sort of specially formatted comment, maybe? I don't want to disable the rule, I just want to ignore a specific violation.
(I realize in this case I could just write the Javadoc comment, but in other cases fixing the rule violation isn't so simple).
Source: (StackOverflow)
Our project contains several classes that we have equals() and hashCode() methods generated by Eclipse (Right Click -> Source -> Generate hashCode() and equals()).
Example:
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final MyTO other = (MyTO) obj;
if (num != other.num)
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (table == null) {
if (other.table != null)
return false;
} else if (!table.equals(other.table))
return false;
return true;
}
These methods that work well for our application, but unfortunately do not pass our cyclomatic complexity checks with Checkstyle. Since these methods are auto-generated, we are not concerned with their complexity. We could suppress the entire class from Checkstyle, but we would prefer to be able to exclude just these two methods.
Does anyone know how to create a custom rule in Checkstyle that will allow us to exclude generated equals() and hashCode() methods in any way, without excluding the entire class?
Source: (StackOverflow)
I'm using STS and installed checkstyle plugin. Using install new software with this URL
http://eclipse-cs.sourceforge.net/update.
I have my own checkstyle rule for my Java project. Whenever I change any code and save it shows the following error for me.
Errors occurred during the build.
Errors running builder 'Checkstyle Builder' on project 'myproject'.
cannot initialize module TreeWalker - Unable to instantiate RedundantThrows
cannot initialize module TreeWalker - Unable to instantiate RedundantThrows
cannot initialize module TreeWalker - Unable to instantiate RedundantThrows
cannot initialize module TreeWalker - Unable to instantiate RedundantThrows
This is my checkstyle rule for RedundantThrows
<module name="RedundantThrows">
<property name="logLoadErrors" value="true" />
<property name="suppressLoadErrors" value="true" />
</module>
How to fix the problem?
Thanks.
Source: (StackOverflow)
I'm looking to find something along the lines of Checkstyle for Visual Studio. I've recently started a new gig doing .NET work and realized that coding standards here are a bit lacking. While I'm still a young guy and far from the most experienced developer I'm trying to lead by example and get things going in the right direction.
I loved the ability to use Checkstyle with Eclipse and examine code before reviews so I'd like to do the same thing with Visual Studio. Anyone have any good suggestions?
Another thing I'd be somewhat interested in is a plug-in for SVN that disallows check-in until the main coding standards are met. I do not want people checking in busted code that's going to wind up in a code review.
Any suggestions at this point would be great.
Source: (StackOverflow)