My Experience with Ruby on Rails Apps Up-gradation | by Muhammad Umair | Jul 2022

  • You should use a single-cov gem to ensure a certain percentage of code coverage to ensure you know when and where the code is breaking.
  • You should also add it to the CI pipeline to ensure that your code will never go live if it does not reach a certain coverage percentage.
  1. Only use gems that have good community support. Otherwise, write your code. Otherwise you will have no support for new versions of Ruby or Rails and therefore technical debt, dependency conflicts between gems, etc.
  2. Upgrade gems whenever a new version is available. To check which gems are outdated and have newer versions, you can use the following command: obsolete batch
  3. Drop the version constraints into your Gemfile. You should never specify versions unless it is very critical. Here is a very good article by Clay Shentrup explaining why version constraints should not be used.
  4. STOP MONKEY PATCHING. You should not use forks for gems in your Gemfile. This would result in an outdated gem that you would have to make downstream changes to sync your fork every time a new version is released and potentially expose you to multiple vulnerabilities.
  5. Regularly audit your gems for vulnerabilities. There is a gem called bundler-audit that you can use for this purpose. Better include this audit in your pipeline to make sure vulnerable code never goes live
  6. Delete unused gems: you can use clean beam — dry running command to list all unused gems and then you can delete them.
  1. All obsolescence warnings begin with WARNING OF DEPRECATION & these warnings are available in your logs.
  2. Rails also allow us to throw an exception on the deprecation warning by setting config.active_support.deprecation=: increase in your development. rb file. This is the best approach to force developers to remove obsolete code.
  3. Shopify recently released a gem called deprecation-toolkit that helps you create a list called a shitlist of all deprecated warnings that you can store in a file and then delete them one by one.
  4. You should use rubocop in your codebase and run it regularly to maintain your codebase and remove outdated code.

About Author

Comments are closed.