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
27
votes
8 answers

Header file inclusion static analysis tools?

A colleague recently revealed to me that a single source file of ours includes over 3,400 headers during compile time. We have over 1,000 translation units that get compiled in a build, resulting in a huge performance penalty over headers that…
fbrereto
  • 35,429
  • 19
  • 126
  • 178
27
votes
1 answer

Is there a python linter that checks types according to type hints?

I'm looking for a Python linter, that can check types usage according to the type hints in the code. The purpose is to run a single check that verifies style, logic, and type errors. I need to run this on CI server, and as a file watcher during…
Gyro
  • 944
  • 1
  • 8
  • 16
27
votes
3 answers

Static Thread Analysis: Good idea?

I help maintain and build on a fairly large Swing GUI, with a lot of complex interaction. Often I find myself fixing bugs that are the result of things getting into odd states due to some race condition somewhere else in the code. As the code base…
Mark Peters
  • 80,126
  • 17
  • 159
  • 190
26
votes
7 answers

Why is imperative mood important for docstrings?

The error code D401 for pydocstyle reads: First line should be in imperative mood. I often run into cases where I write a docstring, have this error thrown by my linter, and rewrite it -- but the two docstrings are semantically identical. Why is it…
Richard
  • 459
  • 1
  • 5
  • 8
26
votes
1 answer

What is the reverse postorder?

This is the explanation in wikipedia: Data-flow analysis This is a typical iteration order for forward data-flow problems. In reverse-postorder iteration, a node is visited before any of its successor nodes has been visited, except when the…
lililqth
  • 378
  • 1
  • 3
  • 7
26
votes
4 answers

Do tools exist which automatically find copy-and-paste code?

Are there tools out there which could automatically find copy-and-paste code among a set of files? I was thinking of writing a script for this, which would just search for equal strings, but such script would find mostly irrelevant equalities. (Such…
26
votes
6 answers

Static analysis tool to detect ABI breaks in C++

It's not very hard to break binary backwards-compatibility of a DSO/shared library with a C++ interface. That said, is there a static analysis tool, which can help detecting such ABI breaks, if it's given two different sets of header files: those of…
25
votes
4 answers

Expression 'i < 0' is always false

For the following snippet: size_t i = 0; std::wstring s; s = (i < 0) ? L"ABC" : L"DEF"; s = (i != -1) ? L"ABC" : L"DEF"; PVS-Studio analysis logs warning for the first condition i < 0, as expected: V547 Expression 'i < 0' is always false.…
mloskot
  • 37,086
  • 11
  • 109
  • 136
25
votes
4 answers

Intellij (or other) - Possible to see a graph/tree of all calls made in Java?

I'm working on a project in Intellij Ultimate 14. I'm not looking to do a live debugging of the application to trace calls. The time it would take to follow all code paths would be insane. I'm hoping that Intellij has some kind of analysis tool that…
user1017413
  • 2,023
  • 4
  • 26
  • 41
25
votes
5 answers

What StyleCop like tools are there for VB.NET

see also VB.NET Static Code Anaylsis For better or for worst we now have a VB.NET coding standards document that is based on a C# coding standard as enforced by StyleCop. For example the number of spaces you should put in each side of a “+” sign…
Ian Ringrose
  • 51,220
  • 55
  • 213
  • 317
24
votes
5 answers

How to enforce usage of the @Override annotation?

Is there a static analysis tool that can enforce usage of the @Override annotation consistently that can be run outside of an IDE? CheckStyle has a MissingOverride check but it only applies to methods that use the @inheritDoc Javadoc tag. I'm…
Craig P. Motlin
  • 26,452
  • 17
  • 99
  • 126
24
votes
3 answers

jenkins + sonar + github integration

Problem: I am setting up jenkins + sonar + github integration for automatic pullrequest static code check through sonar. My Configuration: Installed Sonar with github Installed jenkins In jenkins post-build action I have the following…
Bhuwan Gautam
  • 1,229
  • 1
  • 11
  • 24
23
votes
2 answers

dredge function error - R package MuMln

I have to do statistical analyses on a data set. I would like to create all the possible models and to test them with the dredge function but it doesn't work. Indeed, when I type: glm1<-glm(presabs~dca1+dca2+se1+se2,…
Mornor
  • 3,471
  • 8
  • 31
  • 69
22
votes
2 answers

C# Code Contracts: What can be statically proven and what can't?

I might say I'm getting quite familiar with Code Contracts: I've read and understood most of the user manual and have been using them for quite a while now, but I still have questions. When I search SO for 'code contracts unproven' there are quite a…
JBSnorro
  • 6,048
  • 3
  • 41
  • 62
22
votes
2 answers

Xcode Build and Analyze - Is it possible to purposely skip analysis on a particular file?

I have one particular file in my project which is being worked on by someone else. I don't want to mess with it and would rather not wait for "Build and Analyze" to process it. Is there a way to tell Xcode to skip analysis on this file?
Cruinh
  • 3,611
  • 4
  • 38
  • 45