加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 修复`Missing frozen string literal comment`

发布时间:2020-12-17 03:32:59 所属栏目:百科 来源:网络整理
导读:我创建了一个新的迁移,它看起来像这样: class AddCommentsToUsers ActiveRecord::Migration def change add_column :users,:comments,:text endend 现在有了Code Climate,我被警告了一个问题: 缺少冻结的字符串文字注释. 我试着像这样解决它: # frozen_st
我创建了一个新的迁移,它看起来像这样:

class AddCommentsToUsers < ActiveRecord::Migration
  def change
    add_column :users,:comments,:text
  end
end

现在有了Code Climate,我被警告了一个问题:
缺少冻结的字符串文字注释.

我试着像这样解决它:

# frozen_string_literal: true
class AddCommentsToUsers < ActiveRecord::Migration
  def change
    add_column :users,:text
  end
end

但我仍然有同样的问题.我该如何解决?谢谢.

解决方法

我遇到了同样的问题. Rubocop之前工作得很好,但突然间它开始起作用了.我在github上阅读了他们的配置选项,看到了弄乱你的代码的特定属性.
该物业可在此处找到: FrozenStringLiteral.

要解决此问题,您只需将其添加到rubocop.yml文件中

Style/FrozenStringLiteralComment:
  Enabled: false

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读