Questions tagged [static-analysis]

"Static Analysis" refers to the software tools (or their use) to analyze application code for arbitrary properties, such as errors (uninitialized variables, possible SQL injection-attack, is this code-dead, can an argument be null,...) or structure (what is the call graph for this code? is there duplicate code? what information is passed between components?).

Static analysis refers to the software tools (or their use) to analyze application code for arbitrary properties, such as errors (uninitialized variables, possible SQL injection-attack, is this code-dead, is there duplicate code, can an argument be null), or structure (what is the call graph for this code? what information is passed between components?).

The variety of questions that one might ask about application properties is endless. Usually, one needs a tool customized to answer each individual question, for each individual language. And each such tool typically requires a lot of engineering, as most of them have to contain a significant part of a compiler front end just to read the source code and understand the meaning of the source code entities. Consequently, such tools are rare for the specific question you want to ask; where they exist, there are as many static analysis software tools are there are questions, although often a set of questions are rolled up into a single tool.

(In contrast, dynamic analysis refers to collecting data about interesting properties as an application program actually executes, e.g., "did this sum overflow at runtime?". In principle, a static analysis tool can provide exactly the information that dynamic analysis can, just by simulating the execution of the program, but its a lot of work to build such a simulator when there's already a computer lying around that is willing to do it for no extra effort.)

2152 questions
20
votes
2 answers

Coffeescript Static Analysis / Static Typechecking - Roadblocks

I think Coffeescript is an awesome language! I was looking for some projects / issues / features that add Static Analysis to Coffeescript. However after some searching I found that the Coffeescript faq and this page suggest that static analysis…
19
votes
2 answers

Instrumenting C/C++ codes using LLVM

I just read about the LLVM project and that it could be used to do static analysis on C/C++ codes using the analyzer Clang which the front end of LLVM. I wanted to know if it is possible to extract all the accesses to memory(variables, local as well…
Himanshu Shekhar
  • 437
  • 1
  • 5
  • 16
19
votes
3 answers

How to find unclosed I/O resources in Java?

Many I/O resources in Java such as InputStream and OutputStream need to be closed when they are finished with, as discussed here. How can I search my project for places where such resources are not being closed, e.g. this kind of error: private void…
Andrew Swan
  • 13,427
  • 22
  • 69
  • 98
19
votes
4 answers

Parsing Objective-C code for static analysis

I love static analysis and compile-time checks, almost to a fault, but most of my day job is in Objective-C. To resolve this tension, I'd like to be able to write my own analysis tools that I can run on my Objective-C projects. But googling around…
Bill
  • 44,502
  • 24
  • 122
  • 213
19
votes
5 answers

How to fix the following PMD violations

I am using PMD to analyze code and it produces a few high priority warnings which I do not know how to fix. 1) Avoid if(x!=y)..; else...; But what should I do if I need this logic? That is, I do need to check if x!=y? How can I refactor it? 2) Use…
sarahTheButterFly
  • 1,894
  • 3
  • 22
  • 36
19
votes
3 answers

How to start using ndepend?

I recently downloaded ndepend and ran an analysis on an open source project I participate in. I did not now where to look next - a bit of visual and information overload and it turned out I don't even know where to start. Can anyone suggest starting…
Oded
  • 489,969
  • 99
  • 883
  • 1,009
19
votes
6 answers

How to identify a missing method (Binary Compatibility) in a JAR statically

I want to verify binary compatibility between 2 JARs. Following the suggestions in this answer I used jboss tattletale but it can find only missing classes. How can I find if there are missing methods? Is it possible at all? E.g. "Depends - on"…
Eran Medan
  • 44,555
  • 61
  • 184
  • 276
19
votes
5 answers

Tool to find all unused Code

I need a tool I can run that will show me a list of unused methods, variables, properties, and classes. CSS classes would be an added bonus. I heard FXCop can do this? or NDepend or something?
PositiveGuy
  • 46,620
  • 110
  • 305
  • 471
19
votes
3 answers

Exclude directory from intellij inspection, but not exclude from autocomplete

As far as I know, the only way to exclude a directory is to mark it as excluded in project structure. However, this would make IntelliJ totally ignore the directory. Thus it will not appear in autocomplete options. I do not want this. I want…
NimChimpsky
  • 46,453
  • 60
  • 198
  • 311
18
votes
1 answer

Static call graph generation for the Linux kernel

I'm looking for a tool to statically generate a call graph of the Linux kernel (for a given kernel configuration). The generated call graph should be "complete", in the sense that all calls are included, including potential indirect ones which we…
18
votes
5 answers

How can I find all static variables in my c# project?

I want to run some part of my command line programm in parallel with multiple threads and I am afraid that there might be some static variable left that I must fix (e.g. by making it [ThreadStatic]). Is there any tool or easy way to find these in my…
Christian
  • 2,903
  • 4
  • 31
  • 34
18
votes
3 answers

Type safety in Clojure

I want to ask what sort of type safety languages constructs are there on Clojure? I've read 'Practical Clojure' from Luke VanderHart and Stuart Sierra several times now, but i still have the distinct impression that Clojure (like other lisps) don't…
lurscher
  • 25,930
  • 29
  • 122
  • 185
18
votes
5 answers

Code linting for Objective C

Are there any code linting tools for ObjectiveC?
Himadri Choudhury
  • 10,217
  • 6
  • 39
  • 47
18
votes
6 answers

Free static checker for C99 code

I am looking for a free static checker for C99 code (including GCC extensions) with the ability to explicitly say "these preprocessor macros are always defined." I need that last part because I am compiling embedded code for a single target…
detly
  • 29,332
  • 18
  • 93
  • 152
18
votes
2 answers

Findbugs Annotations - Do I need annotation.jar and jsr305.jar in my deployed code?

So, I would like to use the findbugs annotations to suppress warnings we deem ok code. Do we need to deploy the annotation.jar and jsr305.jar into our production runtime, or do we only need these jars in the classpath for our Eclipse project and our…
tinman
  • 191
  • 1
  • 4