Skip to content

Commit

Permalink
Rename ForbidRBIOutsideOfAllowedPaths to RBIFilePath
Browse files Browse the repository at this point in the history
This name is more idiomatic and focussed on what is allowed (using the
allowed paths) rather than forbidding other paths.
  • Loading branch information
sambostock committed Mar 20, 2024
1 parent c5a84ee commit 95e349d
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Sorbet/ForbidExtendTSigHelpersInShims:
Include:
- "**/*.rbi"

Sorbet/ForbidRBIOutsideOfAllowedPaths:
Sorbet/RBIFilePath:
Description: 'Forbids RBI files outside of the allowed paths'
Enabled: true
VersionAdded: 0.6.1
Expand Down
3 changes: 2 additions & 1 deletion config/obsoletion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
#
# See: https://docs.rubocop.org/rubocop/extensions.html#config-obsoletions
#
{}
renamed:
Sorbet/ForbidRBIOutsideOfAllowedPaths: Sorbet/RBIFilePath
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Sorbet
# # rbi/external_interface.rbi
# # sorbet/rbi/some_file.rbi
# # sorbet/rbi/any/path/for/file.rbi
class ForbidRBIOutsideOfAllowedPaths < RuboCop::Cop::Base
class RBIFilePath < RuboCop::Cop::Base
MSG = "RBI file path should match one of: %<allowed_paths>s"

def on_new_investigation
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/sorbet_cops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require_relative "sorbet/buggy_obsolete_strict_memoization"

require_relative "sorbet/rbi/forbid_extend_t_sig_helpers_in_shims"
require_relative "sorbet/rbi/forbid_rbi_outside_of_allowed_paths"
require_relative "sorbet/rbi/rbi_file_path"
require_relative "sorbet/rbi/single_line_rbi_class_module_definitions"

require_relative "sorbet/signatures/allow_incompatible_override"
Expand Down
2 changes: 1 addition & 1 deletion manual/cops.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ In the following section you find all available cops:
* [Sorbet/FalseSigil](cops_sorbet.md#sorbetfalsesigil)
* [Sorbet/ForbidExtendTSigHelpersInShims](cops_sorbet.md#sorbetforbidextendtsighelpersinshims)
* [Sorbet/ForbidIncludeConstLiteral](cops_sorbet.md#sorbetforbidincludeconstliteral)
* [Sorbet/ForbidRBIOutsideOfAllowedPaths](cops_sorbet.md#sorbetforbidrbioutsideofallowedpaths)
* [Sorbet/ForbidSuperclassConstLiteral](cops_sorbet.md#sorbetforbidsuperclassconstliteral)
* [Sorbet/ForbidTStruct](cops_sorbet.md#sorbetforbidtstruct)
* [Sorbet/ForbidTUnsafe](cops_sorbet.md#sorbetforbidtunsafe)
Expand All @@ -31,6 +30,7 @@ In the following section you find all available cops:
* [Sorbet/KeywordArgumentOrdering](cops_sorbet.md#sorbetkeywordargumentordering)
* [Sorbet/ObsoleteStrictMemoization](cops_sorbet.md#sorbetobsoletestrictmemoization)
* [Sorbet/OneAncestorPerLine](cops_sorbet.md#sorbetoneancestorperline)
* [Sorbet/RBIFilePath](cops_sorbet.md#sorbetrbifilepath)
* [Sorbet/RedundantExtendTSig](cops_sorbet.md#sorbetredundantextendtsig)
* [Sorbet/SignatureBuildOrder](cops_sorbet.md#sorbetsignaturebuildorder)
* [Sorbet/SingleLineRbiClassModuleDefinitions](cops_sorbet.md#sorbetsinglelinerbiclassmoduledefinitions)
Expand Down
64 changes: 32 additions & 32 deletions manual/cops_sorbet.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,38 +356,6 @@ or
include Polaris::Engine.helpers
```

## Sorbet/ForbidRBIOutsideOfAllowedPaths

Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
--- | --- | --- | --- | ---
Enabled | Yes | No | 0.6.1 | -

Makes sure that RBI files are always located under the defined allowed paths.

Options:

* `AllowedPaths`: A list of the paths where RBI files are allowed (default: ["rbi/**", "sorbet/rbi/**"])

### Examples

```ruby
# bad
# lib/some_file.rbi
# other_file.rbi

# good
# rbi/external_interface.rbi
# sorbet/rbi/some_file.rbi
# sorbet/rbi/any/path/for/file.rbi
```

### Configurable attributes

Name | Default value | Configurable values
--- | --- | ---
AllowedPaths | `rbi/**`, `sorbet/rbi/**` | Array
Include | `**/*.rbi` | Array

## Sorbet/ForbidSuperclassConstLiteral

Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
Expand Down Expand Up @@ -700,6 +668,38 @@ module SomeModule
end
```
## Sorbet/RBIFilePath
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
--- | --- | --- | --- | ---
Enabled | Yes | No | 0.6.1 | -
Makes sure that RBI files are always located under the defined allowed paths.
Options:
* `AllowedPaths`: A list of the paths where RBI files are allowed (default: ["rbi/**", "sorbet/rbi/**"])
### Examples
```ruby
# bad
# lib/some_file.rbi
# other_file.rbi
# good
# rbi/external_interface.rbi
# sorbet/rbi/some_file.rbi
# sorbet/rbi/any/path/for/file.rbi
```
### Configurable attributes
Name | Default value | Configurable values
--- | --- | ---
AllowedPaths | `rbi/**`, `sorbet/rbi/**` | Array
Include | `**/*.rbi` | Array
## Sorbet/RedundantExtendTSig
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "spec_helper"

RSpec.describe(RuboCop::Cop::Sorbet::ForbidRBIOutsideOfAllowedPaths, :config) do
RSpec.describe(RuboCop::Cop::Sorbet::RBIFilePath, :config) do
describe "with default configuration" do
it "registers an offense if an RBI file is outside AllowedPaths" do
expect_offense(<<~RUBY, filename: "some/dir/file.rbi")
Expand Down

0 comments on commit 95e349d

Please sign in to comment.