---
title: "rubocop 最佳实践"
author: "flowerwrong"
date: "2014-11-18T13:53:16Z"
tags: []
categories: ["编程语言"]
slug: "rubocop"
draft: false
lastmod: "2014-11-19T11:35:19Z"
id: 2157466
url: "https://flowerwrong.iteye.com/blog/2157466"
---

```
# class definition is too long
# This likely means that your class definition takes more than 100 lines of code.

# missing top-level class documentation comment
# 

# use only ascii symbols in comments(不能使用中文)
# 
```

 

```
# favor modifier if usage when having a single-line body
if token_reg =~ res.to_s
  @token = $1
end

@token = $1 if token_reg =~ res.to_s
# but Avoid using Perl-style special variables (like $0-9, $, etc. ). They are quite cryptic and their use in anything but one-liner scripts is discouraged. Prefer long form versions such as $PROGRAM_NAME.
```

 

```
# use def with parentheses when there are parameters
```