Sha256: 024ca3465fb8164a3e82b28be29270b3c96a2e11a15c2972dcfebf6ff9d55c7f
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Sorbet # This cop 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: ["sorbet/rbi/**"]) # # @example # # bad # # lib/some_file.rbi # # other_file.rbi # # # good # # sorbet/rbi/some_file.rbi # # sorbet/rbi/any/path/for/file.rbi class ForbidRBIOutsideOfAllowedPaths < RuboCop::Cop::Cop include RangeHelp def investigate(processed_source) add_offense( nil, location: source_range(processed_source.buffer, 1, 0), message: message ) if allowed_paths.none? { |pattern| File.fnmatch(pattern, processed_source.file_path) } end private def allowed_paths cop_config["AllowedPaths"]&.compact || [] end def message if allowed_paths.empty? "RBI files should be located in an allowed path, but AllowedPaths is empty or nil" else "RBI file path should match one of: #{allowed_paths.join(", ")}" end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-sorbet-0.6.3 | lib/rubocop/cop/sorbet/rbi/forbid_rbi_outside_of_allowed_paths.rb |