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 2 years ago.
Improve this question
Looking for books or other references that discuss actually how to write a code coverage tool in Java; some of the various techniques or tricks - source vs. byte code instrumentation.
This is for a scripting language that generates Java byte code under the hood.
Does your scripting language generate bytecode? Does it generate debug metadata? If so, bytecode instrumentation is probably the way to go. In fact existing tools will probably work (perhaps with minimal modification).
The typical problem with such tools that they are written to work with Java and assume that a class com.foo.Bar.class corresponds to a file com/foo/Bar.java. Unwinding that assumption can be tedious.
EMMA is a ClassLoader that does byte-code re-writing for code-coverage collection in Java. The coding style is a little funky, but I recommend reading source code for some ideas.
If your scripting language is interpreted then you will need a higher-level class loader (at a source level) that hooks into the interpreter.
You can also get the source from a Open Source code coverage tool and learn from it.
Thxm, Mc! http://asm.objectweb.org/ is another one. Excellent documentation on byte code instrumentation, but nothing "directly" aimed at writing a coverage tool - just some hints or ideas.
You might also want to use something like BCEL to analyse which lines of source actually exist in the byte-code. You don't want to report that things like blank lines and comments haven't been covered.
If you're talking about ColdFusion (which I assume you are from the tags) then I'm not sure this is doable but I may be very wrong here...
IIRC, When CF compiles it essentially compiles into a interpreted form of the CFML as a plain old java source file, this is then compiled into the class. Therefore, any instrumentation that you may have will apply to the intermediary version rather than the CFML itself.
Saying that though, Adobe have got the CF debugger now which can step though code, so please prove me wrong - I'd love code coverage in CFML.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
I'm fully aware that a similar question was already asked here: Generating LLVM Code from Java
The thing is, that was in 2012...I looked at the solutions and found most of the projects mentioned abandoned or at least very inactive.
So, as someone who is most used to working with Java, what would be my options for working with LLVM (to create a toy language, not using clang or anything)?
Try to use one of those projects, even if the might be outdated? Sounds like a bad idea.
Learn C/C++? Don't get me wrong, I already have a C++-book lying around and I don't say it's a bad language, but I highly doubt I would feel comfortable working with it.
Use bindings for other languages, like Haskell, Python, etc.? I might prefer that over C/C++, but that would mean to learn another complete language before getting started...
Write my own bindings? I never did anything like that,I would not even know the difference between JNI, JNA and whatnot...but might be interesting to learn.
Try to format LLVM IR in text form? Might work, but is probably not the best idea either.
Just to finally answer this, Java C++ Presets are a useful and mostly-upto-date option for this: https://github.com/bytedeco/javacpp-presets/tree/master/llvm
I came across the same problem recently since I'm using ANTLR in Java/Scala to define my lexer and parser and LLVM to generate the actual machine code through its IR.
In trying to bind JVM-based front-end to LLVM IR and back-end I am actually trying to use GraalVM https://www.graalvm.org/ since it offers a seamless way to interact across languages, including the LLVM bitcode, using its Polyglot.
Here some references:
https://www.graalvm.org/docs/reference-manual/languages/llvm/
https://medium.com/graalvm/graalvm-llvm-toolchain-f606f995bf
https://blog.plan99.net/graal-truffle-134d8f28fb69
You should be able to access LLVM IR directly from your Java/Scala code or vice versa, you could access your AST in JVM-based language from LLVM/C++ code using Polyglot calls.
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 8 years ago.
Improve this question
I need to implement some statistical tests like: T-test, Anova and Wilcoxon on javascript.
Similar to Java's - Apache Commons Math Library, is there any statistical tests library or codes for javascript?
jStat : a JavaScript statistical library
https://github.com/jstat/jstat
OpenEpi is a Javascript stats library, is open source, and has ANOVA and t-tests. I've not tried it (it's a bit too focused on epidemiology for my needs) but it might be useful.
jStat is a javascript statistical library project, and it looks like it's got a great future, but it might not have all you need right now. Edit: as of Dec 2012 it looks like the jStat project page is no longer maintained but the project is continuing to be developed. There's more up to date documentation on github. It now does have anova tests and varieties of t-test. No sign of Wilcoxon signed-rank though.
If you need very specific statistical processing in javascript urgently, you might have most success by browsing Omegahat who have various little tools that bridge the established stats language R with others including javascript.
It'll depend on the details of exactly what you want to do, but you might have some success with packages such as RJavascript - a code translator which aims to help turn existing R features into Javascript (just don't expect quality results first time). Also, SpiderMonkey builds on R for browsers, so it might be useful for internal or personal uses (but it's unlikely to be suitable for public publishing).
Some years ago I ported https://code.google.com/p/statistics-distributions-js/ so that I could use it in http://elem.com/~btilly/effective-ab-testing/ - it may have the functionality you need if you only need simple things.
If you're looking for a simple library for descriptive statistics, you could use javascriptstats.com
It does:
Mean
Median
Mode
Range
Variance
Standard Deviation
Best!
Leveraging a related answer:
The following blog post lists some recent packages: http://jgoodall.me/posts/2012/02/01/javascript-statistical-libraries/
As mentioned by others, native JS is a far cry from R, which web-wise has progressed from RApache (http://rapache.net/) to shiny (http://www.rstudio.com/shiny/). The latter uses node.js server-side, so this is quite promising. Of course both approaches will require you to code stats in R server-side, instead of using JS either on client or server.
Marc
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 8 years ago.
Improve this question
I don't know how to describe it, but I'm looking for a tool that makes suggestions to my code on how to be... more elegant.
For example to make a nested if() statement a switch statement. something like this.
As I don't know how to describe my problem I don't know what to search for.
I thing code beautifier do not specifically change statements, right?
Have a look at IntelliJ IDEA "Intentions":
http://blogs.jetbrains.com/idea/tag/intentions/
http://www.jetbrains.com/idea/documentation/intentions.jsp
You might want to have a look into Netbeans. It provides code hints, which point out common practices and mistakes.
Except for the auto-formatting and style checking your IDE provides, you may be interested in a static code analysis tool like Crap4J, or something from this list of SCA tools for Java. They help you improve the readability of your code, and warn you when you use error-prone constructs. There are IDE plugins for most tools to let you find bad code as you write it.
You could use a tool like emmaecl, which integrates nicely with Eclipse.
You could also use something like Sonar which does quality analysis on your sources and provides metrics and hints on how to improve the code. Sonar is a web service you install. It would integrate nicely with an automated build tool like Hudson, but that's not required.
Have a look at FindBugs and PMD for improving the quality of your Java source codes.
Have a look at this post for beautifying your Java source codes.
You seem to be looking for a tool that will help you improve not your code's visual appearance and consistency (this is what a beautifier does), but its higher-level structure. FindBugs is your friend. Besides locating real bugs in your code, it will also identify more than 80 bad coding practices and more than 60 dodgy constructs (see this list).
You can use Artistic Style (works for C, C++, C# and Java) which has many options so you can set-up style you like.
You can use it either from command line or if you look hard you might find plugins for the mainstream IDEs (For what I know, it's integrated in KDevelop and there is plugin for Qt Creator).
Most IDEs will have formatting capability. Eclipse, which is a free, OpenSource IDE, will format Java soruce files
Eclipse can format your code.
You can customize it here: Window/Preferences/Java/Code Style
Maybe static code analysis tools like Findbugs or PMD could interesst you.
Eclipse has a code "Clean Up" functionality. You can find it under
Window -> Preferences -> Java -> Code Style - Clean Up.
The nice thing about this is that you can check this preferences in with your project in SVN. This way if you have multiple people collaborating on a project you just define your code Clean Up options and maybe your Formatter options. This goes a long way to not having to define everything in coding guidelines (they are still necessary, but there's a lot of stuff you can now define via those options).
You might also want to explore Checkstyle.
If using the IDE, then at least Netbeans and Eclipse both have functionality to clean up and reformat code.
Netbeans allows you to configure the code formatting to quite detailed level, i.e. including line break before the curly braces or not. Breaking long lines etc. Settings/Preferences->Editor->Formatting.
After configuration you just use ctrl+shift+f (cmd+shift+f) on your open file and all the crap gets automagically cleaned up.
I'm pretty certain the same thing is available for Eclipse also. Haven't dug into the configuration part, but formatting at least was available and was reformatting and cleaning up the code pretty neatly.
From commercial standalone tools jindent does the trick http://www.jindent.com/ for example.
I'd look at Sonar if I were you (http://sonarsource.org), it uses many of the aforementioned tools, such as PMD, Checkstyle and Findbugs and gives you an intuitive overview of the quality of your code.
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 8 years ago.
Improve this question
I have recently inherited a program written in Managed C++ from some guy who just retired. After spending some time digging through it, I can honestly say that at least 95% of it belongs on thedailywtf. However, I am now tasked with modifying it and porting it over to a language I'm comfortable with.
The program itself takes in many many parameters (50+) read in from a file and performs a series of calculations and spits out a report. Once I'm done plowing my way through pages of 3 letter variables (many of them reused for totally unrelated purposes), I need to come up with a way to test my code to make sure it comes up with the same answers as the previous code.
This is most likely wishful thinking, but are there any automated code analysis tools out there that can aid me in this task in any way or form?
I will be porting it over to Java.
I need to come up with a way to test
my code to make sure it comes up with
the same answers as the previous code.
Unit Testing
Since you mentioned that it is about a program that takes parameters in a file and outputs a report, you could generate a few inputs that give sufficient coverage to the portions you want to unit test against the output from the old code.
If something breaks don't forget there is also a chance you have discovered a bug in the old code.
http://www.junit.org/
Progressive Port
I'd go for porting it piece by piece, I kind of feel it will fit your problem since in a report you can grab specific fields and ignore those that you have not ported yet (assuming to output one field/calculation you do not need the whole program to be ported) and verify it against the correct value from the old code (or other correct source in case of bugs in the old code).
I think you should start off writing tests to ensure that the ported code does not break any of the existing report's behavior.
As for automated code analysis tools, the ones most likely to aid you in this area are the data flow analysis tools, which can hypothetically model the flow of data from the file into the variables and out to the report. Unfortunately, a search for such tools resulted in a failure a few weeks back, for me. You might want to have hand-drawn DFDs in places, just to make sure you don't trip over something. Graphviz can help in this area.
It might help copying over the functionality over to Java (I know this sounds perverse), but you could refactor the code carefully under the watchful eyes of PMD, FindBugs and similar code quality assurance tools in Java.
EDIT: I had forgotten the part where in tools of a certain category could be of aid - these are the code slicing tools in the Java world, and I must admit that I haven't used them so far. Here's a list that might help:
JSlice
Other related tools listed on the JSlice page.
I asked a somewhat related question some time ago that makes me think of a possible approach: Is there a Findbugs and / or PMD equivalent for C/C++?
What occurs to me is that, if this code is so janky, perhaps it would be a good idea to spend some time to try to repair / refactor it in place. Obviously, if you're headed to Java, it's a hard thing to convince yourself to spend time on improving C++ code that has a short lifespan. That said, if you replace some of the obviously stupid portions with improved code, it'll likely be shorter, tighter, more obviously correct and a whole lot easier to port and to analyze as you try to convince yourself that the new code is functionally equivalent to the old code.
The most useful tools suggested in answers to my question were Splint and Cppcheck.
There was another broader question asked some time ago that may contribute related ideas: What open source C++ static analysis tools are available?
Disclaimer: I've never had to do anything like this before.
Couldn't you first use a C++ to Java converter (a quick google search led me to a product which claims to be able to do that at a very reasonable price if it does in fact work C++ to Java Converter).
Then, create your unit tests and begin refactoring.
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 c++ code coverage tool which fares well in mutli server setup and on both windows and linux without licensing issues(if non free).
I have done some research and found 2 free tools: Covtool and gcov. Any disadvantages on these or any other suggestions?
Although I don't remember all the details of my research for code coverage tools, I seem to remember the following about gcov and covtool:
They require custom modifications to your build system
They need custom compiler flags and/or link steps
They both provide minimal output and formatting
We needed support for Windows/Linux and gcc/MSVC and settled on BullseyeCoverage which is commercial and non-free. We estimated that it would cost us more, in money, to change our build system to use the free products than it would to pay for a BullseyeCoverage license. Their support was great and responsive and I was very pleased with the quality of the tool.
Some benefits:
Great query support both in command line and GUI form
Required no changes to our build system
Had minimal impact on both compile time and run time
Provides tools to integrate with build bots such as CruiseControl and Hudson
Nice GUI for visualization and navigation of coverage results
AQTime is popular for Delphi/C++Builder users, but like the other recommendation, it is not free.
use Gcov tool along with LCOV tool. LCOV tool is a graphical front-end for gcov.
The OovAide program is a free open source tool that will instrument source files
and generate code coverage statistics as well as show which lines were never
run. It is thread safe and efficient.
It is fairly transparent meaning that the code that it produces is all visibile
and can be modified for your project if there are special needs required.
The basic idea of the source code modifications is that it inserts a macro
at every grouping of statements in the AST that CLang is processing.
This is typically after the conditionals or at braces. The macro can be
modified, but the default is that it increments a value at an offset in
an array. I have also modified it to write to a file in some cases,
and this allows a program trace of execution.
One problem may be that its build system is limited, and must be able to be
built using CLang. It may not work on certain types of projects. But since
it just modifies source code by inserting the macro, it is possible to
use it to modify the source code, then use the existing build system to
build the modified source code.
There is a document describing how it works here. http://oovaide.sourceforge.net/articles/TestCoverage.html