Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging Ruby and Rails code inside Sonar plugin

What is the way to debug Rails and Ruby code (i.e. breakpoints, call stack etc...) which is running inside a separate JVM using IDE (IntelliJ Idea)? What configuration is required for it in Sonarqube and IntelliJ?
I did not find this information on Sonarqube site or elsewhere.

like image 265
Sergey Avatar asked Jun 11 '15 09:06

Sergey


People also ask

How do I run the SonarQube analysis for Ruby?

Copy the jar into the SonarQube plugin directory (e.g. /opt/sonarqube/extensions/plugins) In order to run the analysis for Ruby you will need to utilize the sonar-scanner application. Make sure you have a sonar-project.properties file in the root of your project directory

How do I debug Ruby code in rails?

After entering the debugging session, you can type in Ruby code as you're in a Rails console or IRB. You can also use p or pp command to evaluate Ruby expressions (e.g. when a variable name conflicts with a debugger command). Besides direct evaluation, debugger also helps you collect rich amount of information through different commands.

Why do I need a rails debugger?

When you actually need to journey into your running source code, the debugger is your best companion. The debugger can also help you if you want to learn about the Rails source code but don't know where to start.

What are the best plugins for Ruby on rails?

Ruby Solargraph is one of the most helpful plugins on this list, and provides IntelliSense, code completion, and inline documentation for Ruby. Inline documentation helps you view all the allowed methods of the class/object, and also helps you easily understand the definition of each method and its arguments.


2 Answers

Have a look at http://docs.sonarqube.org/display/DEV/Extend+Web+Application. See section Applications -> Development mode.

Regards

like image 56
Julien L. - SonarSource Team Avatar answered Sep 28 '22 19:09

Julien L. - SonarSource Team


Your best bet is to go with RubyMine: https://www.jetbrains.com/ruby/

It's a version of Intellij for Ruby and Rails. It's got excellent debugging tools. You can find more information about how to set breakpoints and so forth here: https://www.jetbrains.com/ruby/features/ruby_debugger.html

RubyMine is gaining popularity, but most ruby developers just drop a binding.pry at the point in their code they want to debug. Pry is an extremely popular gem that offers great debugging tools. Here's more info on how to use that particular feature: https://github.com/pry/pry#runtime-invocation

like image 37
williamcodes Avatar answered Sep 28 '22 19:09

williamcodes