New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Run local analysis #10

Closed
aheusingfeld opened this Issue Jan 8, 2013 · 18 comments

Comments

Projects
None yet
5 participants
@aheusingfeld
Collaborator

aheusingfeld commented Jan 8, 2013

The plugin should be able to run a local analysis based on the rules defined in Sonar.

  • add context menu entry for files, folders and modules
    ** analysis should be run on all elements beyond the marked element (file, folder, module)
  • add "local search" icon (toggle button) to indicate whether violations list contains results from a local analysis or the remote server
    ** the remote server violations list should be cached so it can quickly be re-read
    ** a click on the icon should clear the list and refill it with the remote server violations list from cache
    ** the local analysis result should not be cached, therefore the icon/ toggle button cannot be clicked again to refill the violations list with the local analysis result

See Sonar Eclipse plugin documentation for details:
http://docs.codehaus.org/display/SONAR/Browsing+Sonar+in+Eclipse#BrowsingSonarinEclipse-RunLocalAnalysisLocal

@ggili

This comment has been minimized.

Contributor

ggili commented Feb 16, 2013

Just to avoid double work I'm about to contribute on the implementation of the feature. Does anybody is doing the same?

@aheusingfeld

This comment has been minimized.

Collaborator

aheusingfeld commented Feb 16, 2013

I had some ideas how to do it, but haven't had time to work on it recently.
Are you planning to use the sonar-runner library as the eclipse plugin does? I think it's the smartest way to do it as it's not bound to Eclipse and encapsulates the Sonar API.

@ggili

This comment has been minimized.

Contributor

ggili commented Feb 16, 2013

Yes I had a look how is implemented in eclipse. I agree, using the runner is the best way to go. I already started with some light implementation which unpacks the runner runtime (as in eclipse) and is executing the analysis. Afterwards need to parse the JSON result then fill the violation. Sure there is still lot to be done.

@gshakhn

This comment has been minimized.

Owner

gshakhn commented Feb 17, 2013

Sounds like a good approach.

I wasn't planning on tackling this in the near future, so I'd welcome a pull request. :)

Thanks,
George

@ggili

This comment has been minimized.

Contributor

ggili commented Mar 8, 2013

Guys . I progressed with this . A part of my work is pushed on my forked repository (more will come later). Not sure if it's worth pushing to this master branch yet, because I still plan to do some things, but is functional. Sure more improvements will come later.

Apparently it is not possible to run local analysis just for a specific file or package. SonnarRunner needs a 'source root' directory or more 'source root ' directories. So the run local analysis will be available only module level (similar as in eclipse).

Another limitation is that local analysis needs at least sonar v3.4. I checked eclipse and they have that version check. I will commit bit later today that check.

Also I added some functional tests with some sample java file. But the tests can be running only through IntelliJ. It is really tricky to run it through maven. Since we need to specify all the intellij/lib folders to surfire classpath + some jvm args for IntelliJ. I spent some time doing that, but I don't have yet a solution, because it was still failing. Maybe in the worst case for the moment we can ignore those tests to run from maven and we can run them through IntelliJ test suite. As temporary solutuion. Did you experienced running intellij test cases from maven?
(I found this http://confluence.jetbrains.com/display/IntelliJIDEA/Writing+Tests+for+Plugins but this is pure running from IntelliJ.);

Alpar

@aheusingfeld

This comment has been minimized.

Collaborator

aheusingfeld commented Mar 8, 2013

Hi Alpar,

I finally fixed the bugs with the breaking tests in #27 and am about to push my changes up to my fork. The problem is that I also needed to add idea.jar to the pom.xml which has further dependencies but - of course - doesn't provide a pom.xml defining these (e.g. a really old version of trove4j, older than 2.0.2). :-/
I found those unresolvable dependencies in the SpringSource Enterprise Bundle repository.

Please see my pull-request #31

On the topic "SonnarRunner needs a 'source root' directory":
Isn't it possible to specify a package as a source root? This would be a rather odd limitation compared to Checkstyle and PMD plugins

@ggili

This comment has been minimized.

Contributor

ggili commented Mar 8, 2013

Hi Alexander,

Great news. Looking forward to this fix:). I remember I tried to add all the jars from intellij/lib for surface plugin class path, but ended up with some strange errors. Inspired from http://kirblog.idetalk.com/2005/09/writing-unit-tests-for-intellij-idea.html

I did not tried to use as maven dependency. As soon as your fix is pushed to this repo I'll grab it and check. But remember that I had to add the trove4j as well to get rid of class not found errors. I'm inherited from LightCodeInsightFixtureTestCase that may need other dependencies.

Wondering if we could build an aggregator pom with all intellij lib dependencies and use it for testing. But will see later.

On the 'SonnarRunner' topic:
I tried to specify a package and I thought will work. But then the local analysis will fail because sonar will tell that the class package is wrongly defined.
like you have a class in folder com/foo/service

pacakge com.foo.service
class Abc

And you tell the runner source folder is : com/foo/service. Sonar analysis will end up in error that the package is wrong. I'll have to double check again. But i'm pretty sure I got error regarding the package mismatch.
It is a limitation it's true. Sure we can force that we could show the analysis results for the specific file, but still we need to run analysis for the whole source root content (in case the module is big then takes more time). I checked in eclipse yesterday. They have this run local analysis only module level.

Or what we can do is to create a 'temporary code base' only with that 'package/file' and the runner to run on those source files, it would be a workable solution. This could come as an improvement :).

Alpar

@simonbrandhof

This comment has been minimized.

Contributor

simonbrandhof commented Apr 25, 2013

Hi,

For information sonar-runner 2.2 has just been released. It brings a new API to easily start an analysis.

Two modes are available : JVM fork (through org.sonar.runner.api.ForkedRunner) or run in the same process (org.sonar.runner.api.EmbeddedRunner). The drawback of the second mode is that it can conflict with some libraries like SLF4J or logback.

The artifact is available in the Maven central repository. Javadoc is not published online but it's available in the central repo as well.

Regards
Simon

@ggili

This comment has been minimized.

Contributor

ggili commented May 29, 2013

Please find pull request for this.
#36
More improvements will come later.

@Nyholm

This comment has been minimized.

Nyholm commented Jul 10, 2013

@ggili Do you have an estimate of how much work you have left on this feature? When will it be done?

@ggili

This comment has been minimized.

Contributor

ggili commented Jul 10, 2013

The thing is ready (sure improvements can be done afterwards). We need to wait for sonar-runner-2.3 official release .Since we are relying on some features which only 2.3 has. I understood the release will be on beginning/mid July.

@Nyholm

This comment has been minimized.

Nyholm commented Jul 10, 2013

Okej, Thank you.
It seams like it is end on Juli (http://jira.codehaus.org/browse/SONARPLUGINS/fixforversion/19178#selectedTab=com.atlassian.jira.plugin.system.project%3Aversion-summary-panel)
But there is no open issues, so they could deploy it any time now...

@simonbrandhof

This comment has been minimized.

Contributor

simonbrandhof commented Jul 23, 2013

For information sonar-runner 2.3 has been released today.

@Nyholm

This comment has been minimized.

Nyholm commented Aug 6, 2013

Any updates on this issue?

@aheusingfeld

This comment has been minimized.

Collaborator

aheusingfeld commented Aug 6, 2013

We're currently discussing the joining of https://github.com/gshakhn/sonar-intellij-plugin and https://github.com/omayevskiy/sonar-intellij-plugin to https://github.com/sonar-intellij-plugin.

You can follow the discussion here: https://groups.google.com/forum/#!topic/sonarqube-intellij-plugin/vgNPPSitg98

We're currently planning to base this on @omayevskiy's version to hopefully keep at least one plugin updatable. Fingers crossed that the approach will work out fine out.

@simonbrandhof

This comment has been minimized.

Contributor

simonbrandhof commented Aug 6, 2013

Good news. For information Sonar has been renamed SonarQube, but not SonarCube, as it's written in the google group title :-)

@aheusingfeld

This comment has been minimized.

Collaborator

aheusingfeld commented Aug 6, 2013

@simonbrandhof ARGH! Thanks for the hint. Change the name and email address of the google group!

@aheusingfeld

This comment has been minimized.

Collaborator

aheusingfeld commented Oct 24, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment