gpt4 book ai didi

ruby-on-rails - 禁用内联或按方法臭味代码气味检测器

转载 作者:行者123 更新时间:2023-12-03 08:28:30 25 4
gpt4 key购买 nike

有没有办法禁用来自 reek 的警告gem 每个方法、每行还是每个 block ?

例如,我们为 rubocop 提供的内容

# suppress warning Use snake_case for method names
def fooBar(baz) # rubocop:disable Naming/MethodName
baz
end

此示例将抑制 rubocop 的警告,我正在寻找类似的 reek 工具。

def foo(bar) # reek:disable TooManyStatements
baz = bar + bar
# other line
# more line
# that produce reek warning
baz
end

在文档中我发现它只能通过配置文件进行配置,但这不是我想要的

最佳答案

https://github.com/troessner/reek/blob/master/docs/Smell-Suppression.md#how-to-disable-smell-detection

There are always the Basic Smell Options you can use in your configuration file.But in this document we would like to focus on a completely different way - via special comments.

A simple example:

# This method smells of :reek:NestedIterators
def smelly_method(foo)
foo.each { |bar| bar.each { |baz| baz.qux } }
end

The method smelly_method will not be reported. The general pattern is to put the string :reek:, followed by the smell class, in a comment before the method or class.

关于ruby-on-rails - 禁用内联或按方法臭味代码气味检测器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65917839/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com