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

How can I perform static code analysis in PHP?

Is there a static analysis tool for PHP source files? The binary itself can check for syntax errors, but I'm looking for something that does more, like: unused variable assignments arrays that are assigned into without being initialized first and…
eswald
  • 8,368
  • 4
  • 28
  • 28
309
votes
14 answers

What open source C++ static analysis tools are available?

Java has some very good open source static analysis tools such as FindBugs, Checkstyle and PMD. Those tools are easy to use, very helpful, runs on multiple operating systems and free. Commercial C++ static analysis products are available. Although…
jnancheta
  • 7,008
  • 8
  • 25
  • 18
275
votes
11 answers

Why are explicit lifetimes needed in Rust?

I was reading the lifetimes chapter of the Rust book, and I came across this example for a named/explicit lifetime: struct Foo<'a> { x: &'a i32, } fn main() { let x; // -+ x goes into scope …
corazza
  • 31,222
  • 37
  • 115
  • 186
174
votes
9 answers

What static analysis tools are available for C#?

What tools are there available for static analysis against C# code? I know about FxCop and StyleCop. Are there others? I've run across NStatic before but it's been in development for what seems like forever - it's looking pretty slick from what…
Paul Mrozowski
  • 6,604
  • 9
  • 34
  • 47
151
votes
13 answers

Using Pylint with Django

I would very much like to integrate pylint into the build process for my python projects, but I have run into one show-stopper: One of the error types that I find extremely useful--:E1101: *%s %r has no %r member*--constantly reports errors when…
rcreswick
  • 16,483
  • 15
  • 59
  • 70
136
votes
6 answers

Is there a tool to validate an Azure DevOps Pipeline locally?

When making changes to YAML-defined Azure DevOps Pipelines, it can be quite tedious to push changes to a branch just to see the build fail with a parsing error (valid YAML, but invalid pipeline definition) and then try to trial-and-error fix the…
Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402
126
votes
8 answers

Is SonarQube Replacement for Checkstyle, PMD, FindBugs?

We are working on a web project from scratch and are looking at the following static code analysis tools. Conventions (Checkstyle) Bad practices (PMD) Potential bugs (FindBugs) The project is built on Maven. Instead of using multiple tools for…
Johnny
  • 1,317
  • 2
  • 10
  • 6
120
votes
13 answers

Are there any JavaScript static analysis tools?

I'm used to having my compiler complain when I do something stupid like a typo on a variable name but JavaScript has a habit of letting this pass. Are there any static analysis tools for JavaScript?
Mat
  • 82,161
  • 34
  • 89
  • 109
118
votes
12 answers

What code analysis tools do you use for your Java projects?

What code analysis tools do you use on your Java projects? I am interested in all kinds static code analysis tools (FindBugs, PMD, and any others) code coverage tools (Cobertura, Emma, and any others) any other instrumentation-based tools anything…
Joshua McKinnon
  • 24,489
  • 11
  • 57
  • 63
113
votes
3 answers

What are the differences between PMD and FindBugs?

There was a question comparing PMD and CheckStyle. However, I can't find a nice breakdown on the differences/similarities between PMD and FindBugs. I believe a key difference is that PMD works on source code, while FindBugs works on compiled…
Thomas Owens
  • 114,398
  • 98
  • 311
  • 431
105
votes
9 answers

How to Generate a calling graph for C++ code

I'm trying to generate calling graph with which to find out all the possible execution paths that are hitting a particular function (so that I don't have to figure out all the paths manually, as there are many paths that lead to this function). For…
shiouming
  • 1,889
  • 4
  • 17
  • 26
101
votes
8 answers

How can I analyze Python code to identify problematic areas?

I have a large source repository split across multiple projects. I would like to produce a report about the health of the source code, identifying problem areas that need to be addressed. Specifically, I'd like to call out routines with a high…
Jerub
  • 41,746
  • 15
  • 73
  • 90
94
votes
17 answers

Checkstyle vs. PMD

We are introducing static analysis tools into the build system for our Java product. We are using Maven2 so Checkstyle and PMD integration come for free. However it looks like there is a large overlap in functionality between these two tools, in…
John Stauffer
  • 16,150
  • 10
  • 40
  • 35
92
votes
6 answers

Import order coding standard

PEP8 suggests that: Imports should be grouped in the following order: standard library imports related third party imports local application/library specific imports You should put a blank line between each group of imports. Is there a way to…
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
68
votes
8 answers

Dead code detection in legacy C/C++ project

How would you go about dead code detection in C/C++ code? I have a pretty large code base to work with and at least 10-15% is dead code. Is there any Unix based tool to identify this areas? Some pieces of code still use a lot of preprocessor, can…
Nazgob
  • 8,502
  • 4
  • 40
  • 42
1
2 3
99 100