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
12
votes
2 answers

Code Contracts: Why are some invariants not considered outside the class?

Consider this immutable type: public class Settings { public string Path { get; private set; } [ContractInvariantMethod] private void ObjectInvariants() { Contract.Invariant(Path != null); } public Settings(string…
Romain Verdier
  • 12,833
  • 7
  • 57
  • 77
12
votes
1 answer

Using Contract.ForAll in Code Contracts

Okay, I have yet another Code Contracts question. I have a contract on an interface method that looks like this (other methods omitted for clarity): [ContractClassFor(typeof(IUnboundTagGroup))] public abstract class ContractForIUnboundTagGroup :…
Dan Bryant
  • 27,329
  • 4
  • 56
  • 102
12
votes
2 answers

Code Contracts - ForAll - What is supported by static verification

There are numerous information that static checking of Contract.ForAll has only limited or no support. I did lot of experimenting and found it can work with: Contract.ForAll(items, i => i != null) Contract.ForAll(items, p) where p is of type…
Michal Minich
  • 2,387
  • 1
  • 22
  • 30
12
votes
3 answers

How to write a custom intermodular pass in LLVM?

I've written a standard Analysis pass in LLVM, by extending the FunctionPass class. Everything seems to make sense. Now what I'd like to do is write a couple of intermodular passes, that is, passes that allows me to analyze more than one module at a…
stepthom
  • 1,432
  • 2
  • 16
  • 27
12
votes
2 answers

Groovy/Grails plugin for Sonar

Sonar is an application for integrating output from several static and test analysis tools into a comprehensive overview of the software's quality. Unfortunately, most of those analysis tools (PDM, FindBugs, etc.) do not support Groovy and, by…
billjamesdev
  • 14,554
  • 6
  • 53
  • 76
12
votes
3 answers

Is there a separate FindBugs plug-in for Android Studio?

According to this, FindBugs supports several IDEs as a plug-in, including IntelliJ-Idea, on which Droidio (Android Studio) is based. So does this mean that the IntelliJ-Idea plug-in can be installed into Droidio, or is there a distinct one somewhere…
12
votes
3 answers

Detect accidental elided dimension in C++

Consider the following snippet: #include using namespace std; int a[10][2]; int b[10][2]; int main(){ //intended cout << a[0][0] - b[0][0] << endl; //left out dimension by mistake cout << a[0] - b[0] << endl; } Obviously (or…
frankc
  • 11,290
  • 4
  • 32
  • 49
12
votes
1 answer

Using scan-build command for clang code analysis

I have installed scan-build/clang version 2.9 on Ubuntu desktop. I build my C++ source code there using make . As it said scan-build would analyze a project which is built using make if you give scan-build make to but after the make i see a…
goldenmean
  • 18,376
  • 54
  • 154
  • 211
12
votes
1 answer

Have you ever compared the static analysis tools Klocwork and Findbugs?

We are using Klocwork as a static analysis tool. Klocwork is a commercial tool and has many advantages but also has limitations like false-positives. I wonder who has ever compared Klocwork with other open source tools such as Findbugs. Generally,…
500004dolkong
  • 725
  • 3
  • 12
  • 19
12
votes
4 answers

-isystem for MS Visual Studio C++ Compiler

I usually like to have a lot of warnings enabled when programming. However, some libraries contains code that easily causes warnings (.., python, Qt, ..). When compiling with gcc I can just use -isystem instead of -I to silence that. How can I do…
Mathias
  • 1,446
  • 2
  • 16
  • 31
12
votes
5 answers

C# abstract Dispose method

I have an abstract class that implements IDisposable, like so: public abstract class ConnectionAccessor : IDisposable { public abstract void Dispose(); } In Visual Studio 2008 Team System, I ran Code Analysis on my project and one of the…
Sarah Vessels
  • 30,930
  • 33
  • 155
  • 222
12
votes
2 answers

Are there any static analysis tools that will report how closely the SOLID principles are followed?

I know blindly following any "best practice" can still lead to a stinking pile of crap that strictly adheres to the best practice. The SOLID principles are just that, principles. They don't apply to every situation but they are still very good…
Kenneth Cochran
  • 11,954
  • 3
  • 52
  • 117
12
votes
6 answers

Should useless type qualifiers on return types be used, for clarity?

Our static analysis tool complains about a "useless type qualifier on return type" when we have prototypes in header files such as: const int foo(); We defined it this way because the function is returning a constant that will never change,…
mpontillo
  • 13,559
  • 7
  • 62
  • 90
12
votes
2 answers

Finding unused methods in IntelliJ (excluding tests)

I ran into a method today that is .. not used anywhere .. but is tested. Since it is used by a test, IntelliJ did not flag the method as 'unused'. Does IntelliJ allow for the following search condition "Find methods that are unused with the…
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
12
votes
5 answers

How can I make a static analysis call graph for Perl?

I am working on a moderately complex Perl program. As a part of its development, it has to go through modifications and testing. Due to certain environment constraints, running this program frequently is not an option that is easy to exercise. What…
Paul Nathan
  • 39,638
  • 28
  • 112
  • 212