Skip to content

Commit 59ef765

Browse files
MONGOID-5304: Add Rubocop static code analyzer (#5243)
Co-authored-by: Dmitry Rybakov <[email protected]>
1 parent 67c211d commit 59ef765

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed

.github/workflows/rubocop.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Rubocop
3+
4+
on: [push, pull_request]
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
env:
10+
CI: true
11+
TESTOPTS: "-v"
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up Ruby 3.0
15+
uses: ruby/setup-ruby@v1
16+
with:
17+
ruby-version: 3.0
18+
bundler-cache: true
19+
- name: Run RuboCop
20+
run: bundle exec rubocop --parallel

.rubocop.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
inherit_from: .rubocop_todo.yml
2+
3+
require:
4+
- rubocop-performance
5+
- rubocop-rails
6+
- rubocop-rake
7+
- rubocop-rspec
8+
9+
AllCops:
10+
TargetRubyVersion: 2.6
11+
NewCops: enable
12+
Exclude:
13+
- 'spec/shared/lib/mrss/**/*'
14+
- 'vendor/**/*'
15+
16+
# -----------------------------------
17+
# TODO: Enable and fix the cops below
18+
# -----------------------------------
19+
20+
Gemspec:
21+
Enabled: false
22+
23+
Layout:
24+
Enabled: false
25+
26+
Lint:
27+
Enabled: false
28+
29+
Metrics:
30+
Enabled: false
31+
32+
Naming:
33+
Enabled: false
34+
35+
Performance:
36+
Enabled: false
37+
38+
Rake:
39+
Enabled: false
40+
41+
Rails:
42+
Enabled: false
43+
44+
RSpec:
45+
Enabled: false
46+
47+
Security:
48+
Exclude:
49+
- 'spec/**/*'
50+
51+
Style:
52+
Enabled: false
53+
54+
# --------------------------------------
55+
# Cops below this line set intentionally
56+
# --------------------------------------
57+
58+
Bundler/OrderedGems:
59+
Enabled: false
60+
61+
Gemspec/OrderedDependencies:
62+
Enabled: false
63+
64+
# Not used by Mongoid
65+
Rails/RedundantPresenceValidationOnBelongsTo:
66+
Enabled: false
67+
68+
Style/Documentation:
69+
Exclude:
70+
- 'spec/**/*'

.rubocop_todo.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2023-02-10 19:24:10 UTC using RuboCop version 1.45.1.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.

gemfiles/standard.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ def standard_dependencies
1515
# Evergreen configuration generation
1616
gem 'erubi'
1717
gem 'tilt'
18+
gem 'solargraph'
1819
end
1920

2021
group :development, :test do
2122
gem 'rspec-core', '~> 3.10'
23+
gem 'rubocop', '~> 1.45.1'
24+
gem 'rubocop-performance', '~> 1.16.0'
25+
gem 'rubocop-rails', '~> 2.17.4'
26+
gem 'rubocop-rake', '~> 0.6.0'
27+
gem 'rubocop-rspec', '~> 2.18.1'
2228

2329
platform :mri do
2430
gem 'byebug'

0 commit comments

Comments
 (0)