Skip to content

Commit

Permalink
Setup rubocop and apply Rails style guide
Browse files Browse the repository at this point in the history
  • Loading branch information
hopsoft committed Oct 23, 2018
1 parent 1361957 commit 3c97d9f
Show file tree
Hide file tree
Showing 48 changed files with 934 additions and 690 deletions.
222 changes: 222 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
AllCops:
TargetRubyVersion: 2.5
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Exclude:
- '**/templates/**/*'
- '**/vendor/**/*'
- 'actionpack/lib/action_dispatch/journey/parser.rb'
- 'railties/test/fixtures/tmp/**/*'
- 'node_modules/**/*'
- 'bin/*'

Performance:
Exclude:
- '**/test/**/*'

Rails:
Enabled: true

# Prefer assert_not over assert !
Rails/AssertNot:
Include:
- '**/test/**/*'

# Prefer assert_not_x over refute_x
Rails/RefuteMethods:
Include:
- '**/test/**/*'

# Prefer &&/|| over and/or.
Style/AndOr:
Enabled: true

# Do not use braces for hash literals when they are the last argument of a
# method call.
Style/BracesAroundHashParameters:
Enabled: true
EnforcedStyle: context_dependent

# Align `when` with `case`.
Layout/CaseIndentation:
Enabled: true

# Align comments with method definitions.
Layout/CommentIndentation:
Enabled: true

Layout/ElseAlignment:
Enabled: true

# Align `end` with the matching keyword or starting expression except for
# assignments, where it should be aligned with the LHS.
Layout/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: variable
AutoCorrect: true

Layout/EmptyLineAfterMagicComment:
Enabled: true

Layout/EmptyLinesAroundBlockBody:
Enabled: true

# In a regular class definition, no empty lines around the body.
Layout/EmptyLinesAroundClassBody:
Enabled: true

# In a regular method definition, no empty lines around the body.
Layout/EmptyLinesAroundMethodBody:
Enabled: true

# In a regular module definition, no empty lines around the body.
Layout/EmptyLinesAroundModuleBody:
Enabled: true

Layout/FirstParameterIndentation:
Enabled: true

# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
Style/HashSyntax:
Enabled: true

# Method definitions after `private` or `protected` isolated calls need one
# extra level of indentation.
Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: rails

# Two spaces, no tabs (for indentation).
Layout/IndentationWidth:
Enabled: true

Layout/LeadingCommentSpace:
Enabled: true

Layout/SpaceAfterColon:
Enabled: true

Layout/SpaceAfterComma:
Enabled: true

Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true

Layout/SpaceAroundKeyword:
Enabled: true

Layout/SpaceAroundOperators:
Enabled: true

Layout/SpaceBeforeComma:
Enabled: true

Layout/SpaceBeforeFirstArg:
Enabled: true

Style/DefWithParentheses:
Enabled: true

# Defining a method with parameters needs parentheses.
Style/MethodDefParentheses:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always
Exclude:
- 'actionview/test/**/*.builder'
- 'actionview/test/**/*.ruby'
- 'actionpack/test/**/*.builder'
- 'actionpack/test/**/*.ruby'
- 'activestorage/db/migrate/**/*.rb'

Style/RedundantFreeze:
Enabled: true
Exclude:
- 'actionpack/lib/action_dispatch/journey/router/utils.rb'
- 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb'

# Use `foo {}` not `foo{}`.
Layout/SpaceBeforeBlockBraces:
Enabled: true

# Use `foo { bar }` not `foo {bar}`.
Layout/SpaceInsideBlockBraces:
Enabled: true
EnforcedStyleForEmptyBraces: space

# Use `{ a: 1 }` not `{a:1}`.
Layout/SpaceInsideHashLiteralBraces:
Enabled: true

Layout/SpaceInsideParens:
Enabled: true

# Check quotes usage according to lint rule below.
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes

# Detect hard tabs, no hard tabs.
Layout/Tab:
Enabled: true

# Blank lines should not have any spaces.
Layout/TrailingBlankLines:
Enabled: true

# No trailing whitespace.
Layout/TrailingWhitespace:
Enabled: true

# Use quotes for string literals when they are enough.
Style/UnneededPercentQ:
Enabled: true

# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
Lint/RequireParentheses:
Enabled: true

Lint/StringConversionInInterpolation:
Enabled: true

Lint/UriEscapeUnescape:
Enabled: true

Style/ParenthesesAroundCondition:
Enabled: true

Style/RedundantReturn:
Enabled: true
AllowMultipleReturnValues: true

Style/Semicolon:
Enabled: true
AllowAsExpressionSeparator: true

# Prefer Foo.method over Foo::method
Style/ColonMethodCall:
Enabled: true

Style/TrivialAccessors:
Enabled: true

Performance/FlatMap:
Enabled: true

Performance/RedundantMerge:
Enabled: true

Performance/StartWith:
Enabled: true

Performance/EndWith:
Enabled: true

Performance/RegexpMatch:
Enabled: true

Performance/UnfreezeString:
Enabled: true
79 changes: 41 additions & 38 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,52 +1,55 @@
source 'https://rubygems.org'
# frozen_string_literal: true

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.5.3'
ruby "2.5.3"

gem 'active_link_to', '~> 1.0.5'
gem 'bootsnap', '>= 1.1.0', require: false
gem 'cable_ready', '~> 2.0.6'
gem 'country_select'
gem 'devise'
gem 'jbuilder', '~> 2.5'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 3.11'
gem 'rails', '~> 5.2.1'
gem 'redis', '~> 4.0'
gem 'sass-rails', '~> 5.0'
gem 'simple_form', '~> 4.0'
gem 'stimulus_reflex', '~> 0.1.8'
gem 'tag_columns', '~> 0.1.6'
gem 'turbolinks', '~> 5'
gem 'uglifier', '>= 1.3.0'
gem 'webpacker', '~> 3.5'
gem "active_link_to", "~> 1.0.5"
gem "bootsnap", ">= 1.1.0", require: false
gem "cable_ready", "~> 2.0.6"
gem "country_select"
gem "devise"
gem "jbuilder", "~> 2.5"
gem "pg", ">= 0.18", "< 2.0"
gem "puma", "~> 3.11"
gem "rails", "~> 5.2.1"
gem "redis", "~> 4.0"
gem "sass-rails", "~> 5.0"
gem "simple_form", "~> 4.0"
gem "stimulus_reflex", "~> 0.1.8"
gem "tag_columns", "~> 0.1.6"
gem "turbolinks", "~> 5"
gem "uglifier", ">= 1.3.0"
gem "webpacker", "~> 3.5"

group :development, :test do
gem 'awesome_print'
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'dotenv'
gem 'pry'
gem 'pry-byebug'
gem 'pry-rails'
gem "awesome_print"
gem "byebug", platforms: [:mri, :mingw, :x64_mingw]
gem "dotenv"
gem "pry"
gem "pry-byebug"
gem "pry-rails"
end

group :development do
#gem 'spring'
#gem 'spring-watcher-listen', '~> 2.0.0'
gem 'annotate'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'magic_frozen_string_literal'
gem 'model_probe'
gem 'rufo'
gem 'teamocil'
gem 'web-console', '>= 3.3.0'
# gem 'spring'
# gem 'spring-watcher-listen', '~> 2.0.0'
gem "annotate"
gem "listen", ">= 3.0.5", "< 3.2"
gem "magic_frozen_string_literal"
gem "model_probe"
gem "rubocop"
gem "rufo"
gem "teamocil"
gem "web-console", ">= 3.3.0"
end

group :test do
gem 'capybara', '>= 2.15'
gem 'chromedriver-helper'
gem 'selenium-webdriver'
gem "capybara", ">= 2.15"
gem "chromedriver-helper"
gem "selenium-webdriver"
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
18 changes: 18 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ GEM
archive-zip (0.11.0)
io-like (~> 0.3.0)
arel (9.0.0)
ast (2.4.0)
awesome_print (1.8.0)
bcrypt (3.1.12)
bindex (0.5.0)
Expand Down Expand Up @@ -101,6 +102,7 @@ GEM
concurrent-ruby (~> 1.0)
i18n_data (0.8.0)
io-like (0.3.0)
jaro_winkler (1.5.1)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
Expand Down Expand Up @@ -130,7 +132,11 @@ GEM
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
orm_adapter (0.5.0)
parallel (1.12.1)
parser (2.5.1.2)
ast (~> 2.4.0)
pg (1.1.3)
powerpack (0.1.2)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
Expand Down Expand Up @@ -170,6 +176,7 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rainbow (3.0.0)
rake (12.3.1)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
Expand All @@ -178,6 +185,15 @@ GEM
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
rubocop (0.59.2)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.10.0)
ruby_dep (1.5.0)
rubyzip (1.2.2)
rufo (0.4.0)
Expand Down Expand Up @@ -227,6 +243,7 @@ GEM
thread_safe (~> 0.1)
uglifier (4.1.19)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.4.0)
unicode_utils (1.4.0)
warden (1.2.7)
rack (>= 1.0)
Expand Down Expand Up @@ -271,6 +288,7 @@ DEPENDENCIES
puma (~> 3.11)
rails (~> 5.2.1)
redis (~> 4.0)
rubocop
rufo
sass-rails (~> 5.0)
selenium-webdriver
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative 'config/application'
require_relative "config/application"

Rails.application.load_tasks
Loading

0 comments on commit 3c97d9f

Please sign in to comment.