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

Function returns lock by value

I have the following structure type Groups struct { sync.Mutex Names []string } and the following function func NewGroups(names ...string) (Groups, error) { // ... return groups, nil } When I check…
maksadbek
  • 1,508
  • 2
  • 15
  • 28
21
votes
10 answers

Maven plugins to analyze javascript code quality

Javascript code can be tough to maintain. I am looking for tools that will help me ensure a reasonable quality level. So far I have found JsUNit, a very nice unit test framework for javascript. Tests can be run automatically from ant on any browser…
Alexandre Victoor
  • 3,104
  • 2
  • 27
  • 27
21
votes
2 answers

Tool for automatically check docstring style according to PEP257

Tools like pep8 can check source code style, but they don't check if docstrings are fromatted according to pep257, pep287. Are there such tools? Update I decided to implement such a static analysis tool on my own,…
Vladimir Keleshev
  • 13,753
  • 17
  • 64
  • 93
21
votes
3 answers

IntelliJ-Idea disable inspection: Actual value of parameter is always

Is there a way to disable this inspection? I know, this maybe be a bad design, but I still would like to disable it.
yu.pitomets
  • 1,660
  • 2
  • 17
  • 44
21
votes
9 answers

Any Static Code Analysis Tools for Stored Procedures?

Are there any static code analysis tools for stored procedures written particularly in PL/SQL and T-SQL?
suyasha
  • 41
  • 2
  • 3
  • 12
21
votes
5 answers

Typescript: accessing VS Code's "Find All References" programatically

One of the things I like about Typescript in VS Code is the ability to find all references to a function with Shift+F12 (or right-click). Is it possible to get to this mapping programatically, or to export it somehow? The output would contain…
Hoff
  • 38,776
  • 17
  • 74
  • 99
21
votes
2 answers

being sure about "unknown evaluation order"

Since version 1.80, Cppcheck tells me that Expression 'msg[ipos++]=checksum(&msg[1],ipos-1)' depends on order of evaluation of side effects in this code sequence (simplified, data is a variable) BYTE msg[MAX_MSG_SIZE]; // msg can be smaller,…
Wolf
  • 9,679
  • 7
  • 62
  • 108
21
votes
1 answer

Is there a list of Cppcheck messages?

Our team previously used Lint as a static code analyser, but it became too cluttered and had too much noise. We are using C++03 with frequent use of Boost, and Lint didn't seem to like Boost (I hear this has become better in later versions). I…
Tas
  • 7,023
  • 3
  • 36
  • 51
21
votes
3 answers

Are there any good tools for static code analysis in typescript?

We have been searching for good tools for measuring the quality of our TypeScript code. Mainly, we are interested in measuring Cyclomatic Complexity, LCOM, Instability and similar metrics. A tool for visualizing dependencies between modules would…
21
votes
3 answers

Java for each loop being flagged as UR anomaly by PMD

I would like to confirm if this is a bug on PMD? How do I file a ticket if it is. public static void main(final String[] args) { for (final String string : args) { string.getBytes(); //UR Anomaly } for (int i…
John Doe
  • 1,364
  • 1
  • 12
  • 19
21
votes
6 answers

Closed type classes

Is it possible to create a typeclass that can no longer admit new members (perhaps by using module boundaries)? I can refuse to export a function necessary for a complete instance definition, but that only results in a runtime error if someone…
J. Abrahamson
  • 72,246
  • 9
  • 135
  • 180
21
votes
3 answers

Typesafe varargs in C with gcc

Many times I want a function to receive a variable number of arguments, terminated by NULL, for instance #define push(stack_t stack, ...) _push(__VARARG__, NULL); func _push(stack_t stack, char *s, ...) { va_list args; va_start(args, s); …
mikebloch
  • 1,577
  • 11
  • 21
20
votes
4 answers

Static Code Analyzer for C++ in Linux

Possible Duplicate: What open source C++ static analysis tools are available? Does anybody know of an open source,good static code analyzer for C++ code in Linux ? The idea is to catch programming errors even before the code goes in to the code…
Ajay
  • 9,947
  • 8
  • 32
  • 34
20
votes
6 answers

Are there any tools which can report on commented-out .NET code?

Has anyone come across a tool to report on commented-out code in a .NET app? I'm talking about patterns like: //var foo = "This is dead"; And /* var foo = "This is dead"; */ This won't be found by tools like ReSharper or FxCop which look for…
Troy Hunt
  • 20,345
  • 13
  • 96
  • 151
20
votes
1 answer

How to enable C++ warnings for bitwise operators with boolean arguments

While working with a rather large C++ code base and the GCC toolchain on Linux, I have encountered code which performs a boolean check as follows: #include int main() { bool foo = true; if (~foo) { // do some expensive…
Andrei Bârsan
  • 3,473
  • 2
  • 22
  • 46