Questions tagged [code-analysis]

Code Analysis is the process of analyzing the code of the application to discover, review, validate or verify certain properties of the application. This is useful during the process of development and for testing the application before it is put in production mode, especially for checking the security related aspects.

Code Analysis is the process of analyzing the code of the application to discover, review, validate or verify certain properties of the application. This is useful during the process of development and for testing the application before it is put in production mode, especially for checking the security related aspects. Code analysis can be classified from several perspectives, including:

1. What can be analyzed: source code or binary code (byte code) of the application can be analyzed. Both of these categories have their pros and cons.

2. How or When should code be analyzed: Code can be analyzed statically (without executing it) or dynamically (while the application is executed). Static analysis, being conservative, is prone to false positive, but it is exhaustive. On the other hand, dynamic analysis, being very accurate, may miss certain behaviors which are not manifested in any of the execution monitored (because dynamic analysis only analyzes code that is executed - i.e. when certain conditions are met)

3. Purpose of the analysis: Flaws can be found, like NULL pointer dereferencing or passing an ASCII string instead of a Unicode string. Furthermore, aspects of the code can be found, like building various graphs of dependencies or deducing the conditions under which recursion will occur.

1882 questions
54
votes
3 answers

Tool to determine what lowest version of Python required?

Is there something similar to Pylint, that will look at a Python script (or run it), and determine which version of Python each line (or function) requires? For example, theoretical usage: $ magic_tool
dbr
  • 165,801
  • 69
  • 278
  • 343
54
votes
7 answers

How to determine maximum stack usage in embedded system with gcc?

I'm writing the startup code for an embedded system -- the code that loads the initial stack pointer before jumping to the main() function -- and I need to tell it how many bytes of stack my application will use (or some larger, conservative…
David Cary
  • 5,250
  • 6
  • 53
  • 66
51
votes
5 answers

How to determine maximum stack usage?

What methods are available for determining the optimum stack size for embedded/memory constrained system? If it's too big then memory is wasted that could be used elsewhere. However, if it is too small then we get this website's namesake... To try…
Judge Maygarden
  • 26,961
  • 9
  • 82
  • 99
49
votes
6 answers

Tools to detect duplicated code (Java)

I am in a project where previous programmers have been copy-pasting codes all over the place. These codes are actually identical (or very similar) and they could have been refactored into one. I have spent countless hours refactoring these codes…
Rosdi Kasim
  • 24,267
  • 23
  • 130
  • 154
47
votes
34 answers

Why do code quality discussions evoke strong reactions?

I like my code being in order, i.e. properly formatted, readable, designed, tested, checked for bugs, etc. In fact I am fanatic about it. (Maybe even more than fanatic...) But in my experience actions helping code quality are hardly implemented. (By…
46
votes
10 answers

JavaScript Source Code Analyzer

Does anyone know of a good, extensible source code analyzer that examines JavaScript files?
JamesEggers
  • 12,885
  • 14
  • 59
  • 86
45
votes
5 answers

C# Code Analysis CA1822 Warning - Why?

I have the method shown below which is generating a CA1822 Code Analysis warning. CA1822 says this: "The 'this parameter (or 'Me' in Visual Basic) of 'ImportForm.ProcessFile(StreamReader)' is never used. Mark the member as static (or Shared in…
Randy Minder
  • 47,200
  • 49
  • 204
  • 358
44
votes
4 answers

Assembly Binding Redirection and Code Analysis

I'm using DotNetOpenAuth (which references System.Web.Mvc version 1.0.0.0) in a Mvc 3.0.0.0 project in Visual Studio 2010. I'm using assembly binding redirection as follows:-
42
votes
9 answers

How to get the FxCop custom dictionary to work?

How is it possible to get the FxCop custom dictionary to work correctly? I have tried adding words to be recognised to the file 'CustomDictionary.xml', which is kept in the same folder as the FxCop project file. This does not seem to work, as I…
Thomas Bratt
  • 48,038
  • 36
  • 121
  • 139
40
votes
6 answers

C# - StyleCop - SA1121: UseBuiltInTypeAlias - Readability Rules

Not found it in StyleCop Help Manual, on SO and Google so here it is ;) During StyleCop use I have a warning: SA1121 - UseBuiltInTypeAlias - Readability Rules The code uses one of the basic C# types, but does not use the built-in alias for…
binball
  • 2,255
  • 4
  • 30
  • 34
40
votes
3 answers

How do you prevent Visual Studio from switching to the Code Analysis tab after each build?

After each build, Visual Studio 2012 switches from the Solution Explorer to the Code Analysis tab, usually with the yellow "No code analysis issues were detected." (Might as well say "TA DA!"). Is there an option to turn off the tab switching…
Jim
  • 804
  • 6
  • 17
39
votes
3 answers

Code Analysis CA1063 fires when deriving from IDisposable and providing implementation in base class

I have some code that will trigger Code Analysis warning CA1063: CA1063 : Microsoft.Design : Remove IDisposable from the list of interfaces implemented by 'Functionality' and override the base class Dispose implementation instead. However, I'm not…
Martin Liversage
  • 104,481
  • 22
  • 209
  • 256
39
votes
9 answers

Where can I find an actively developed lint tool for Ruby?

Most of the code I write is in Ruby, and every once in a while, I make some typo which only gets caught after a while. This is irritating when I have my scripts running long tasks, and return to find I had a typo. Is there an actively developed lint…
Geo
  • 93,257
  • 117
  • 344
  • 520
38
votes
12 answers

How to analyze binary file?

I have a binary file. I don't know how it's formatted, I only know it comes from a delphi code. Does it exist any way to analyze a binary file? Does it exist any "pattern" to analyze and deserialize the binary content of a file with unknown…
Ricibald
  • 9,369
  • 7
  • 47
  • 62
37
votes
9 answers

Automatic code quality tool for Ruby?

One thing I really miss about Java is the tool support. FindBugs, Checkstyle and PMD made for a holy trinity of code quality metrics and automatic bug checking. Is there anything that will check for simple bugs and / or style violations of Ruby…
Will Sargent
  • 4,346
  • 1
  • 31
  • 53