• Home

  • Custom Ecommerce
  • Application Development
  • Database Consulting
  • Cloud Hosting
  • Systems Integration
  • Legacy Business Systems
  • Security & Compliance
  • GIS

  • Expertise

  • About Us
  • Our Team
  • Clients
  • Blog
  • Careers

  • VisionPort

  • Contact
  • Our Blog

    Ongoing observations by End Point Dev people

    Linting Ruby In Your Editor

    Patrick Lewis

    By Patrick Lewis
    June 27, 2019

    Cotton Photo by Kimberly Vardeman, used under CC BY 2.0

    Ruby developers have access to a variety of linters and static program analysis tools that can greatly improve developer efficiency and code quality by catching syntax errors, detecting code smells, and making coding style suggestions based on popular style guides.

    I have been a long-time advocate of configuring development environments with automatic code linting and will use this post to highlight some of the available tools for Ruby and methods for integrating them with popular code editors (Vim, Emacs, and Visual Studio Code).

    Configuring your editor for automatic linting makes it much easier to identify and fix issues with your code at development time, and in-editor integration is very convenient for highlighting problems as you type (or save), making it easy to evaluate and improve the quality of your code as it is written.

    Three popular linting plugins/extensions for Vim, Visual Studio Code, and Emacs are:

    Asynchronous Lint Engine (ALE) Plugin for Vim

    Provides asynchronous linting in Vim while you edit, and displays warnings/error messages in the editor. Supports the following tools for Ruby development and runs them automatically if they are found in your PATH:

    Ruby Extension for Visual Studio Code

    Requires configuring the settings JSON file to enable each tool on an individual basis:

    // Basic settings: turn linter(s) on
    "ruby.lint": {
    	"reek": true,
    	"rubocop": true,
    	"ruby": true, //Runs ruby -wc
    	"fasterer": true,
    	"debride": true,
    	"ruby-lint": true
    },
    

    Flycheck Extension for Emacs

    Detects and uses the following tools when editing Ruby code:

    Linter Selection

    I suggest starting small and only installing one or two linters to begin with; some choices provide similar features and will display conflicting or redundant warnings/errors if used at the same time. I think that RuboCop is a great first choice, and I have spent years using it as my primary linter, though recently I have started supplementing it with Reek and Fasterer.

    I highly recommend the use of these tools and consider them essential for any Ruby developer that is interested in improving the quality, reliability, and maintainability of their code.

    ruby vim vscode emacs tools


    Comments