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
39
votes
9 answers

Where can I find an actively developed lint tool for Ruby?

Most of the code I write is in Ruby, and every once in a while, I make some typo which only gets caught after a while. This is irritating when I have my scripts running long tasks, and return to find I had a typo. Is there an actively developed lint…
Geo
  • 93,257
  • 117
  • 344
  • 520
37
votes
8 answers

Are there any static code analysis tools for Delphi/Pascal?

Are there any static code analysis tools for Delphi/Pascal? I have seen plenty of options for C++ and .NET, but nothing for Delphi/Pascal. Ideally something that could be integrated into a continuous integration system.
Rob Hunter
  • 2,787
  • 4
  • 35
  • 52
37
votes
1 answer

JSR-305 annotations replacement for Java 9

So far we have been using the Findbugs JSR-305 annotations (com.google.code.findbugs:jsr305) and everything including tool support (Sonar, Eclipse, Findbugs, …) has been working fine. However it is our understanding that Jigsaw in Java 9 is going to…
37
votes
1 answer

False positive: precondition is redundant

Why do I get the following warning for this trivial code sample as soon as the Warning Level is on the 2nd level or higher? public int Foo(int a) { if (a >= 0) throw new ArgumentException("a should be negative", "a"); …
Voo
  • 29,040
  • 11
  • 82
  • 156
37
votes
5 answers

Can ReSharper be set to warn if IDisposable not handled correctly?

Is there a setting in ReSharper 4 (or even Visual Studio itself...) that forces a warning if I forget to wrap code in a using block, or omit the proper Dispose call in a finally block?
serg10
  • 31,923
  • 16
  • 73
  • 94
35
votes
1 answer

PHP_CodeSniffer, PHPMD or PHP Depend

I am looking at doing some static code analysis of an exisiting PHP project, and I'm having trouble understanding the distinctions between PHP_CodeSniffer, PHPMD, and PHP Depend. Are these simply alternatives to the same problem, or do they…
jmans
  • 5,648
  • 4
  • 27
  • 32
35
votes
4 answers

How to use cppcheck's inline suppression filter option for C++ code?

I would like to use Cppcheck for static code analysis of my C++ code. I learned that I can suppress some kind of warnings with --inline-suppr command. However, I can't find what "suppressed_error_id" I should put in the comment: //…
Blaise
  • 7,230
  • 6
  • 43
  • 53
35
votes
9 answers

Tool to generate graph data for class dependencies

Is there some tool that is able to analyze Java source files, construct a graph from it and provide the graph's data in some standard / understandable format? It definitively does not need to have GUI, I'd prefer a command line thing so I can…
Rostislav Matl
  • 4,294
  • 4
  • 29
  • 53
35
votes
3 answers

Is there a way to measure duplicate code?

I'm looking for a code duplication tool that is language agnostic. It's easy to find language specific code duplication tools (for Java, C, PHP, ...), but I'd like to run some code duplication analysis on a templates in a custom syntax. I don't care…
35
votes
2 answers

Should the Code Contracts static checker be able to check arithmetic bound?

(Also posted on the MSDN forum - but that doesn't get much traffic, as far as I can see.) I've been trying to provide an example of Assert and Assume. Here's the code I've got: public static int RollDice(Random rng) { …
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
34
votes
6 answers

Static Actionscript code analysis possibilities

I want to see class, function and variable/property, dependencies visually, like NDepend, but for ActionScript 2 or AS3 code. Any programs or ideas? Use doxygen in some way? FlexUnit?
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
34
votes
2 answers

How to turn off JSLint indentation warnings?

I find that JSLint produces lots of warnings of the form: Expected 'foo' to have an indentation at X instead at Y. The JSLint options documentation describes an indent option that recognizes a numerical value representing the amount of space for…
Greg Mattes
  • 33,090
  • 15
  • 73
  • 105
33
votes
1 answer

How to exclude private members from StyleCop rule SA1600

Does anyone know how to change the StyleCop rule SA1600 that says elements must be documented so that it only applies to properties and not to private members? Our ORM (DevExpress XPO) requires that you have private members for all public properties…
Steven Evers
  • 16,649
  • 19
  • 79
  • 126
33
votes
2 answers

Arrays should not be statically initialized by an array initializer. Why?

This is one of the rules from Googles static analyser CodePro AnalytiX: Summary Arrays should not be statically initialized by an array initializer. Description This audit rule checks for array variables that are initialized (either in the…
Davor
  • 1,387
  • 16
  • 33
33
votes
5 answers

How do commercial Java static analysis tools compare with the free ones?

I'm familiar with a handful of the free static analysis tools available for Java, such as FindBugs and PMD. What I'd like to know is how the commercial products such as Klocwork and Coverity stack up against these. What are their strengths and…
Alex Varju
  • 2,922
  • 3
  • 24
  • 22