diff --git a/.rubocop.yml b/.rubocop.yml index 615260c..54a157d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ Rails: # Commonly used screens these days easily fit more than 80 characters. Metrics/LineLength: - Max: 120 + Max: 140 # Too short methods lead to extraction of single-use methods, which can make # the code easier to read (by naming things), but can also clutter the class @@ -14,9 +14,12 @@ Metrics/MethodLength: Metrics/ClassLength: Max: 1500 +Rails/FilePath: + Enabled: false + # No space makes the method definition shorter and differentiates # from a regular assignment. -Style/SpaceAroundEqualsInParameterDefault: +Layout/SpaceAroundEqualsInParameterDefault: EnforcedStyle: no_space # Single quotes being faster is hardly measurable and only affects parse time. @@ -30,8 +33,17 @@ Style/StringLiterals: Style/SymbolArray: Enabled: true +Style/MixinUsage: + Enabled: false + +Style/ClassAndModuleChildren: + Enabled: false + +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + # Most readable form. -Style/AlignHash: +Layout/AlignHash: EnforcedHashRocketStyle: table EnforcedColonStyle: table @@ -67,7 +79,7 @@ Style/RaiseArgs: # Indenting the chained dots beneath each other is not supported by this cop, # see https://github.com/bbatsov/rubocop/issues/1633 -Style/MultilineOperationIndentation: +Layout/MultilineOperationIndentation: Enabled: false # Fail is an alias of raise. Avoid aliases, it's more cognitive load for no gain. @@ -82,17 +94,12 @@ Style/SignalException: Lint/HandleExceptions: Enabled: false -Style/SpaceInsideBlockBraces: +Layout/SpaceInsideBlockBraces: # The space here provides no real gain in readability while consuming # horizontal space that could be used for a better parameter name. # Also {| differentiates better from a hash than { | does. SpaceBeforeBlockParameters: false -# No trailing space differentiates better from the block: -# foo} means hash, foo } means block. -Style/SpaceInsideHashLiteralBraces: - EnforcedStyle: no_space - # { ... } for multi-line blocks is okay, follow Weirichs rule instead: # https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc Style/BlockDelimiters: diff --git a/Gemfile b/Gemfile index 35982d8..2f350d0 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,8 @@ gem "puma", "~> 3.0" # Rack Middleware for handling Cross-Origin Resource Sharing (CORS), which makes cross-origin AJAX possible gem "rack-cors" -# Bootsnap is a library that plugs into Ruby, with optional support for ActiveSupport and YAML, to optimize and cache expensive computations. +# Bootsnap is a library that plugs into Ruby, with optional support +# for ActiveSupport and YAML, to optimize and cache expensive computations. gem "bootsnap", require: false # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder diff --git a/app/controllers/api/v1/concerns/error_handler.rb b/app/controllers/api/v1/concerns/error_handler.rb index ba83fcb..1eb0c1b 100644 --- a/app/controllers/api/v1/concerns/error_handler.rb +++ b/app/controllers/api/v1/concerns/error_handler.rb @@ -11,11 +11,11 @@ module ErrorHandler end def render_error(status, model) - render json: {success: false, error: ErrorSerializer.serialize(model.errors)}, status: status + render json: { success: false, error: ErrorSerializer.serialize(model.errors) }, status: status end def not_found - render json: {success: false, error: "Not found"}, status: :not_found + render json: { success: false, error: "Not found" }, status: :not_found end end end diff --git a/config/application.rb b/config/application.rb index 9577a85..7d8787a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -32,7 +32,8 @@ class Application < Rails::Application config.middleware.insert_before 0, Rack::Cors do allow do origins "*" - resource "*", headers: :any, expose: ["access-token", "expiry", "token-type", "uid", "client"], methods: %i[get post delete put options] + resource "*", headers: :any, expose: ["access-token", "expiry", "token-type", "uid", "client"], + methods: %i[get post delete put options] end end diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb index 38aaf64..0880b58 100644 --- a/config/initializers/new_framework_defaults.rb +++ b/config/initializers/new_framework_defaults.rb @@ -19,4 +19,4 @@ ActiveSupport.halt_callback_chains_on_return_false = false # Configure SSL options to enable HSTS with subdomains. Previous versions had false. -Rails.application.config.ssl_options = {hsts: {subdomains: true}} +Rails.application.config.ssl_options = { hsts: { subdomains: true } } diff --git a/config/routes.rb b/config/routes.rb index 5ac6ad7..59b6437 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,7 +8,7 @@ root "home#index" # API endpoints - scope "/api", module: :api, defaults: {format: :json}, constraints: AuthConstraint.new(token: "OllBS57MeAW041dgR7xolpZaiO87kjnMVVK3qrtgtTbcBolB7K3TugZBuM6") do + scope "/api", module: :api, defaults: { format: :json }, constraints: AuthConstraint.new(token: "OllBS57MeAW041dgR7xolpZaiO87") do # Version 1 of API scope "/v1", module: :v1 do # resources :news diff --git a/scripts/run-rubocop.bash b/scripts/run-rubocop.bash index fc6f04d..311cf9f 100755 --- a/scripts/run-rubocop.bash +++ b/scripts/run-rubocop.bash @@ -4,5 +4,8 @@ set -e cd "${0%/*}/.." -echo "Running rubocop" +echo "Running rubocop - fix" bundle exec rubocop -a + +echo "Running rubocop" +bundle exec rubocop