Skip to content

Commit

Permalink
cleaned up rubocop.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
briri committed Jul 13, 2020
1 parent b043a29 commit 6fa3f7f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 75 deletions.
98 changes: 41 additions & 57 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,6 @@ AllCops:
# Show the name of the cops being voilated in the feedback
DisplayCopNames: true
DisplayStyleGuide: true
# We're using Ruby 2.6 right now. So force that version or higher.
TargetRubyVersion: 2.6
# Don't check these files. So many of them are boilerplate code with violations.
Exclude:
- 'bin/*'
- 'lib/tasks/**/*'
- 'Gemfile'
- 'db/**/*'
# - 'config/**/*'
- 'script/**/*'
- '**/Rakefile'
- '**/config.ru'

# Ignore this cop. The Rubocop default is sensible, but the rubocop-rails gem modifies
# this to position end keywords awkwardly.
Layout/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: keyword

# Force no empty lines at the start or end of a block's body. Ignore specs, since this
# improves readability within the RSpec blocks.
Expand All @@ -41,10 +23,11 @@ Layout/EmptyLinesAroundModuleBody:
Enabled: true
EnforcedStyle: empty_lines

Layout/IndentationWidth:
Description: 'Use 2 spaces for indentation.'
StyleGuide: '#spaces-indentation'
# Ignore this cop. The Rubocop default is sensible, but the rubocop-rails gem modifies
# this to position end keywords awkwardly.
Layout/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: keyword

# The difference between `rails` and `normal` is that the `rails` style
# prescribes that in classes and modules the `protected` and `private`
Expand All @@ -58,11 +41,10 @@ Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: normal

# Enforce this in the main code but ignore it in specs since the Rspec core methods
# are defined as potentially ambiguous blocks
Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/**/*'
Layout/IndentationWidth:
Description: 'Use 2 spaces for indentation.'
StyleGuide: '#spaces-indentation'
Enabled: true

# Restrict the length of each line of code to 90 characters. Enforcing this is important
# as many developers are working on smaller screens, or split screens. Having to scroll
Expand All @@ -71,48 +53,39 @@ Layout/LineLength:
# I've found that 90 is a suitable limit. Many developers balk at the 80 character
# default.
Max: 100
Exclude:
# Excludes the spec helper, since this boilerplate file has comments that are much
# longer.
- 'spec/spec_helper.rb'

# Bumping the default ClassLength so we don't need to refactor everything
Metrics/ClassLength:
Max: 300
# Enforce this in the main code but ignore it in specs since the Rspec core methods
# are defined as potentially ambiguous blocks
Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/**/*'

# Bumping the default AbcSize so we don't need to refactor everything
Metrics/AbcSize:
Max: 25

# Bumping the default CyclomaticComplexity so we don't need to refactor everything
Metrics/CyclomaticComplexity:
Max: 25

# Bumping the default PerceivedComplexity so we don't need to refactor everything
Metrics/PerceivedComplexity:
Max: 25

# Restrict the number of lines of code that may be within a block of code. This should
# force developers to break their code into smaller discrete methods or objects.
Metrics/BlockLength:
# Exclude specs, since those are defined as large blocks of code
Exclude:
- 'spec/**/*'

# Bumping the default ClassLength so we don't need to refactor everything
Metrics/ClassLength:
Max: 300

# Bumping the default CyclomaticComplexity so we don't need to refactor everything
Metrics/CyclomaticComplexity:
Max: 25

# Bumping the default MethodLength so we don't need to refactor everything
Metrics/MethodLength:
Max: 25

# Leave the string formatting style as `"some text %{value}" % { value: "text" }`
# since we're uncertain what effect `format` and `sprintf` may have on the Fastgetext
# markup `_("text")`
Style/FormatString:
EnforcedStyle: percent

# Prefer the use of `"some %{token} text"` instead of `some %<token> text` or
# `some %token text` since it would invalidate many of our translation strings
Style/FormatStringToken:
EnforcedStyle: template
# Bumping the default PerceivedComplexity so we don't need to refactor everything
Metrics/PerceivedComplexity:
Max: 25

# This cop enforces the use of boolean and/or "&&" and "||" over "and" "or".
# Sometimes using "and"/"or" is preferrable, when these are used as control flow.
Expand All @@ -136,14 +109,25 @@ Style/ClassAndModuleChildren:
Style/Documentation:
Enabled: false

# Enforce double quotes. Don't allow single quotes. This is preferred since double
# quotes are more useful (they support escaping characters, and interpolation).
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes

# Enforce empty methods to be written across two lines, like any normal method would be.
# This allows for easy modification of the method in future.
Style/EmptyMethod:
Enabled: true
EnforcedStyle: expanded

# Leave the string formatting style as `"some text %{value}" % { value: "text" }`
# since we're uncertain what effect `format` and `sprintf` may have on the Fastgetext
# markup `_("text")`
Style/FormatString:
EnforcedStyle: percent

# Prefer the use of `"some %{token} text"` instead of `some %<token> text` or
# `some %token text` since it would invalidate many of our translation strings
Style/FormatStringToken:
EnforcedStyle: template

# Enforce double quotes. Don't allow single quotes. This is preferred since double
# quotes are more useful (they support escaping characters, and interpolation).
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
34 changes: 18 additions & 16 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ gem "jbuilder"
# gem "image_processing", "~> 1.2"

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', require: false
gem "bootsnap", require: false

# GEMS ADDED TO HELP HANDLE RAILS MIGRATION FROM 3.x to 4.2
# THESE GEMS HELP SUPPORT DEPRACATED FUNCTIONALITY AND WILL LOSE SUPPORT IN
# FUTURE VERSIONS WE SHOULD CONSIDER BRINGING THE CODE UP TO DATE INSTEAD

# A set of Rails responders to dry up your application
# (http://github.com/plataformatec/responders)
#gem "responders"
# gem "responders"

# ============== #
# ERROR HANDLING #
Expand All @@ -69,7 +69,7 @@ gem "mysql2", group: :mysql, require: false
gem "pg", group: :pgsql, require: false

# Bit fields for ActiveRecord (https://github.com/pboling/flag_shih_tzu)
gem "flag_shih_tzu" #, "~> 0.3.23"
gem "flag_shih_tzu" # , "~> 0.3.23"

# ======== #
# SECURITY #
Expand Down Expand Up @@ -101,7 +101,7 @@ gem "omniauth-orcid"
gem "omniauth-rails_csrf_protection"

# A ruby implementation of the RFC 7519 OAuth JSON Web Token (JWT) standard.
gem 'jwt'
gem "jwt"

# Gems for repository integration
# OO authorization for Rails (https://github.com/elabs/pundit)
Expand Down Expand Up @@ -152,18 +152,18 @@ gem "api-pagination"
gem "sassc-rails"

# Font-Awesome SASS (https://github.com/FortAwesome/font-awesome-sass)
gem 'font-awesome-sass', '~> 5.13.0'
gem "font-awesome-sass", "~> 5.13.0"

# Use webpack to manage app-like JavaScript modules in Rails
# (https://github.com/rails/webpacker)
#gem "webpacker"
# gem "webpacker"

# Parse CSS and add vendor prefixes to CSS rules using values from the Can
# I Use website. (https://github.com/ai/autoprefixer-rails)
gem "autoprefixer-rails"

# Minimal embedded v8 for Ruby (https://github.com/discourse/mini_racer)
#gem "mini_racer"
# gem "mini_racer"

# ========= #
# EXPORTING #
Expand All @@ -182,8 +182,9 @@ gem "wicked_pdf"
# (http://github.com/karnov/htmltoword)
gem "htmltoword"

# Filename sanitization for Ruby. This is useful when you generate filenames for downloads from user input
gem 'zaru'
# Filename sanitization for Ruby. This is useful when you generate filenames for
# downloads from user input
gem "zaru"

# ==================== #
# INTERNATIONALIZATION #
Expand All @@ -208,10 +209,10 @@ gem "gettext", require: false, group: :development
# Run any code in parallel Processes(> use all CPUs) or Threads(> speedup
# blocking operations). Best suited for map-reduce or e.g. parallel downloads/uploads.
# TODO: Replace use of this with ActiveJob where possible
gem 'parallel'
gem "parallel"

# Makes http fun again! Wrapper to simplify the native Net::HTTP libraries
gem 'httparty'
gem "httparty"

# Autoload dotenv in Rails. (https://github.com/bkeepers/dotenv)
gem "dotenv-rails"
Expand All @@ -222,7 +223,7 @@ gem "dotenv-rails"

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem "byebug", platforms: %i[mri mingw x64_mingw]
end

group :test do
Expand Down Expand Up @@ -285,11 +286,11 @@ group :test do
gem "rspec-collection_matchers"

# A set of RSpec matchers for testing Pundit authorisation policies.
gem 'pundit-matchers'
gem "pundit-matchers"

# This gem brings back assigns to your controller tests as well as assert_template
# to both controller and integration tests.
gem 'rails-controller-testing'
gem "rails-controller-testing"
end

group :ci, :development do
Expand All @@ -310,9 +311,10 @@ end

group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem "web-console"
gem "listen"
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem "web-console"
# Spring speeds up development by keeping your application running in the background.
# Read more: https://github.com/rails/spring
gem "spring"
gem "spring-watcher-listen"

Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env rake
# frozen_string_literal: true

# 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 'rake/testtask'
Expand All @@ -8,7 +10,7 @@

# task default: :test

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

DMPRoadmap::Application.load_tasks

Expand Down
4 changes: 3 additions & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# frozen_string_literal: true

# This file is used by Rack-based servers to start the application.
require File.expand_path(File.dirname(__FILE__) + '/config/environment')
require File.expand_path(File.dirname(__FILE__) + "/config/environment")

run DMPRoadmap::Application

0 comments on commit 6fa3f7f

Please sign in to comment.