Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deatiled Code Analysis

 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

What does detailed code analysis mean? Can we do code analysis using JUnit?

Thanks.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15490
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What "detailed code analysis" means exactly depends on the context. Where did you hear or read this?

JUnit is for automatic unit testing, not for code analysis. There are a number of tools that do static code analysis - such a tool reads your source code and analyses it using a number of rules, and warns you about potential bugs in your code. See, for example FindBugs and PMD.
 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper Young wrote:What "detailed code analysis" means exactly depends on the context. Where did you hear or read this?

JUnit is for automatic unit testing, not for code analysis. There are a number of tools that do static code analysis - such a tool reads your source code and analyses it using a number of rules, and warns you about potential bugs in your code. See, for example FindBugs and PMD.



I was asked this question in an inteview and I said Junit. I wanted to confirm with you guys and looks like I am wrong anyways Jesper, I have few more questions.

1).Can't we do the analysis without any tools and if we can, do people follow this approach?

2).Does dynamic analysis come under the code analysis too?

3).Does white and black box testing methods come under the code analysis too?

Thanks.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15490
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ofcourse you could do it also without any tools, but tools save time and make less mistakes than people. On the other hand, tools cannot check everything. I guess that code reviews are a common thing, especially when there are high quality standards.

Dynamic analysis: It depends exactly on what you mean by that. I would not call things like profiling and testing (including white or black box testing) "code analysis". In my opinion, "code analysis" means looking at the source code to determine if it is correct. With things like profiling and testing, you are not directly looking at the source code.
 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, Thanks for the reply Jesper. Debugger in IDEs, can also be used for static code analysis right?

Thanks.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Debuggers are used at runtime, so that rules out that they'd do static analysis (which is done with classes, not objects).

But even at runtime, what kind of analysis do you expect from a debugger?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic