I want to make ruby-lint usable.

ruby-lint, as described by its author:

ruby-lint is a static code analysis tool for Ruby. It is inspired by tools such as jshint, flake8 and similar tools. ruby-lint primarily focuses on logic related errors such as the use of non existing variables instead of focusing on [style] (e.g. the amount of characters per line).

The features of ruby-lint include but are not limited to the detection of unused variables, the use of undefined methods and method calls with invalid argument amounts and more. More in-depth analysis will be added over time.

The aim of ruby-lint is to provide analysis that is as accurate as possible. However, due to the dynamic nature of Ruby and the sheer amount of meta-magic in third-party code there will at times be false positives. Analysis can be improved by documenting your code using YARD, in particular the @param and @return tags are used by ruby-lint to obtain extra information when processing methods.

Given the following code:

class Person
  def initialize(name)
    # oops, not setting [@name](/users/name)
  end

  def greet
    return "Hello, #{[@name](/users/name)}"
  end
end

user     = Person.new('Alice')
greeting = user.greet

user.greet(:foo)

Analysing this file using ruby-lint (with the default settings) would result in the following output:

test.rb: error: line 7, column 22: undefined instance variable [@name](/users/name)
test.rb: warning: line 12, column 1: unused local variable greeting
test.rb: error: line 14, column 1: wrong number of arguments for 'greet' (expected 0 but got 1)

If you have 100% test coverage, ruby-lint does not add value. But I have many projects that are less covered.

The problem with ruby-lint is that it produces way too many obvious false positives on all projects that I've tried it on.

I have started fixing it during the CSM Workshop 2016 and fixed some bugs and reported others.

The Hack Week project aims to make ruby-lint useful enough that it can be deployed in CI tests.

Looking for hackers with the skills:

Nothing? Add some keywords!

This project is part of:

Hack Week 14

Activity

  • over 8 years ago: michal-m liked this project.
  • over 8 years ago: mfilka joined this project.
  • over 8 years ago: teclator liked this project.
  • over 8 years ago: locilka liked this project.
  • over 8 years ago: mvidner started this project.
  • over 8 years ago: mvidner originated this project.

  • Comments

    • mvidner
      over 8 years ago by mvidner | Reply

      PR#184: Load constant Foo::Bar when Bar is seen inside Foo

    • okurz
      over 8 years ago by okurz | Reply

      The static code checker suite coala might be worth to look at

      • mvidner
        over 8 years ago by mvidner | Reply

        Thanks, I'll check it out!

      • mvidner
        over 8 years ago by mvidner | Reply

        Coala's strong point is offering a unified user interface for many analysis tools, even spanning multiple languages of the analyzed code. The drawback is that the unification only works on the commonalities between the languages, like line count, comments, and whitespace.

        For more advanced analysis Coala calls language specific backends, one exists for RuboCop, but not for ruby-lint.

        An interesting possibility would be to take the AST produced by parser.gem and send it to Coala (implemented in Python), probably via JSON. That would be a foundation for analyzing Ruby with Coala.

    • mvidner
      over 8 years ago by mvidner | Reply

      PR#187: Fix 'Not enough argument definitions' when parsing less usual constructs

      PR#188: Absolute constant lookup (::Foo)

    • mvidner
    • mvidner
      over 8 years ago by mvidner | Reply

      If you would like to try it on a piece of YaST, these definitions for the YaST libraries will be needed: https://github.com/mvidner/ruby-lint-definitions-yast

    • mvidner
      over 8 years ago by mvidner | Reply

      I have packaged an unofficial release of ruby-lint-2.2.0.0.20160630 in https://build.opensuse.org/package/show/devel:languages:ruby:extensions/rubygem-ruby-lint

    • mvidner
      over 8 years ago by mvidner | Reply

      https://github.com/mvidner/ruby-lint-definitions-yast updated with a README that shows how to run it.

    • mvidner
      over 8 years ago by mvidner | Reply

      Found 1 real bug among the false positives, https://github.com/config-files-api/config_files_api/pull/6

    • mvidner
      over 8 years ago by mvidner | Reply

      ruby-lint-2.3.0, including the above work, has been released and thanks to Coolo updated in devel:languages:ruby:extensions.

      We have not yet reached few enough false positives for the tool to be generally useful. I will continue working on it in my spare time.

    Similar Projects

    This project is one of its kind!