File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 103
103
end
104
104
end
105
105
106
+ it 'is expected that all cops documented with `@safety` are `Safe: false` or `SafeAutoCorrect: false`' do
107
+ require 'yard'
108
+
109
+ YARD ::Registry . load!
110
+
111
+ unsafe_cops = YARD ::Registry . all ( :class ) . select do |example |
112
+ example . tags . any? { |tag | tag . tag_name == 'safety' }
113
+ end
114
+
115
+ unsafe_cop_names = unsafe_cops . map do |cop |
116
+ department_and_cop_names = cop . path . split ( '::' ) [ 2 ..] # Drop `RuboCop::Cop` from class name.
117
+
118
+ department_and_cop_names . join ( '/' )
119
+ end
120
+
121
+ unsafe_cop_names . each do |cop_name |
122
+ cop_config = config [ cop_name ]
123
+ unsafe = cop_config [ 'Safe' ] == false || cop_config [ 'SafeAutoCorrect' ] == false
124
+
125
+ expect ( unsafe ) . to (
126
+ be ( true ) ,
127
+ "`#{ cop_name } ` cop should be set `Safe: false` or `SafeAutoCorrect: false` " \
128
+ 'because `@safety` YARD tag exists.'
129
+ )
130
+ end
131
+ end
132
+
106
133
it 'sorts cop names alphabetically' do
107
134
previous_key = ''
108
135
config_default = YAML . load_file ( 'config/default.yml' )
You can’t perform that action at this time.
0 commit comments