static-analysis

Analyzing a simple C++ program with Frama-C

一笑奈何 提交于 2021-02-10 20:15:37
问题 I started learning C++ from a great tutorial available at https://learnxinyminutes.com/docs/c++/ and would like to analyze in Frama-C a simplest example that shows references: using namespace std; #include <iostream> #include <string> int main() { string foo = "I am foo"; string bar = "I am bar"; string& fooRef = foo; // This creates a reference to foo. fooRef += ". Hi!"; // Modifies foo through the reference cout << fooRef; // Prints "I am foo. Hi!" // Doesn't reassign "fooRef". This is the

Analyzing a simple C++ program with Frama-C

这一生的挚爱 提交于 2021-02-10 20:11:08
问题 I started learning C++ from a great tutorial available at https://learnxinyminutes.com/docs/c++/ and would like to analyze in Frama-C a simplest example that shows references: using namespace std; #include <iostream> #include <string> int main() { string foo = "I am foo"; string bar = "I am bar"; string& fooRef = foo; // This creates a reference to foo. fooRef += ". Hi!"; // Modifies foo through the reference cout << fooRef; // Prints "I am foo. Hi!" // Doesn't reassign "fooRef". This is the

Python script should end with new line or not ? Pylint contradicting itself?

喜夏-厌秋 提交于 2021-02-07 12:22:28
问题 I am new to Pylint, and when I run it against my script, I get this output: C: 50, 0: Trailing newlines (trailing-newlines) Here, Pylint is saying that it is bad to have a final newline. I like to have a new line at the end of my scripts, so I thought I would disable this warning. I did some google web searching and found this: http://pylint-messages.wikidot.com/messages:c0304 C0304 Message Final newline missing Description Used when a Python source file has no line end character(s) on its

Static code analysis tool for Common Lisp?

你离开我真会死。 提交于 2021-02-07 05:43:30
问题 I'm busy learning Common Lisp, & I'm looking for a static code analysis tool that will help me develop better style & avoid falling into common traps. I've found Lisp Critic and I think it looks good, but I was hoping that someone may be able to recommend some other tools, and / or share their experiences with them. 回答1: Given the dynamic nature of Lisp, static analysis is everything from tough to impossible, depending on the type of source code. For some purposes I would recommend using the

How to find out if (the source code of) a function contains a loop?

允我心安 提交于 2021-02-04 14:51:26
问题 Let's say, I have a bunch of functions a , b , c , d and e and I want to find out if they directly use a loop: def a(): for i in range(3): print(i**2) def b(): i = 0 while i < 3: print(i**2) i += 1 def c(): print("\n".join([str(i**2) for i in range(3)])) def d(): print("\n".join(["0", "1", "4"])) def e(): "for" I want to write a function uses_loop so I can expect these assertions to pass: assert uses_loop(a) == True assert uses_loop(b) == True assert uses_loop(c) == False assert uses_loop(d)

How to find out if (the source code of) a function contains a loop?

匆匆过客 提交于 2021-02-04 14:51:26
问题 Let's say, I have a bunch of functions a , b , c , d and e and I want to find out if they directly use a loop: def a(): for i in range(3): print(i**2) def b(): i = 0 while i < 3: print(i**2) i += 1 def c(): print("\n".join([str(i**2) for i in range(3)])) def d(): print("\n".join(["0", "1", "4"])) def e(): "for" I want to write a function uses_loop so I can expect these assertions to pass: assert uses_loop(a) == True assert uses_loop(b) == True assert uses_loop(c) == False assert uses_loop(d)

How do I use the clang static analyzer with msbuild on Windows?

空扰寡人 提交于 2021-01-27 10:22:35
问题 The binary windows installer for clang includes scan-build but when you run it with msbuild nothing happens. Even if I do something like: "C:\Program Files\LLVM\bin\scan-build.bat" "C:\Program Files\LLVM\bin\clang.exe" test.cpp I get something like: scan-build: Using 'C:\Program Files\LLVM\bin\clang.exe' for static analysis scan-build: Removed Directory '....' scan-build: No Bugs found Where test.cpp is: void DivideByZero(int z){ if (z == 0) { int x = 1 / z; } } int main() { int *i = nullptr;

How do I use the clang static analyzer with msbuild on Windows?

a 夏天 提交于 2021-01-27 10:19:33
问题 The binary windows installer for clang includes scan-build but when you run it with msbuild nothing happens. Even if I do something like: "C:\Program Files\LLVM\bin\scan-build.bat" "C:\Program Files\LLVM\bin\clang.exe" test.cpp I get something like: scan-build: Using 'C:\Program Files\LLVM\bin\clang.exe' for static analysis scan-build: Removed Directory '....' scan-build: No Bugs found Where test.cpp is: void DivideByZero(int z){ if (z == 0) { int x = 1 / z; } } int main() { int *i = nullptr;

Static code analysis for VB6 and classic ASP

ぐ巨炮叔叔 提交于 2020-12-10 03:55:51
问题 I'm looking for a static code analysis tool that will determine if I have orphaned functions in my VB6 code. The problem I'm running into is we make calls to the VB6 code from classic asp. Is there a tool that will look at both the classic asp and VB6 and determine if there are any orphaned functions? 回答1: Great Migrations offers a VB6/COM/ASP processor that can produce precisely what you are asking for. These detailed "reference reports" are a side benefit of the primary purpose of the