0.0
A long-lived project that still receives updates
A RuboCop extension for converting Ruby to Crystal.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 1.80.2
 Project Readme

Rubocop::Crystal

The beginnings of a RuboCop extension for converting Ruby to Crystal.

TODO

Many things. In particular, how are types going to work?

Getting static type information about Ruby files isn't the difficult part, the problem is conveying this information to the Crystal compiler while still maintaining valid syntax.

Inserting Crystal types into Ruby code is a no-go, because that causes Lint/Syntax errors in RuboCop.

Possible paths forward:

  • Modify the parser to accept Crystal type declarations, or at least not break on them.
  • Modify Crystal to accept type declarations from .rbs and/or .rbi files.
  • Modify Crystal to accept type declarations from sorbet/rbs-inline/other annotations.
    • Write Ameba extension to convert the type annotations, as it works with Crystal syntax.
  • Find a way to convey type information to Crystal using valid Ruby syntax.

Interesting repos:

Installation

gem install rubocop-crystal

Usage

rubocop --plugin rubocop-crystal

Note that there are some differences between Ruby and Crystal that can be automatically resolved, while some (at least for now) require manual intervention.

If you wish to only process the autocorrectable offenses, add --disable-uncorrectable, while reporting only the offenses requiring manual intervention is waiting on rubocop/rubocop#13275.