static-analysis

C#/.NET analysis tool to find race conditions/deadlocks

守給你的承諾、 提交于 2019-11-27 03:49:24
Is there a tool that analyses .NET code and finds race conditions? I have a bit of code that has a public static property that gets or creates a private static field. It also has a public static method that sets this field to null (...yes, I know!..) As there are no locks around either of these methods, it's a safe bet that things'll go horribly wrong in the future. I need a tool that'll recursively go through things that call either of these methods and see if anything was spawned on another thread. I'm looking for a tool or perhaps an nDepend SQL script (if this is possible). You're probably

How do I enforce null checking? [duplicate]

你离开我真会死。 提交于 2019-11-27 02:41:07
问题 This question already has answers here : avoiding null reference exceptions (15 answers) Closed 20 days ago . I'm working on a large project where, even with 10s of 1000s of automated tests and 100% code coverage, we're getting a ridiculous number of errors. About 95% of errors we get are NullReferenceExceptions. Is there any way to enforce null-checking at compile time? Barring that, is there any way to automagically enforce null-checking in unit tests without having to write the tests for

How to identify a missing method (Binary Compatibility) in a JAR statically

自古美人都是妖i 提交于 2019-11-27 00:56:49
问题 I want to verify binary compatibility between 2 JARs. Following the suggestions in this answer I used jboss tattletale but it can find only missing classes. How can I find if there are missing methods? Is it possible at all? E.g. "Depends - on" class Foo depends on Bar (like many other middle class workers) import org.overlyusedclassnames.Bar public class Foo{ public void someMethod(){ Bar tender = new Bar(); tender.getJohnnyRedLabel(); tender.getJohnnyBlueLabel(); //this method is new in the

How can I analyze Python code to identify problematic areas?

本小妞迷上赌 提交于 2019-11-26 23:46:11
问题 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 cyclomatic complexity, identify repetition, and perhaps run some lint-like static analysis to spot suspicious (and thus likely erroneous) constructs. How might I go about constructing such a report? 回答1: For measuring cyclomatic complexity, there's a

Instance variables with underscore in Objective-C 2.0 and renaming with @synthetize leads to optimization warnings by the 'Analyze' tool of Xcode 4 [duplicate]

只愿长相守 提交于 2019-11-26 23:17:48
Possible Duplicate: How does an underscore in front of a variable in a cocoa objective-c class work? I'm using the same convention for instance variable and properties naming as shown by sebnow in his following answer: instance variable/ method argument naming in Objective C I copy paste his example code here: @interface Foo : NSObject { id _bar; } @property (nonatomic, retain) id bar; - (id) initWithBar:(id)aBar; @end @implementation Foo @synthesize bar = _bar; - (id) initWithBar:(id)aBar { self = [super init]; if(self != nil) { _bar = aBar; } return self; } @end In the implementation of some

Should I use the final modifier when declaring case classes?

风流意气都作罢 提交于 2019-11-26 22:41:05
问题 According to scala-wartremover static analysis tool I have to put "final" in front of every case classes I create: error message says "case classes must be final". According to scapegoat (another static analysis tool for Scala) instead I shouldn't (error message: "Redundant final modifier on case class") Who is right, and why? 回答1: It is not redundant in the sense that using it does change things. As one would expect, you cannot extend a final case class, but you can extend a non-final one.

jenkins + sonar + github integration

非 Y 不嫁゛ 提交于 2019-11-26 22:37:33
问题 Problem: I am setting up jenkins + sonar + github integration for automatic pullrequest static code check through sonar. My Configuration: Installed Sonar with github Installed jenkins In jenkins post-build action I have the following properties -Dsonar.github.login=bhuwang -Dsonar.github.repository=company/repo -Dsonar.verbose=true -Dsonar.analysis.mode=preview -Dsonar.issuesReport.console.enable=true -Dsonar.forceUpdate=true -Dsonar.github.login=gitusername -Dsonar.github.oauth=token Token

Dead code detection in legacy C/C++ project [closed]

回眸只為那壹抹淺笑 提交于 2019-11-26 19:33:32
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 automated process handle that? You could use a code coverage analysis tool for this and look for unused spots in your code. A popular tool for the gcc toolchain is gcov, together with the graphical frontend lcov ( http://ltp.sourceforge.net/coverage/lcov.php ). If you use gcc, you can compile with gcov support, which is enabled by the '--coverage'

How to Generate a calling graph for C++ code

左心房为你撑大大i 提交于 2019-11-26 19:17:50
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 instance: path 1: A -> B -> C -> D path 2: A -> B -> X -> Y -> D path 3: A -> G -> M -> N -> O -> P -> S -> D ... path n: ... I have tried Codeviz and Doxygen, somehow both results show nothing but callees of target function, D. In my case, D is a member function of a class whose object will be wrapped within a smart pointer. Clients will always

Stack Size Estimation

自古美人都是妖i 提交于 2019-11-26 19:15:36
问题 In multi-threaded embedded software (written in C or C++), a thread must be given enough stack space in order to allow it to complete its operations without overflowing. Correct sizing of the stack is critical in some real-time embedded environments, because (at least in some systems I've worked with), the operating system will NOT detect this for you. Usually, the stack size for a new thread (other than the main thread) is designated at the time that thread is created (i.e. in an argument to