Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I've been trying to find a Java linter capable of running on the CLI that is separate from Eclipse that I can call as a commit hook for git or from our automated build script. Does such a thing exist?
Ideally it needs to check for unused imports and variables, that style guidelines are followed, exceptions are used properly, etc. Though some subset of those features would be better that what we have now - nothing!
SpotBugs (earlier Findbugs) for finding existing bugs. VERY GOOD!
PMD for finding patterns that can lead to bugs (e.g. unused variables)
Checkstyle to enforce coding standards and conventions (e.g. whitespace, Javadoc)
Error Prone hooks right into your application's compile step
clang-format supports java and may be available on your system already
All these tools have some overlapping rules. There are many other similar tools, but these are the most popular and supported.
Also, check out Sonar, which combines many of the other tools and provides a nice view for it too.
rules from Checkstyle, FindBugs, PMD, Clirr, fb-contrib.
Not sure exactly how to add it to a post-commit hook, but http://docs.codehaus.org/display/SONAR/Analyzing+with+Maven might be a good starting point (especially if you're using maven).
Maybe even consider using one of the approaches listed in http://docs.codehaus.org/display/SONAR/Continuous+Integration since it seems that you might be trying to look for better tooling for your whole team ("Though some subset of those features would be better that what we have now - nothing!"
This is EXACTLY what I am working on: a tool CLI-friendly to be used to check the quality of Java code. It has also an interactive modality. You can run single queries (to check for single warnings) or all queries together.
The tools is in its early stage but I am working on it almost every day. It is available here:
https://github.com/ftomassetti/effectivejava
Please let me know what do you think about it and feel free to ask questions.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Our team wants to adopt a coherent coding style, that has an automated refactor tool to spread the style across the team easily (not in terms of formatting - more like preventing "mistakes" and detecting general pitfalls in the code).
We have those needs:
- Working well with Eclipse, cross platform (linux/windows)
- Manipulate the code without changing its semantics
- Configurable (option to enable/disable rules)
- Optional: "Short Style" preferred ('v' instead of 'variable', if there is such tool that can do it)
A bit strict needs - but I'm sure SO community will do it :)
For the record I'll mention I was a member of the team developed Spartan refactoring (just a contributor - nothing too fancy), but along the way I've stepped on a few more - all of them are open source:
Spartan Refactoring - cross platform eclipse plugin. Adopts general purpose rules as long as some unique ones representing the Spartan coding style. Completely configurable.
AutoRefactor - eclipse plugin (I think it's cross platform). Adopts general purpose rules, also includes rules that considered as formatting (like braces eliminations) and also Configurable.
SonarQube - Large toolkit that also includes refactoring tool. Does the job but you also get a bunch of other tools inside (might be good or bad, depending on your needs).
To make the answer complete, have a look at:
automatic-refactoring-tools
automatic-refactoring-tools for java
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am looking for a tool which verifies that a set of java source files (not the byte code) follows a set of predefined rules.
For example, if we have a predefined rule which says any method contains an assertion, the method name must have the suffix "xxxTest". In order to keep the code clean, all the developers must follow these rules/conventions. Of course code reviewing would solve this problem however there should be a way to automate these simple code style checking.
In addition, the developer should be able to run this tool locally on his change-set before committing.
To solve this problem, I started to write my own verifier using the javaparser which will be executed using a gradle task. However in order to avoid re-inventing the wheel, I was wondering if there are existing tools which allows me to do this or even close (may be I can contribute to it)!
UPDATE:
I am aware of CheckStyle and Sonar for static analysis. However I need to run this tool on the CI (ex, Jenkins) as part of the build. So the build should fail if the convention is not applied.
You can test JArchitect and its powerful query language CQLinq.
For your specific need you can execute the folowing query
You can easily build this tool combined JavaParser and java-symbol-solver. The first one produces an AST of your source code and with the second one you can solve symbols (for example finding all the ancestors of a given class).
If your rules are simple enough you could probably get away just using JavaParser. That would be nice because JavaParser has very few dependencies and it is very mature and established.
Use a tool like Checkstyle.
It either allows you to configure a rule-set for your styleguide or you can write an extension.
There is also extensive support to integrate it into IDEs and build process.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I am looking for a library/API that has some out of the box data and control dependence analyses for Java programs. This would be a static analysis on the control flow graph (CFG) of the given program to compute data dependences and control dependences. I would like to avoid reimplementing these techniques/algorithms if they have already been done. An inter-procedural analysis would be great, but I could work with a library that does an intra-procedural one as well.
Any suggestions would be greatly appreciated.
Edit: One thing I have found is jChord, but I haven't been able to determine yet if it actually has any of the out of the box functionality that I am looking for or if I would have to implement it myself.
Another possibility is the joeq library which seems to at least have the infrastructure necessary for doing this, but the documentation (or lack thereof) is making it difficult for me to tell what it is actually capable of.
I am sure Eclipse does plenty of data flow analysis underneath the hood, but I haven't seen anything yet that is public facing. Anyone know of the Eclipse API having stuff like this?
Try http://www.sable.mcgill.ca/soot/
OP says he is interested in non-open source systems too.
Our DMS Software Reengineering Toolkit with its Java Front End can parse Java source code in all dialects 1.4-1.7, producing full ASTs, build symbol tables, compute types of expressions, and determine control and dataflows within methods, including explicity control dependence as requested by OP.
Usually folks that are interested in advanced analyses have something other than the raw analysis in mind. DMS is an ecosystem of program analysis and transformation tools, that can be used to leverage such analyses into diagnostics about the existing code in terms of source location (drawn directly from the ASTs) or source code (prettyprinted from a subtree of interest), or to generate new code fragments (by assembling ASTs and prettyprinting them) or finally by actually changing the original code (by modifying the ASTs using procedural modifications or better yet, source-to-source transformation, and prettyprinting the modified AST).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I know this question has been asked many times, but here are my specific needs. The obfuscator needs to come in a form of a java library, so I can make an Ant task in order to automate the build process. IE7, 8, Firefox and Chrome must be able to interpret the resulting js very fast (original js file is pretty big - 18k lines of code). If none exist which satisfy these requirements I'm willing to consider a commercial solution.
Some options:
YUI compressor. See Julien Lecomte's blog for example use from Ant.
LCA Soft provide a free Ant task interface to the Dojo Toolkit compressor.
Jawr - Ant task.
(I've not used Jawr or Dojo, so can't comment on which is best.)
Google's closure-compiler is another alternative.
There is a newer free option for Javascript Obfuscation - Roquson. They provide completely free Javascript Obfuscation with additional features like Variable renaming, Domain Locking and Expiration Date.
Check it out here: http://roquson.com
I still believe that jsutility.pjoneil.net provides the best compression of any program available except for gzip. It's obfuscation support is avoids most of the problems with obfuscation. It also now support batch operations.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
What is a good open source project which uses junit tests in its source code?
I want to see how its done and learn about it.
Any serious project (including open source) has unit tests. For what I've seen spring and hibernate have a lot of them.
This is a very good lecture about Object-oriented design for testability. It is not for complete beginners, but it gives very good insights.
The most widely used Test coverage tool is: eclemma
Update
Regarding "real world" understanding of jUnit. I would recommend use TDD and implement something very simple.
For example: Set (Java collections) and implement the test for the methods like: equals(), contains(), empty() etc.
The best way to learn something is by doing. Read this article, they have taken an example of Xerces XML parser
I wrote sections for Geoserver which only got accepted into the open-source tree once the additions were covered by tests. While testing my framework I came across some of the shortcomings in the Testing itself and extended it to allow for more abstract testing. The source for Geoserver can be accessed via SVN and the Eclipse Run-As Junit Test profile gives nice pass/fail stats.
You could also try and participate TopCoder developer competitions (this is not an ad). Every project there is required to have number of tests. And the volume of code covered by tests should not be below 85%.
I can recommend you to look at Hibernate project source code. Unit tests are very good there. Good example to follow.