static-analysis

How to immediately see Swift errors in AppCode?

依然范特西╮ 提交于 2019-12-10 04:09:56
问题 Is there a way to immediately see Swift errors in AppCode? On their website they talk about static code analysis, but nowhere could I find a claim that this happens instantly. When you type some Swift code in Xcode you usually see warnings, errors etc. immediately. In AppCode I first have to make the build ( ⌘F9 ), then go through the list in the Messages Build view (which got way nicer in AppCode 2016.01 RC2): I find this tedious, especially when you make some small typos that lead to syntax

List of FindBugs 2.0 bugs by rank?

只谈情不闲聊 提交于 2019-12-10 03:09:21
问题 I know there is list of bugs, but I would like to have a list with additional information about rank (1 to 20 in version 2.0) or at least about ranking groups (Of concern, Troubling, Scary, Scariest). Maybe I'm missing something, but FindBugs forum does not seem to be active?! 回答1: Perhaps http://code.google.com/p/findbugs/source/browse/trunk/findbugs/etc/bugrank.txt but I don't know if it is exhaustive (FindBugs Bug Descriptions has more entries). 来源: https://stackoverflow.com/questions

Function prototype in header file doesn't match definition, how to catch this?

99封情书 提交于 2019-12-10 02:39:45
问题 (I found this question which is similar but not a duplicate: How to check validity of header file in C programming language ) I have a function implementation, and a non-matching prototype (same name, different types) which is in a header file. The header file is included by a C file that uses the function, but is not included in the file that defines the function. Here is a minimal test case : header.h: void foo(int bar); File1.c: #include "header.h" int main (int argc, char * argv[]) { int

Typesafe varargs in C with gcc

99封情书 提交于 2019-12-09 08:19:04
问题 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); while (s = va_arg(args, char*)) push_single(stack, s); } Can I instruct gcc or clang to warn if foo receives non char* variables? Something similar to __attribute__(format) , but for multiple arguments of the same pointer type. 回答1: I know you're thinking of

How to syntax check portable POSIX shell scripts? [duplicate]

微笑、不失礼 提交于 2019-12-09 06:30:16
问题 This question already has answers here : How do I syntax check a Bash script without running it? (8 answers) Closed 3 years ago . The following shell script executes well when provided /bin/true for the first argument, but may otherwise fail with a syntax error during execution! #!/bin/sh if $1 ; then exit; fi /tmp/asdf <<< ASDF # Something with syntax error in POSIX Surely some syntax errors (if not all?) can be avoided by static checking? How do I statically check whether a given Shell

Type checker for JavaScript?

断了今生、忘了曾经 提交于 2019-12-08 17:40:30
问题 Does anyone know if there's a good tool for analyzing JavaScript code and detecting type errors? I know that JavaScript itself is weakly and dynamically typed, but it would be really nice if I could have a program that would verify that all my field accesses are sensible and that I don't try treating a number like a string, for example. I'm aware that there are valid use cases in JavaScript where adding or removing fields or converting between different types is valid and expected, but some

C++/clang analyzer memory leaks?

无人久伴 提交于 2019-12-08 08:51:09
问题 I'm trying to get clang++ to tell me there is a memory leak. I tried scan-build but it reported nothing. How do I get llvm/clang to warn me of this problem? #include <iostream> int main() { int *a = new int; *a = 8; std::cout<< a << std::endl; } 回答1: False-positive pruning usually leads to removing all leaks that originate from main(), since the program will exit anyway. Try analyzing the same code, but in a different function. 回答2: Because int is too small, there is something like one

How do I link when building with llvm libraries?

混江龙づ霸主 提交于 2019-12-08 07:55:12
问题 I am trying to parse a LLVM-IR file(.ll) and do a static analysis.. I found this sample code below, and I tried to build it, but I don't know which library to link. #include <iostream> #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IRReader/IRReader.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; int main(int argc, char** argv) { if (argc < 2) { errs() << "Expected an argument - IR file name\n"; exit(1); }

Custom PMD Rule - Check Package Comment In Place

爷,独闯天下 提交于 2019-12-08 06:49:55
问题 I'm trying to write a rule to enforce that a package contains a Javadoc comment with a particular expression, e.g: /** * Example Expression */ Does anybody know how I would write such a rule using the AbstractJavaRule class. I've looked at ASTPackageDeclaration, but this doesn't appear to have what I want. Many thanks in advance... 回答1: PMD uses JavaCC to parse each java file into an Abstract Syntax Tree. Typically parsers used for compilation just drop comments, and from what I can gather on

Static analysis of header inclusion in C++

岁酱吖の 提交于 2019-12-08 03:43:30
问题 It seems that often I find that my code when moving either from one linux installation to another or from one unix to another, I find that I've missed including certain header files. This tends to become annoying when you give the source to someone else expecting them to be able to compile it just fine, only for it to fail because of missing header file includes. Are there any static analysis tools that can detect headers that should be explicitly included where they're currently seem to be