Sonarqube and eclipse - java

I have sonarqube and eclipse with plugin configured for a java project. When I run mvn sonar:sonar - I see results of the build in sonarqube console.
When I make analysis with Eclipse plugin - I see all issues locally in Eclipse, but not on server.
This is because eclipse plugin uses preview mode and sonarque db is not updated (which is good).
Now I would like that every eclipse sonar analysis would run in "analysis mode" - and sonarqube database get updated every time (don't ask why).
Do you know how to enable this behaviour?
thanks!

I don't ask why but anyway this is not possible.

Related

Why I can't remove this Eclipse plugin after failed installation?

I am using Eclipse Mars and I have the following problem.
After the installation of a plugin, the Adoe Flash Builder plugin, it is a plugin that is installed outside Eclipse (executing an installer and selecting the Eclipse folder) I have some problem.
The plugin installation failed (because this plugin is supported only on the 32 bit version of Eclipse). So the plugin was not completly installed.
When I start Eclipse I obtain a lot of error messages caused by this failed installation and it is impossible to me work.
So I have tried to disinstall this plugin but it doesn't give me the possibility to uninstall it (the Uninstall button is disabled).
Here the screenshot where you can see that, selecting the plugin that I want to uninstall, the Uninstall button is disabled:
Why? Can I manually delete this plugin in some way? (I have not directory related to it into my Eclipse folder). It seems that in some way Eclipse have the information of this plugin but that this is not effectively present. How can I remove it? Or is faster reinstall and configure again my environment (Eclipse + SVN plugin + project configuration)
I have tried sometimes to get rid of "messed up" eclipse configurations.
In the end, it just didn't work out. I always ended up throwing away everything.
Besides: Eclipse Neon R2a was released already; so just download that and say goodbye to Mars.
And the real answer (in my opinionated eyes): I decided at some point to enable myself to install eclipse "from scratch" as quickly as possible (for example by having automation where possible; and "checklists" to follow where manual interaction is required). Simply because "installing from scratch" helps avoiding a lot of problems over time.
And while we are talking about eclipse best practices: if your OS is Linux, consider to switch to git-svn instead of SVN. Your machine still talks SVN to the remote SVN server, but you can enjoy the full beauty of git locally. No more SVN plugins, no more hours of waiting for that SVN plugin doing refresh ... I can't tell you how much time that simply change saved for me.

Reports missing on SonarQube dashboard after upgrade

Recently I've upgraded SonarQube from 3.5 to 4.5.4 (LTS) and now there are a few users complaining that there are some reports missing on their project dashboards. The reports/numbers missing widgets are: lines of code and complexity. Unit tests coverage displays nothing. Other widgets (like technical debt, issues, directory tangle index) display 0 which also is suspicious. The project is in Java using the Sonar way profile.
The user does:
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install
mvn sonar:sonar -Dsonar.login=login -Dsonar.password=***** -Dcom.sun.jndi.ldap.connect.pool.prefsize=0 -Dcom.sun.jndi.ldap.connect.pool.timeout=3600000
The sonar:sonar step shows "0 files indexed".
The log is huge so I don't want to paste it here. I could not find anything helpful in it. What do I need to do to have all reports I used to have?
I have a test project where most of the missing data is displayed "out of the box".
Starting with version 4.3, SonarQube no longer runs automated tests. It expects Jenkins/CI system to run the tests, create the JUnit/PMD/Jacoco/Clover etc. reports, and then tell SonarQube where to find them. (In older versions of SonarQube, this behavior could be achieved by setting the "reuseReports" flag to true.)
If the build is not configured to generate the reports, it will need to be adjusted to do so.

Is there a way to execute Sonar's SSLR (squid-based) rules locally (on demand) in IntelliJ?

There is a SonarQube for IntelliJ, which, even though a bit temperamental, allows you to download rule violations from Sonar and view them directly in IntelliJ (the downside being the analysis runs on the server, necessitating a sync; the upside being you get exactly what you'd get in Sonar), and there is the QAPlugin, which allows you to import Sonar's Checkstyle, PMD and Findbugs rules and run them locally, but it does not support SSLR/squid rules yet. Sonar, however, seems to be moving away from PMD & Co. towards SSLR.
Is there currently a way to import Sonar's SSLR-based rules in IntelliJ and to run them locally?
You should take a look at the official SonarQube IntelliJ plugin which allows you to run SonarQube analysis within IntelliJ - whatever the rules you've configured on your SonarQube instance (SonarQube rules, Checkstyle, PMD, Findbugs).
Up from version 2 the SonarQube Community Plugin allows you not only to download issues from Sonar and view them directly in IntelliJ, but also to run any local analysis script, the results are then shown in Intellij like any other inspection.
You don't need to import any rules, instead you just run a local analysis script using the sonar-runner or any build tool plugin like mvn sonar plugin:
/path/to/mvn sonar:sonar -DskipTests=true -Dsonar.language=java -Dsonar.analysis.mode=incremental -Dsonar.host.url=http://your.sonar.host -Dsonar.profile=your_squid_based_profile
this will create a sonar-report.json file:
Export results to /path/to/your/project/target/sonar/sonar-report.json
You can configure the plugin which script to execute and where to read the results. Also the plugin does not care if the issues comes from squid or any other rule set.
See also: https://github.com/sonar-intellij-plugin/sonar-intellij-plugin

Can't debug Java program in Intellij IDEA

For the first time I encounter problem when I can't debug Java program in Intellij IDEA. Output to command line works, but breakpoint is ignored..
May be it's because I created Maven configuration to start the program.
It might be that I'm disconnected from JVM, but I have no idea how to connect to.
What can be the cause of such behaviour?
If you're talking about debugging something running in Maven with IntelliJ, you can
Run the maven build through IntelliJ and debug it like anything else, or
Run your build using mvnDebug instead of just mvn. It will wait for a debugger to connect on port 8000. You can have IntelliJ do this by creating a Run/Debug Configuration of type "Remote" that connects to localhost:8000.
If you are facing with non-triggered breakpoints, see following:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003676199-Can-t-debug-any-Java-or-Kotlin-application
In my case disabling android plugins solved the problem.
My solution was the following in IntelliJ. Go to:
Settings -> Build, Execution, Deployment-> Build Tools -> Maven -> Runner
Make sure to uncheck the box 'Delegate IDE build/run actions to Maven'
After that, I could debug and the breakpoints worked properly.
Remember that Maven and IDEA use separate build processes. Ironically I only managed today to get my own app built,deployed and run in browser today using:
Maven 3.0
Tomcat 7.0.5 with tomcat-maven-plugin
IDEA IU version 10
So ask if you need a hand.
Yucca
Sounds like the same bug in the Java VM, I just ran into:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6862295
The stated workaround was to use the -XX:+UseParallelGC on the Java VM.
It's not an IDE problem.
That solution was worked for me;
File-->Invalidate Caches-->Tick The Clear CheckBoxes --> Restart
Have a nice day.

How to properly setup a maven project in Eclipse/IntelliJ

I'm struggling a bit, trying to properly setup my maven projects in an IDE.
I don't particularly care between Eclipse and IntelliJ, but it seems that IntelliJ handles much better when it comes to import my projects, so I think I will stick with this one.
I'm having other problems now when trying to run the install goal through IntelliJ.
The first error :
The svn command failed. Command output: 'svn' is not recognized as
an internal or external command, operable
program or batch file.
How do I configure IntelliJ in order to let him see svn ? This error sounds weird to me, as I have installed Subversion as my Version Control System in IntelliJ.
Also, and this is related, I have a setenv.cmd that I usually run from the commandLine before calling mvn install. It only sets some variable like :
PROJECT_HOME=d:\Project\xxx\xxx\Trunk
PROJECT_VERSION=0.4.3-SNAPSHOT
M2_HOME=d:\Java\apache-maven-2.0.11
JAVA_HOME=d:\Java\jdk1.5.0_11
PYTHON_HOME=d:\Python26
XOOOF_HOME=d:\Project\xxx\xxx\XOOOF-BIN-1.0.3
XOOOF_URL=file:///d:/Project/xxx/xxx/XOOOF-BIN-1.0.3
SVNCLIENT_HOME=d:\Java\svn-win32-1.6.3
CATALINA_HOME=d:\Java\apache-tomcat
PATH=C:\WINDOWS;C:\WINDOWS\system32
How could I improve this step, and find a way to make it work from my IDE ?
Thanks !
If you want to do maven builds in eclipse I would strongly suggest installing m2eclipse by Sonatype.
It has an excellent reference on how to use it -> http://www.sonatype.com/books/m2eclipse-book/reference/
Regarding the first error it seems to be not Idea fault. AFAIK Idea doesn't need/use external SVN binaries. What happens when you click "9: Changes" tab at the bottom in Idea? If you make your project/module as managed by SVN there should be Repository subtab.
You run Maven from Idea to perform install goal and that error seems to come from it. Do you use SCM/SVN plugin in pom.xml? If yes or you would like to have an ability to run SVN from command line add directory with svn.exe (d:\Java\svn-win32-1.6.3? d:\Java\svn-win32-1.6.3\bin?) to PATH (not only to SVNCLIENT_HOME). After that operation svn command from new "run window" should be recognized.

Categories