{"id":107,"date":"2014-05-09T16:19:06","date_gmt":"2014-05-09T07:19:06","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2014\/05\/09\/shimojo"},"modified":"2022-10-29T22:31:46","modified_gmt":"2022-10-29T13:31:46","slug":"shimojo","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2014\/05\/09\/shimojo\/","title":{"rendered":"RuboCop\u3092\u4f7f\u3063\u3066\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u306b\u6cbf\u3063\u305f\u30b3\u30fc\u30c9\u3092\u66f8\u304f"},"content":{"rendered":"

\u4e0b\u689d\u3067\u3059\u3002
\u73fe\u5728\u53c2\u52a0\u3057\u3066\u3044\u308bRails\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u306f\u3001RuboCop\u3092\u4f7f\u3063\u3066\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u306b\u5408\u308f\u305b\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002RuboCop\u306fRuby\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u9759\u7684\u89e3\u6790\u3057\u3001\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u306b\u5408\u3063\u3066\u3044\u306a\u3044\u7b87\u6240\u3092\u6307\u6458\u3057\u3066\u304f\u308c\u308b\u30c4\u30fc\u30eb\u3067\u3059\u3002\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u306f\u3042\u3063\u3066\u3082\u5b9f\u969b\u306b\u306f\u5b88\u3089\u308c\u306a\u3044\u3068\u3044\u3046\u73fe\u5b9f\u306f\u591a\u304f\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u30c4\u30fc\u30eb\u3092\u4f7f\u3063\u3066\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u3092\u5b88\u308d\u3046\u3068\u3044\u3046\u5bf8\u6cd5\u3067\u3059\u3002<\/p>\n

RuboCop\u3067\u30d9\u30fc\u30b9\u3068\u3057\u3066\u3044\u308b\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u81ea\u4f53\u306f\u3053\u308c<\/a>\u3067\u3059\u3002
\n\u307e\u305f\u3001
\u65e5\u672c\u8a9e\u8a33<\/a>\u3092\u3057\u3066\u304f\u308c\u3066\u3044\u308b\u65b9\u3082\u3044\u307e\u3059\u3002<\/p>\n

\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n

\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u3053\u308c\u3060\u3051\u3067\u3059\u3002<\/p>\n

$ gem install rubocop<\/code><\/pre>\n

\u4f7f\u7528\u65b9\u6cd5<\/h2>\n

\u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u914d\u4e0b\u306eRuby\u30bd\u30fc\u30b9\u3092\u5168\u3066\u30c1\u30a7\u30c3\u30af\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n

$ rubocop<\/code><\/pre>\n

\u30d5\u30a1\u30a4\u30eb\u6307\u5b9a\u3084\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u6307\u5b9a\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n

$ rubocop hoge.rb\n$ rubocop hoge<\/code><\/pre>\n

vim\u3068\u306e\u9023\u643a<\/h2>\n

RuboCop\u3068\u5404\u7a2e\u30a8\u30c7\u30a3\u30bf\u306e\u9023\u643a\u304c\u53ef\u80fd\u3067\u3059\u3002
\nvim\u30e6\u30fc\u30b6\u306f
Vim RuboCop<\/a>\u304c\u4f7f\u7528\u53ef\u80fd\u3067\u3059\u3002<\/p>\n

\u500b\u4eba\u7684\u306b\u306f\u3001\u3064\u3044\u3064\u3044RuboCop\u3092\u901a\u3057\u5fd8\u308c\u308b\u306e\u304c\u3044\u3084\u306a\u306e\u3067\u3001\u81ea\u52d5\u7684\u306b\u901a\u3059\u3088\u3046\u306b\u3057\u3066\u3042\u308a\u307e\u3059\u3002syntastic\u3092\u4f7f\u3044\u307e\u3059\u3002
syntastic\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u4e0a\u3067\u3001\u4ee5\u4e0b\u3092.vimrc\u306b\u8ffd\u52a0\u3002<\/p>\n

let g:syntastic_mode_map = { 'mode': 'active',\n             'active_filetypes': ['ruby'] }\nlet g:syntastic_ruby_checkers = ['rubocop']<\/code><\/pre>\n

\u3053\u308c\u3067\u3001\u4fdd\u5b58\u306e\u305f\u3073\u306bRuboCop\u304c\u8d70\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u4fdd\u5b58\u304c\u591a\u5c11\u91cd\u304f\u306a\u308a\u307e\u3059\u304c\u3001\u30bd\u30fc\u30b9\u3092\u66f8\u3044\u3066\u304b\u3089\u6d41\u3059\u3088\u308a\u3082\u30d9\u30bf\u30fc\u304b\u306a\u3068\u601d\u3044\u307e\u3059\u3002\u30c6\u30b9\u30c8\u307e\u3067\u901a\u3057\u3066\u304b\u3089\u3001RuboCop\u901a\u3059\u306e\u5fd8\u308c\u305f\u3053\u3068\u306b\u6c17\u3065\u3044\u3066\u3001\u5bfe\u5fdc\u3057\u3066\u304b\u3089\u307e\u305f\u30c6\u30b9\u30c8\u3059\u308b\u306e\u306f\u6642\u9593\u304c\u3082\u3063\u305f\u3044\u306a\u3044\u306e\u3067\u3002<\/p>\n

\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u306e\u5909\u66f4<\/h2>\n

\u500b\u4eba\u7684\u611f\u60f3\u3068\u3057\u3066\u306f\u3001\u6700\u521d\u306bRuboCop\u3092\u4f7f\u3063\u305f\u3068\u304d\u306f\u3001\u30c1\u30a7\u30c3\u30af\u304c\u3051\u3063\u3053\u3046\u53b3\u3057\u3044\u306a\u3042\u3068\u3044\u3046\u5370\u8c61\u3067\u3057\u305f\u3002\u3042\u3068\u3001\u305f\u307e\u306b\u4f55\u3092\u6307\u6458\u3055\u308c\u3066\u3044\u308b\u306e\u304b\u308f\u304b\u3089\u306a\u3044\u3053\u3068\u3082\u3042\u308a\u307e\u3057\u305f\u3002
\n\u7279\u306b\u3001\u3053\u308c\u307e\u3067\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306e1\u884c80\u6587\u5b57\u5236\u9650\u3092\u6c17\u306b\u3057\u305f\u3053\u3068\u304c\u306a\u304b\u3063\u305f\u3053\u3068\u304c\u591a\u3044\u306e\u3067\u3059\u304c\u3001\u53c2\u52a0\u3057\u305f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u306f1\u884c80\u6587\u5b57\u5236\u9650\u304c\u3042\u308a\u3001\u6163\u308c\u308b\u307e\u3067\u3061\u3087\u3063\u3068\u82e6\u52b4\u3057\u307e\u3057\u305f\u3002 <\/p>\n

\u307e\u3042\u6163\u308c\u305f\u3089\u5927\u3057\u305f\u3053\u3068\u306f\u306a\u3044\u306e\u3067\u3059\u3057\u3001\u6b21\u7b2c\u306b\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u304c\u982d\u306b\u5165\u3063\u3066\u304f\u308b\u306e\u3067RuboCop\u306e\u6307\u6458\u304c\u5165\u308b\u3053\u3068\u3082\u5c11\u306a\u304f\u306a\u3063\u3066\u304d\u307e\u3059\u3002
\n\u305f\u3060\u3001\u30e1\u30bd\u30c3\u30c9\u4e00\u306410\u884c\u3068\u304b\u3061\u3087\u3063\u3068\u304d\u3064\u3044\u30eb\u30fc\u30eb\u3082\u3042\u308b\u306e\u3067\u3001\u9069\u5b9c.rubocop.yml\u30d5\u30a1\u30a4\u30eb\u3067\u8a2d\u5b9a\u3092\u5909\u66f4\u3057\u3066\u3044\u304f\u306e\u304c\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

\u305f\u3081\u3057\u306b<\/h2>\n

RuboCop\u81ea\u4f53\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092RuboCop\u306b\u304b\u3051\u3066\u307f\u307e\u3057\u305f\u3002\u5168\u90e8\u5b8c\u74a7\u306b\u901a\u3063\u3066\u3044\u307e\u3059\u3002\u3055\u3059\u304c\uff01<\/p>\n

\/Users\/shimojomasatsugu\/Development\/rubocop% rubocop\nInspecting 469 files\n.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\n\n469 files inspected, no offenses detected<\/code><\/pre>\n

\u3068\u601d\u3063\u305f\u3089\u3001\u3001\u3001.rubocop_todo.yml\u3067\u8a2d\u5b9a\u3092\u5909\u66f4\u3057\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n

\uff08\u524d\u7565\uff09\n# Offense count: 24\nCyclomaticComplexity:\n  Max: 10\n\n# Offense count: 114\n# Configuration parameters: CountComments.\nMethodLength:\n  Max: 20<\/code><\/pre>\n

\u3042\u308c\u3001\u672c\u5bb6\u304c\u3053\u308c\u3092\u3084\u308b\u306e\u306f\u53cd\u5247\u3067\u306f\u30fb\u30fb\u30fb <\/p>\n

\u3068\u601d\u3046\u6c17\u6301\u3061\u306f\u7f6e\u3044\u3066\u304a\u3044\u3066\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306fCyclomaticComplexity\u306f6\u3001MethodLength\u306f10\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u500b\u4eba\u7684\u306b\u3082\u3061\u3087\u3063\u3068\u53b3\u3057\u3044\u306e\u3067\u306f\u3068\u601d\u3063\u3066\u3044\u307e\u3057\u305f\u3002\u307e\u3042\u7d0d\u5f97\u3067\u3059\u3002<\/p>\n

\u306a\u304a\u3001\u6700\u8fd1\u3001
\n
SideCI<\/a>
\n\u3068\u3044\u3046\u30b5\u30fc\u30d3\u30b9\u304c\u767b\u5834\u3057\u307e\u3057\u305f\u3002\u3053\u308c\u3082\u9759\u7684\u89e3\u6790\u30c4\u30fc\u30eb\u3067\u3059\u304c\u3001Rails\u306e\u30bd\u30fc\u30b9\u3092\u5bfe\u8c61\u306b\u3001Rails\u3089\u3057\u304f\u306a\u3044\u30b3\u30fc\u30c9\u3084\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306b\u554f\u984c\u304c\u3042\u308b\u30b3\u30fc\u30c9\u306a\u3069\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u304f\u308c\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u6c17\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u307e\u305f\u30ec\u30dd\u30fc\u30c8\u3067\u304d\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u4e0b\u689d\u3067\u3059\u3002\u73fe\u5728\u53c2\u52a0\u3057\u3066\u3044\u308bRails\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u306f\u3001RuboCop\u3092\u4f7f\u3063\u3066\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u306b\u5408\u308f\u305b\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002RuboCop\u306fRuby\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u9759\u7684\u89e3\u6790\u3057\u3001\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u306b\u5408\u3063\u3066\u3044\u306a\u3044\u7b87\u6240\u3092\u6307\u6458\u3057\u3066\u304f\u308c\u308b\u30c4\u30fc\u30eb\u3067\u3059\u3002\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u306f\u3042\u3063\u3066\u3082\u5b9f\u969b\u306b\u306f\u5b88\u3089\u308c\u306a\u3044\u3068\u3044\u3046\u73fe\u5b9f\u306f\u591a\u304f\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u30c4\u30fc\u30eb\u3092\u4f7f\u3063\u3066\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u898f\u7d04\u3092\u5b88\u308d\u3046\u3068\u3044\u3046\u5bf8\u6cd5\u3067\u3059\u3002 RuboCop\u3067\u30d9\u30fc\u30b9 […]<\/p>\n","protected":false},"author":4,"featured_media":684,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[42],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/107"}],"collection":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/comments?post=107"}],"version-history":[{"count":1,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/107\/revisions"}],"predecessor-version":[{"id":3331,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/107\/revisions\/3331"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media?parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/categories?post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/tags?post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}