Skip to content

Commit

Permalink
fix: code format
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrNikolas committed Jun 16, 2020
1 parent 16f852f commit 26ff4c5
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 17 deletions.
27 changes: 17 additions & 10 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v1/concerns/error_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion config/initializers/new_framework_defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion scripts/run-rubocop.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 26ff4c5

Please sign in to comment.