Skip to content

Instantly share code, notes, and snippets.

@dvandersluis
Created September 17, 2021 04:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvandersluis/0d692eafd4696f542f5bd6abd1840043 to your computer and use it in GitHub Desktop.
Save dvandersluis/0d692eafd4696f542f5bd6abd1840043 to your computer and use it in GitHub Desktop.
describe 'cop description' do
let(:cops) do
RuboCop::Cop::Cop
.registry
.without_department(:Test)
.without_department(:InternalAffairs)
.cops
end
let(:config) { RuboCop::ConfigLoader.load_file('config/default.yml') }
it 'includes a @safety YARD tag for all cops that are `Safe: false` or `SafeAutoCorrect: false`' do
require 'yard'
YARD::Registry.load!
cops.each do |cop|
cop_config = config.dig(cop.cop_name)
next unless cop_config['Safe'] == false || cop_config['SafeAutoCorrect'] == false
yard = YARD::Registry.resolve(nil, cop.name)
expect(yard.tags('safety')).to_not be_empty, "unsafe cop `#{cop.cop_name}` is missing a `@safety` block in its description"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment