Skip to content

Commit

Permalink
Update Rubocop settings to community standards
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelherold committed Dec 26, 2018
1 parent 9529146 commit a959bbc
Show file tree
Hide file tree
Showing 39 changed files with 356 additions and 559 deletions.
276 changes: 2 additions & 274 deletions .rubocop.yml
Expand Up @@ -9,289 +9,17 @@ AllCops:
- "db/schema.rb"
TargetRubyVersion: 2.1

Naming/AccessorMethodName:
Description: Check the naming of accessor methods for get_/set_.
Enabled: false

Style/Alias:
Description: Use alias_method instead of alias.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
Enabled: false

Style/Attr:
Description: Checks for uses of Module#attr.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#attr
Enabled: false

Style/CollectionMethods:
Description: Preferred collection methods.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
Enabled: true
PreferredMethods:
collect: map
collect!: map!
find: detect
find_all: select
inject: reduce

Style/Documentation:
Description: Document classes and non-namespace modules.
Enabled: false

Layout/DotPosition:
Description: Checks the position of the dot in multi-line method calls.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
Enabled: true
EnforcedStyle: trailing
SupportedStyles:
- leading
- trailing

Style/DoubleNegation:
Description: Checks for uses of double negation (!!).
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
Enabled: false

Style/EachWithObject:
Description: Prefer `each_with_object` over `inject` or `reduce`.
Enabled: false

Style/EmptyLiteral:
Description: Prefer literals to Array.new/Hash.new/String.new.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
Enabled: false

Naming/FileName:
Description: Use snake_case for source file names.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
Enabled: true
Exclude:
- lib/benchmark-memory.rb

Style/GuardClause:
Description: Check for conditionals that can be replaced with guard clauses
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
Enabled: false
MinBodyLength: 1

Style/HashSyntax:
Description: Check the style of Hash syntax.
Enabled: true
EnforcedStyle: hash_rockets
SupportedStyles:
- hash_rockets
- ruby19
- ruby19_no_mixed_keys

Style/IfUnlessModifier:
Description: Favor modifier if/unless usage when you have a single-line body.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
Enabled: false

Style/InlineComment:
Description: Avoid inline comments.
Enabled: false

Style/ModuleFunction:
Description: Checks for usage of `extend self` in modules.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
Enabled: false

Style/OneLineConditional:
Description: Favor the ternary operator(?:) over if/then/else/end constructs.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
Enabled: false

Style/OptionHash:
Description: Do not use option hashes when you can use keyword arguments.
Enabled: false

Style/PercentLiteralDelimiters:
Description: Use `%`-literal delimiters consistently
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
Enabled: false
PreferredDelimiters:
"%": "()"
"%i": "()"
"%q": "()"
"%Q": "()"
"%r": "{}"
"%s": "()"
"%w": "()"
"%W": "()"
"%x": "()"

Style/PerlBackrefs:
Description: Avoid Perl-style regex back references.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
Enabled: false

Naming/PredicateName:
Description: Check the names of predicate methods.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
Enabled: true
NamePrefix:
- is_
- has_
- have_
NamePrefixBlacklist:
- is_
Exclude:
- spec/**/*

Style/RaiseArgs:
Description: Checks the arguments passed to raise/fail.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
Enabled: true
EnforcedStyle: exploded
SupportedStyles:
- compact
- exploded

Style/Send:
Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
may overlap with existing methods.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
Enabled: false

Style/SignalException:
Description: Checks for proper usage of fail and raise.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
Enabled: true
EnforcedStyle: semantic
SupportedStyles:
- only_raise
- only_fail
- semantic

Style/SingleLineBlockParams:
Description: Enforces the names of some block params.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
Enabled: false
Methods:
- reduce:
- a
- e
- inject:
- a
- e

Style/SingleLineMethods:
Description: Avoid single-line methods.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
Enabled: false
AllowIfMethodIsEmpty: true

Layout/SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space
EnforcedStyleForEmptyBraces: no_space
SupportedStyles:
- space
- no_space

Style/SpecialGlobalVars:
Description: Avoid Perl-style global variables.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
Enabled: false

Style/StringLiterals:
Description: Checks if uses of quotes match the configured preference.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
Enabled: true
EnforcedStyle: double_quotes
SupportedStyles:
- single_quotes
- double_quotes

Style/StringLiteralsInInterpolation:
Description: Checks if uses of quotes inside expressions in interpolated strings
match the configured preference.
Enabled: true
EnforcedStyle: single_quotes
SupportedStyles:
- single_quotes
- double_quotes

Style/TrailingCommaInLiteral:
Description: Checks for trailing comma in parameter lists and literals.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
Enabled: true
EnforcedStyleForMultiline: comma

Style/VariableInterpolation:
Description: Do not interpolate global, instance and class variables directly in
strings.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
Enabled: false

Style/WhenThen:
Description: Use when x then ... for one-line cases.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
Enabled: false

Lint/AssignmentInCondition:
Description: Do not use assignment in conditions.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
Enabled: false
AllowSafeAssignment: true

Lint/EachWithObjectArgument:
Description: Check for immutable argument given to each_with_object.
Enabled: true

Lint/HandleExceptions:
Description: Do not suppress exception.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
Enabled: false

Lint/LiteralInInterpolation:
Description: Checks for literals used in interpolation.
Enabled: false

Metrics/AbcSize:
Description: A calculated magnitude based on number of assignments, branches, and
conditions.
Enabled: false
Max: 15

Metrics/BlockLength:
Exclude:
- spec/**/*.rb

Metrics/ClassLength:
Description: Avoid classes longer than 100 lines of code.
Enabled: false
CountComments: false
Max: 100

Metrics/ModuleLength:
CountComments: false
Max: 100
Description: Avoid modules longer than 100 lines of code.
Enabled: false

Metrics/CyclomaticComplexity:
Description: A complexity metric that is strongly correlated to the number of test
cases needed to validate a method.
Enabled: false
Max: 6

Metrics/MethodLength:
Description: Avoid methods longer than 10 lines of code.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
Enabled: false
CountComments: false
Max: 10

Metrics/ParameterLists:
Description: Avoid parameter lists longer than three or four parameters.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
Enabled: false
Max: 5
CountKeywordArgs: true

Metrics/PerceivedComplexity:
Description: A complexity metric geared towards measuring complexity for a human
reader.
Enabled: false
Max: 7
Exclude:
- spec/**/*.rb
28 changes: 14 additions & 14 deletions Gemfile
@@ -1,25 +1,25 @@
source "https://rubygems.org"
source 'https://rubygems.org'

gemspec

group :development do
gem "guard"
gem "guard-bundler"
gem "guard-inch"
gem "guard-rspec", "~> 4.6"
gem "guard-rubocop"
gem "inch"
gem "rake", "~> 10"
gem "rubocop", "0.52.1"
gem "yard", "~> 0.9.11"
gem 'guard'
gem 'guard-bundler'
gem 'guard-inch'
gem 'guard-rspec', '~> 4.6'
gem 'guard-rubocop'
gem 'inch'
gem 'rake', '~> 10'
gem 'rubocop', '0.52.1'
gem 'yard', '~> 0.9.11'

group :test do
gem "pry"
gem 'pry'
end
end

group :test do
gem "codeclimate-test-reporter", :require => false
gem "rspec", "~> 3.4"
gem "simplecov"
gem 'codeclimate-test-reporter', require: false
gem 'rspec', '~> 3.4'
gem 'simplecov'
end
8 changes: 4 additions & 4 deletions Guardfile
@@ -1,14 +1,14 @@
guard :bundler do
watch("Gemfile")
watch("interactor-contracts.gemspec")
watch('Gemfile')
watch('interactor-contracts.gemspec')
end

guard :inch do
watch(/.+\.rb/)
end

guard :rspec, :cmd => "bundle exec rspec" do
watch("spec/spec_helper.rb") { "spec" }
guard :rspec, cmd: 'bundle exec rspec' do
watch('spec/spec_helper.rb') { 'spec' }

watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
Expand Down
12 changes: 6 additions & 6 deletions Rakefile
@@ -1,17 +1,17 @@
require "bundler"
require 'bundler'
Bundler.setup
Bundler::GemHelper.install_tasks

require "inch/rake"
require 'inch/rake'
Inch::Rake::Suggest.new(:inch)

require "rspec/core/rake_task"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

require "rubocop/rake_task"
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop)

require "yard/rake/yardoc_task"
require 'yard/rake/yardoc_task'
YARD::Rake::YardocTask.new(:yard)

task :default => %i(spec rubocop yard inch)
task default: %i[spec rubocop yard inch]

0 comments on commit a959bbc

Please sign in to comment.