# RuboCop Airbnb
Airbnb specific analysis for [RuboCop](https://github.com/rubocop-hq/rubocop).
It contains Airbnb's internally used configuration for
[RuboCop](https://github.com/rubocop-hq/rubocop) and
[RuboCop RSpec](https://github.com/backus/rubocop-rspec). It also includes a handful custom rules
that are not currently addressed by other projects.
## Installation
Just put this in your `Gemfile` it depends on the appropriate version of rubocop and rubocop-rspec.
```
gem 'rubocop-airbnb'
```
Note: If you want to run with Ruby 2.2 you will need to set your version to 2
```
gem 'rubocop-airbnb', '~> 2'
```
## Usage
You need to tell RuboCop to load the Airbnb extension. There are three
ways to do this:
### RuboCop configuration file
First Create a new file `.rubocop_airbnb.yml` in the same directory as your `.rubocop.yml`
this file should contain
```
require:
- rubocop-airbnb
```
Next add the following to `.rubocop.yml`
or add before `.rubocop_todo.yml` in your existing `inherit_from`
```
inherit_from:
- .rubocop_airbnb.yml
- .rubocop_todo.yml
```
You need to inherit `.rubocop_airbnb.yml` from another file because of Rubocop order of operations.
It runs `inherit_from` before `require` commands. If the configuration is not in a separate file
you could potentially experience a bunch of warnings from `.rubocop_todo.yml` for non-existant
`Airbnb` rules.
Now you can run `rubocop` and it will automatically load the RuboCop Airbnb
cops together with the standard cops.
### Command line
```bash
rubocop --require rubocop-airbnb
```
## The Cops
All cops are located under
[`lib/rubocop/cop/airbnb`](lib/rubocop/cop/airbnb), and contain
examples/documentation.
In your `.rubocop.yml`, you may treat the Airbnb cops just like any other
cop. For example:
```yaml
Airbnb/PhraseBundleKeys:
Exclude:
- spec/my_poorly_named_spec_file.rb
```
没有合适的资源?快使用搜索试试~ 我知道了~
Airbnb Ruby代码风格指南:实战版
共64个文件
rb:43个
yml:15个
md:3个
0 下载量 72 浏览量
2024-05-13
19:59:02
上传
评论
收藏 62KB ZIP 举报
温馨提示
资源简介: 在高质量软件开发中,代码风格和一致性的重要性不言而喻。基于Airbnb的Ruby代码风格指南,本资源提供了一套详尽的编程规范及示例,旨在帮助Ruby开发者提升代码质量,确保项目的可读性和可维护性。无论是个人开发者还是团队协作,遵循这些经过实战验证的指南都将使得代码更加优雅、清晰和高效。 主要特性: 全面的风格指南:涵盖从命名约定到错误处理的各个方面,基于Airbnb多年的实战经验总结而来。 易于遵循的规则:每项规则都配有清晰的例子和解释,使其易于理解和实施。 实用的Ruby编程技巧:除了基本规则,还提供了Ruby语言的高级技巧和最佳实践。 集成自动化工具:包括配置文件,可用于流行的代码质量检测工具,如RuboCop,以自动化代码审查过程。 持续更新:随着Ruby语言和开发实践的演进,资源将定期更新,保持最新状态。 适用场景: 代码质量提升:适用于希望提高代码标准的企业和开发者。 新员工培训:为新加入的团队成员提供明确的编码指导。 教育和学习:理想的教材,用于教授现代编程实践和代码风格。
资源推荐
资源详情
资源评论
收起资源包目录
ruby.zip (64个子文件)
ruby-main
rubocop-airbnb
lib
rubocop
airbnb.rb 461B
airbnb
inject.rb 693B
inflections.rb 393B
rails_autoloading.rb 2KB
version.rb 155B
cop
airbnb
no_timeout.rb 784B
unsafe_yaml_marshal.rb 1KB
const_assigned_in_wrong_file.rb 3KB
factory_class_use_string.rb 1KB
class_or_module_declared_in_wrong_file.rb 4KB
simple_unless.rb 544B
opt_arg_parameters.rb 1KB
continuation_slash.rb 726B
rspec_environment_modification.rb 2KB
rspec_describe_or_context_under_namespace.rb 4KB
phrase_bundle_keys.rb 2KB
module_method_in_wrong_file.rb 3KB
simple_modifier_conditional.rb 735B
spec_constant_assignment.rb 1KB
risky_activerecord_invocation.rb 2KB
default_scope.rb 699B
mass_assignment_accessible_modifier.rb 522B
factory_attr_references_class.rb 3KB
rubocop-airbnb.rb 262B
.rubocop.yml 132B
LICENSE.md 1KB
.rspec 30B
rubocop-airbnb.gemspec 1KB
spec
rubocop
cop
airbnb
continuation_slash_spec.rb 3KB
default_scope_spec.rb 888B
risky_activerecord_invocation_spec.rb 1KB
factory_attr_references_class_spec.rb 4KB
simple_unless_spec.rb 673B
rspec_environment_modification_spec.rb 1KB
simple_modifier_conditional_spec.rb 3KB
no_timeout_spec.rb 819B
factory_class_use_string_spec.rb 555B
class_or_module_declared_in_wrong_file_spec.rb 5KB
phrase_bundle_keys_spec.rb 1KB
mass_assignment_accessible_modifier_spec.rb 706B
opt_arg_parameter_spec.rb 2KB
module_method_in_wrong_file_spec.rb 4KB
spec_constant_assignment_spec.rb 2KB
const_assigned_in_wrong_file_spec.rb 4KB
unsafe_yaml_marshal_spec.rb 924B
rspec_describe_or_context_under_namespace_spec.rb 6KB
spec_helper.rb 1KB
CHANGELOG.md 2KB
.rubocop_airbnb.yml 385B
Gemfile 71B
README.md 2KB
config
rubocop-bundler.yml 128B
rubocop-style.yml 29KB
default.yml 1KB
rubocop-airbnb.yml 3KB
rubocop-rails.yml 5KB
rubocop-security.yml 322B
rubocop-rspec.yml 8KB
rubocop-performance.yml 4KB
rubocop-naming.yml 2KB
rubocop-metrics.yml 1KB
rubocop-layout.yml 16KB
rubocop-lint.yml 8KB
rubocop-gemspec.yml 292B
共 64 条
- 1
资源评论
拉叭叭小能手
- 粉丝: 36
- 资源: 21
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功