Shopify / rubocop-sorbet

A collection of RuboCop rules for Sorbet
MIT License
181 stars 27 forks source link

Use `add_global_offense` for `ForbidRBIOutsideOfAllowedPaths` #251

Closed Earlopain closed 3 months ago

Earlopain commented 3 months ago

The previous add_offense errors when the file is empty: Range 0..1 makes no sense in that context. The error occurs during output:

test.rbi:1:1: C: Sorbet/ForbidRBIOutsideOfAllowedPaths: RBI file path should match one of: rbi/**, sorbet/rbi/**
index 0 outside of array bounds: 0...0

add_global_offense was added for Rubocop v1 which is great since 1.0.0 is now the minimum required version.

Why even bother?

I created a new rbi file for testing and ruby-lsp runs over it with rubocop immediatly which means it will error.

andyw8 commented 3 months ago

This makes me realize that Ruby LSP doesn't have a way to show 'global' offenses:

https://github.com/Shopify/ruby-lsp/issues/2388