All Questions
Tagged with static-code-analysis or static-analysis
2,722 questions
0 votes
1 answer
133 views
How to detect redundant assignments with Python linters?
Consider this small function: def test(): x = 1 x = 2 x = 3 return x + 1 Apparently, the first two assignments to x have no effect here and can be removed. Yet surprisingly, pylint/...
2 votes
4 answers
396 views
How to suppress this false positive warning from Clang static code analyzer?
#include <stdio.h> #include <stdlib.h> typedef struct { int a; } tempStruct1; typedef struct { int b; } tempStruct2; typedef struct { tempStruct1 *temp1; tempStruct2 *...
0 votes
0 answers
46 views
Liveness Analysis doesn't produce expected result
First a bit of context. Consider the code: void foo(double* b){ int a = 100; a = 101; b[1] += b[a]; } I have a visitor, that has VisitArraySubscriptExpr(ASE), where I perform ...
0 votes
1 answer
86 views
Does the react context API not hide dependencies?
When I make a component that relies on something like the currently chosen language for example, or maybe a special query function to fetch data, and I provide either of these things via a ...
0 votes
1 answer
273 views
Is clang-tidy '-checks=clang-analyzer-*' a drop in replacement for scan-build and clang-check -analyze?
Is clang-tidy '-checks=clang-analyzer-*' a drop in replacement for scan-build and clang-check -analyze? If I'm using the former, is there any need for using latters again? Previously there are two ...
10 votes
3 answers
861 views
Annotating intentional infinite loop to satisfy "-fanalyzer"
I have a following embedded system optimization case (simplified). int main() { while (1) { // Do something if (unrecoverable_error) { __breakpoint(); while(1); } } } ...
1 vote
1 answer
180 views
Why isn't PHPStan complaining about invalid array keys?
Here's the code: <?php declare(strict_types=1); /** * @param array{key?: string} $options */ function hello($options) { var_dump($options); } hello([ 'WRONG_KEY' => '...', ]); I ...
0 votes
1 answer
28 views
ClangFormat style to handle non-idiomatic whitespace?
Are there any ClangFormat styles (or other tools) which will handle excessive newlines? With two or more newlines after the function parameter parentheses, as in the example below, none of the styles ...