Programmatically initiate code review [message #84304] |
Tue, 26 September 2006 13:25  |
Eclipse User |
|
|
|
Originally posted by: matthew.gregory.us.michelin.com
I am (quite unsuccessfully) trying to figure out how (if) I can
programmatically initiate a code review using TPTP. I'm finding very
little on Google or in this newsgroup, perhaps there is somewhere else I
could be looking? My method so far is the browsing javadoc, peeking at
TPTP source and picking things that seem like they might be right.
Further complicating things is this is my first experience doing any
plugin development or Eclipse customization of any sort.
Here's the mess I have so far:
<snippet>
IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject("helloWorld ");
IResource[] resources = project.members(IResource.FILE);
List files = Arrays.asList(resources);
System.out.println("found " + files.size() + " files");
AnalysisHistory hist =
AnalysisHistoryFactory.instance().createAnalysisHistory("configName ");
CodeReviewProvider provider = new CodeReviewProvider();
provider.addOwnedElement(AnalysisUtil.getAnalysisElement("codereview.java.j2sebestpractices "));
provider.addOwnedElement(AnalysisUtil.getAnalysisElement("codereview.java.category.statement "));
provider.addOwnedElement(AnalysisUtil.getAnalysisElement(" codereview.java.rules.statement.RuleStatementSurroundWithBra ces "));
mgr.addOwnedElement(provider);
mgr.analyze(hist, files);
List history = mgr.getHistoryResults("configName");
System.out.println("found " + history.size() + " history results");
Iterator iter = history.iterator();
while (iter != null && iter.hasNext()) {
System.out.println(iter.next().toString());
}
if (true)
System.out.println("i KNOW this line fails analysis");
if (true) { /* this one too */ }
System.out.println("finished.");
</snippet>
The code actually runs through without exception, I just get no elements
in my history List.
Can anyone tell me the proper way to go about programmatically initiating
a code review?
Many thanks in advance!
|
|
|
|
|
|
|
|
|
Re: Programmatically initiate code review [message #84609 is a reply to message #84511] |
Thu, 28 September 2006 10:48   |
Eclipse User |
|
|
|
Originally posted by: matthew.gregory.us.michelin.com
We want to use TPTP as a base for a custom analysis package that we can
roll out to all of our developers which use RAD6 (and soon RAD7). What
made me choose TPTP over some of the other existing tools is it's
integration into Eclipse/RAD and it's customizability. One of our
requirements is to be able to do some basic architectural rule validation
to make sure applications are correctly implemented according to our
framework. None of the other tools (other than quite expensive ones)
would allow for these kinds of rules.
What TPTP doesn't do that I need to customize is some automation (Please
correct me if I'm wrong). We don't want developers to be able to ignore
the tool, so we want to automate the execution of code analysis. I think
a custom builder will be best for this, but not exactly sure just yet.
This automation is why I'm trying to figure out how to programmatically
initiate the analysis.
Another "cool" (not so cool, but that's life) thing I need to do is an
interim solution while we're in RAD6/7 limbo. Since we can't create
custom rules in RAD6 I need to create all my rules in Eclipse 3.2 in a
headless plugin, use RAD6 to call it, and then just capture the output
somehow. Won't be terribly pretty, but won't be long-term either. We're
still waiting to learn when the top-secret release date of RAD7 ... any of
you guy associated with that project as well? ;-) If so, I have some
questions ...
We also want to be able to execute the analysis in a batch mode for
projects which do nightly builds. In any of the three cases, though, I
think I need to know how to programmatically launch this analysis.
Perhaps not the last(?)
So that's the basics. I think TPTP is a great tool. I can't say I'm an
expert in code analysis, but based on my research it gains leverage from
Eclipse that gives it far more power than the other tools out there, with
the added benefit of tying it all into a neat little IDE package.
|
|
|
|
|
Re: Programmatically initiate code review [message #84661 is a reply to message #84643] |
Fri, 29 September 2006 17:01  |
Eclipse User |
|
|
|
Originally posted by: s_gutz.ca.ibm.com
Excellent news.
The history contains AnalysisHistoryElement instances so its not totally
straightforward. Each of these keeps track of which analysis elements
(a.k.a categories and rules) are enabled and maps it back to a real
AnalysisElement.
BTW in 4.3 the internal ResultsModel class has been replaced by a public
listener mechanism on AnalaysisHistoryFactory. For either UI or
command-line application you can now listen for history activity with ease.
Steve
Matt Gregory wrote:
> I'll take a look at the synchronousAnalyze() method. I've got it
> working pretty well though. It works within Eclipse32 and headlessly
> from command line. All it does is print out to the console or command
> line the rule violated, file, and line. You're right, I just avoided
> the ResultsModel class all together. I just had to figure out how to
> parse through the results in the history to get the information I
> wanted. I'm happy to share the code (although I've employed the brute
> force method since it's a prototype) with whomever is interested.
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.05023 seconds