Rubocop for Crystal?

Is there an equivalent to Rubocop for Crystal?

I have been using crystal tool format but it doesn’t enforce all coding style guidelines (e.g. I have CamelCased a variable and it doesn’t tell me off or fix it).

Alternatively is there a Rubocop configuration that could be used for Crystal, while respecting the language differences?

Ameba gets closest I think, but we don’t use it inside the compiler/standard library, so no idea how much of a Christmas tree that would already light up trying to run it there :)

1 Like

I’ll take a look, but might leave running it on standard library for another weekend!

For the lols: https://paste.ee/p/KBcfI

src/compiler/crystal/syntax/lexer.cr:91:9
[C] Metrics/CyclomaticComplexity: Cyclomatic complexity too high [522/10]
> def next_token

^.^

Some are actionable, others not so much, like lexer/parser complexity or C API function names being camelcase.

2 Likes