Skip to content
Splines edited this page Jan 8, 2024 · 19 revisions

Linting 💫

We have different linters in place checking for style guideline violations (also in our CI/CD pipeline for every PR). Most of the linters are directly available and ready to use if you install the recommended extensions in the VSCode marketplace (we've set up the recommendations specifically for MaMpf).

TODO: refer to justfile with many commands

Setup Rubocop (Lint Ruby)

The backend of MaMpf is written in Ruby on Rails. Custom linting rules are defined in rubocop.yml.

Use Rubocop in VSCode

  • Install the recommended Ruby LSP extension and you'll be ready to lint any .rb file.

Troubleshooting:

  • Try to run the Ruby LSP: Restart command.
  • See the output of the plugin in the Output pane (choose "Ruby LSP" in the dropdown).

Setup ESLint (Lint JavaScript)

We use ESLint to lint .js and .js.erb files. In our CI/CD, we check for style guideline violations, so make sure to always submit already linted code. If you don't use VSCode, you can use the command line, i.e. yarn run eslint --fix ./your-file.js, or the respective ESLint extension/plugin in other IDEs. We provide the respective config file in the project root (.eslintrc.js).

Use ESLint in VSCode

  1. Install the ESLint extension on the marketplace (filter for the recommended extensions we set up).
  2. Install the necessary node modules: yarn install (this includes the eslint npm package and some other related packages that are necessary).
  3. Open any .js or .js.erb file, change something (e.g. remove a semicolon) and save the file. ESLint will automatically lint it. You can also use the Format Document command in the command palette.

Troubleshooting

  • Try to run the ESLint: Restart ESLint Server command.
  • See the output of the plugin in the Output pane (choose "ESLint" in the dropdown).

Code structure

Some overviews over the (fairly big) MaMpf code base.

  • Annotation tool & Thyme player (frontend): Thyme overview
  • Suggestions for Just:
    • Rails Sandbox
    • Reset the database to the prepopulated one

Testing ✅

Currently only available on branch pipeline/tests.

In VSCode, you can install the recommended extensions "Ruby Test Explorer". Then go to tests and click on Run all tests. See the "Output" tab in VSCode for errors of the plugin. You can also go to a _spec.rb file and run tests from there individually.

Note that in the test explorer pane, you should prefer to use Run all tests instead of "Run tests" for the "models". This is because with "Run all tests" only one docker container will be created while for the latter, a new docker container is created for every new _spec.rb file. The creation of the docker container takes quite some time, so use Run all tests to get faster test results (really a lot faster, like ~15min vs. ~1min).

In other IDEs, use respective test extensions. From the shell you can invoke the tests using TODO (include just command).

Clone this wiki locally