Skip to content

Instantly share code, notes, and snippets.

@pocke
Created January 21, 2020 14:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pocke/d6aa017eca672aca763176ddfd289e20 to your computer and use it in GitHub Desktop.
Save pocke/d6aa017eca672aca763176ddfd289e20 to your computer and use it in GitHub Desktop.

Title

Tool around types

Abstract

Ruby will introduce static analysis in Ruby 3. It means Ruby will have static types. I'll talk about a tool that integrates RuboCop and the static types.

Details

I created and am developing a RuboCop plugin, that is called rubocop-typed (tentative). https://github.com/pocke/rubocop-typed.

It integrates RuboCop and Static typing by using Steep. It means RuboCop can use type information for the analysis. "This variable is String type", "This method call returns Array of Integer", and more.

I think it can improve RuboCop's analysis. Currently, RuboCop gives up implementing some kind of Cop (Cop is the name of rule) due to too many false positives. For example, "div vs []" is a good example. If we will implement a cop that replaces a[:b][:c] with a.dig(:b, :c) without the types, it will introduce too many false positives. But we can implement it without false positives by types. And I already implemented the example as a PoC. https://github.com/pocke/rubocop-typed/blob/ea4241064e171e181f3c4dea5df95f49168d2798/lib/rubocop/cop/typed/dig.rb

In this talk, I'll introduce the RuboCop plugin. How to use, and how to develop. And I'll describe the plugin resolves what kind of problem.

Pitch

I have three years experiecne in developing RuboCop.And I'm involved in the ruby-signature project. I think I can talk well about this theme.

And Static Analysis is one of the main features of Ruby 3. The past Kaigis had many talks about types. But I cannot find any talk for integration between types and existing tools. So I think my talk will be interesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment