Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jmh committed Apr 13, 2023
0 parents commit 0f05b91
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Namely Ruby Whiff

Namely Ruby Whiff is a Ruby gem that contains common Rubocop configurations to use in your Ruby projects. New tools will be added over time, the next being ruby critic.

## Installation

To install Namely Ruby Whiff, simply add it to your Gemfile:

```ruby
gem 'namely-ruby-whiff'
```

And then run `bundle install`.

Next, replace your project's `.rubocop.yml` file with the following, followed by any rules or configurations you want to add or override:

```yaml
inherit_gem:
namely_ruby_whiff: config/rubocop-rails.yml
```
For non-Rails projects, use the following file path instead: `config/rubocop-vanilla.yml`.

## Usage

Once you've installed the gem, you can run Rubocop with the following command to make sure it's finding the configs from the gem:

```bash
bundle exec rubocop
```

The gem also includes `rubocop-changes` a tool to apply Rubocop to only the files that have changes in your branch.

```bash
bundle exec rubocop-changes
```
11 changes: 11 additions & 0 deletions config/rubocop-rails.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require:
- rubocop-rails

inherit_from:
- rubocop-vanilla.yml
- rubocop/rails.yml

AllCops:
Exclude:
- 'db/**/*'
TargetRubyVersion: 2.6
24 changes: 24 additions & 0 deletions config/rubocop-vanilla.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require:
- rubocop-rspec
- rubocop-performance

inherit_from:
- rubocop/layout.yml
- rubocop/lint.yml
- rubocop/metrics.yml
- rubocop/rspec.yml
- rubocop/style.yml

AllCops:
Exclude:
- 'bin/**/*'
- 'gen/**/*'
- 'protorepo/**/*'
# rubocop checks .ruby-version for version
# TargetRubyVersion: 2.6

Naming/MethodParameterName:
AllowedNames: ['id', 'ms', 'to']

Performance/OpenStruct:
Enabled: true
11 changes: 11 additions & 0 deletions config/rubocop/layout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Layout/FirstHashElementLineBreak:
Enabled: true

Layout/FirstMethodArgumentLineBreak:
Enabled: true

Layout/MultilineAssignmentLayout:
Enabled: true

Layout/LineLength:
Max: 120
17 changes: 17 additions & 0 deletions config/rubocop/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Lint:
Severity: refactor

Lint/NumberConversion:
Enabled: true

Lint/ShadowedException:
Enabled: false

Lint/RescueException:
Exclude:
- 'app/lib/koala/evaluator.rb'
- 'app/services/net_suite/gl_org_units_service.rb'

Lint/UnifiedInteger:
Exclude:
- 'app/models/type_for_field.rb'
28 changes: 28 additions & 0 deletions config/rubocop/metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Metrics/AbcSize:
Max: 100

Metrics/BlockLength:
Max: 40
Exclude:
- 'config/routes.rb'
- 'spec/factories.rb'
- 'spec/**/*_spec.rb'
- 'app/workers/net_suite_export_job.rb'

Metrics/ClassLength:
Max: 300

Metrics/CyclomaticComplexity:
Max: 15

Metrics/MethodLength:
Max: 60

Metrics/ModuleLength:
Max: 300

Metrics/PerceivedComplexity:
Max: 15

Metrics/ParameterLists:
Max: 8
20 changes: 20 additions & 0 deletions config/rubocop/rails.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Rails:
Enabled: true

Rails/ActiveRecordAliases:
Enabled: false

Rails/ActiveRecordOverride:
Enabled: false

Rails/HasManyOrHasOneDependent:
Enabled: false

Rails/InverseOf:
Enabled: false

Rails/SaveBang:
Enabled: false

Rails/SkipsModelValidations:
Enabled: false
24 changes: 24 additions & 0 deletions config/rubocop/rspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
RSpec/AnyInstance:
Enabled: false

RSpec/ExampleLength:
Max: 45

RSpec/MessageChain:
Enabled: false

RSpec/MessageSpies:
Enabled: false

RSpec/MultipleExpectations:
Max: 13

RSpec/NestedGroups:
Max: 5

RSpec/LetSetup:
Exclude:
- 'spec/mailers/gl_sync_mailer_spec.rb'

RSpec/NamedSubject:
Enabled: false
45 changes: 45 additions & 0 deletions config/rubocop/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Style/ClassAndModuleChildren:
Enabled: false

Style/ClassVars:
Exclude:
- 'app/lib/koala/evaluator.rb'

Style/DateTime:
Enabled: true
Exclude:
- 'app/workers/sync_job.rb'

Style/Documentation:
Enabled: false

Style/EachWithObject:
Exclude:
- 'app/models/namely_importer.rb'

Style/FrozenStringLiteralComment:
Exclude:
- 'app/lib/koala/evaluator.rb'
- 'spec/features/**/*_spec.rb'

Style/GuardClause:
MinBodyLength: 4

Style/MethodCalledOnDoEndBlock:
Enabled: false

Style/MethodMissingSuper:
Enabled: false

Style/MissingRespondToMissing:
Enabled: false

Style/MultilineMethodSignature:
Enabled: true

Style/MutableConstant:
Exclude:
- 'app/models/net_suite/constants.rb'

Style/Send:
Enabled: true
14 changes: 14 additions & 0 deletions namely_ruby_whiff.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Gem::Specification.new do |spec|
spec.name = 'namely_ruby_whiff'
spec.version = '0.0.2'
spec.summary = 'A set of configurations to support high quality Ruby code.'
spec.authors = ['[email protected]']
spec.files = []
spec.required_ruby_version = '>= 2.5.0'

spec.add_dependency 'rubocop', '>= 0.72'
spec.add_dependency 'rubocop-changes'
spec.add_dependency 'rubocop-performance'
spec.add_dependency 'rubocop-rails'
spec.add_dependency 'rubocop-rspec'
end

0 comments on commit 0f05b91

Please sign in to comment.