Skip to main content
Version: 1.1.1

Development

Debugging

JavaScript

You can use your browser's developer tools:

https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_are_browser_developer_tools

Ruby (Rails application)

Below are two options for "live"-debugging Ruby code (i.e., while the application is running).

Pry

Install pry and set binding.pry breakpoints in your Ruby code: https://docs.gitlab.com/ee/development/pry_debugging.html. Pry should work independently of your IDE.

Visual Studio Code

If you're using the Visual Studio Code IDE, you can use it's visual / GUI debugger. The configuration depends on your local setup, however, following these instructions should get you started fine:

https://andyv.me/til/debug-a-ruby-on-rails-server-using-vs-code/.

In case debugging doesn't work yet, have a look at the following resources to fine-tune your configuration:

https://github.com/rubyide/vscode-ruby/blob/main/docs/debugger.md https://github.com/Microsoft/vscode-recipes/blob/2174a750102a76142378ea08dbbb4a576dc6d1d5/debugging-Ruby-on-Rails/README.md

Linting

For linting and formatting Ruby and JavaScript, RuboCop and ESLint are used respectively. They can be used with the following commands from the inside of a Chemotion ELN installation directory. The flags -a or -x for rubocop and --fix for ESLint are for correcting and therefore changing the code. Without the flags errors or warnings are displayed, but no changes are made to the code.

rubocop [-a | -x] [paths]
yarn run eslint [--fix] [paths]

When ESLint detects linting errors, it will finishes by default with the exit code 1. This can lead to scripts being terminated with error codes in some environments (e. g. GitHub Actions). To avoid this the eslint-plugin-only-warn can be added via yarn which returns warnings instead of errors. The plugin needs to be activated with a flag in the ESLint command:

yarn run eslint --plugin eslint-plugin-only-warn [--fix] [paths]

There are Linting extensions for Visual Studio Code available.

Visual Studio Code

Vim

Check https://github.com/dense-analysis/ale.

Webpack

Debug

The webpack configurations can be printed to the node console via:

RAILS_ENV=test node -e 'console.dir(require("config/webpack/test"), { depth: null })'