Skip to content

Commit

Permalink
rubocop style adopted
Browse files Browse the repository at this point in the history
  • Loading branch information
mradeybee committed Dec 9, 2015
1 parent b4c9778 commit f1f71a7
Show file tree
Hide file tree
Showing 31 changed files with 381 additions and 2,420 deletions.
235 changes: 235 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
AllCops:
Exclude:
- "vendor/**/*"
- "db/schema.rb"
- "bin/*"
- "config/environments/*"
UseCache: 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
reduce: inject
Style/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/FileName:
Description: Use snake_case for source file names.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
Enabled: false
Exclude: []
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/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
MaxLineLength: 80
Style/OptionHash:
Description: Don't 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/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: false
EnforcedStyle: exploded
SupportedStyles:
- compact
- exploded
Style/SignalException:
Description: Checks for proper usage of fail and raise.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
Enabled: false
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
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/TrailingComma:
Description: Checks for trailing comma in parameter lists and literals.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
Enabled: false
EnforcedStyleForMultiline: no_comma
SupportedStyles:
- comma
- no_comma
Metrics/AbcSize:
Description: A calculated magnitude based on number of assignments, branches, and
conditions.
Enabled: false
Max: 15
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
Lint/AssignmentInCondition:
Description: Don't use assignment in conditions.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
Enabled: false
AllowSafeAssignment: true
Style/InlineComment:
Description: Avoid inline comments.
Enabled: false
Style/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/Documentation:
Description: Document classes and non-namespace modules.
Enabled: false
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
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/PerlBackrefs:
Description: Avoid Perl-style regex back references.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
Enabled: false
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/SpecialGlobalVars:
Description: Avoid Perl-style global variables.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
Enabled: false
Style/VariableInterpolation:
Description: Don't 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/EachWithObjectArgument:
Description: Check for immutable argument given to each_with_object.
Enabled: true
Lint/HandleExceptions:
Description: Don't suppress exception.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
Enabled: false
Lint/LiteralInCondition:
Description: Checks of literals used in conditions.
Enabled: false
Lint/LiteralInInterpolation:
Description: Checks for literals used in interpolation.
Enabled: false
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ruby "2.2.3"
gem "rails", "4.2.4"

gem "rails-api"
gem 'coveralls', require: false
gem "coveralls", require: false
gem "spring", group: :development
gem "sqlite3"
gem "responders", "~> 2.0"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Bucketlist

[![Code Climate](https://codeclimate.com/github/andela-aadepoju/Bucketlist/badges/gpa.svg)](https://codeclimate.com/github/andela-aadepoju/Bucketlist) [![Test Coverage](https://codeclimate.com/github/andela-aadepoju/Bucketlist/badges/coverage.svg)](https://codeclimate.com/github/andela-aadepoju/Bucketlist/coverage) [![Issue Count](https://codeclimate.com/github/andela-aadepoju/Bucketlist/badges/issue_count.svg)](https://codeclimate.com/github/andela-aadepoju/Bucketlist)[![Coverage Status](https://coveralls.io/repos/andela-aadepoju/Bucketlist/badge.svg?branch=tests&service=github)](https://coveralls.io/github/andela-aadepoju/Bucketlist?branch=tests)
[![Code Climate](https://codeclimate.com/github/andela-aadepoju/Bucketlist/badges/gpa.svg)](https://codeclimate.com/github/andela-aadepoju/Bucketlist) [![Test Coverage](https://codeclimate.com/github/andela-aadepoju/Bucketlist/badges/coverage.svg)](https://codeclimate.com/github/andela-aadepoju/Bucketlist/coverage) [![Issue Count](https://codeclimate.com/github/andela-aadepoju/Bucketlist/badges/issue_count.svg)](https://codeclimate.com/github/andela-aadepoju/Bucketlist) [![Coverage Status](https://coveralls.io/repos/andela-aadepoju/Bucketlist/badge.svg?branch=tests&service=github)](https://coveralls.io/github/andela-aadepoju/Bucketlist?branch=tests)
5 changes: 3 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 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.
# for example lib/tasks/capistrano.rake,
# and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require File.expand_path("../config/application", __FILE__)

Rails.application.load_tasks
4 changes: 1 addition & 3 deletions app/controllers/v1/bucketlists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def create
end

def update
@bucketlist = Bucketlist.find(params[:id])
@bucketlist = Bucketlist.find(params[:id])
if @bucketlist.update(bucketlist_params)
render json: @bucketlist, status: 202
else
Expand All @@ -40,7 +40,5 @@ def update
def bucketlist_params
params.permit(:id, :name, :publicity)
end


end
end
23 changes: 2 additions & 21 deletions app/controllers/v1/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,20 @@ module V1
class UsersController < ApplicationController
before_action :authenticate, except: :create

def index
@user = User.all
render json: @user
end

def show
@user = User.find(params[:id])
render json: @user
end

def new
@user = User.new(user_params) if user_params
render json: @user
end

def edit
end

def create
@user = User.create(user_params) if user_params
render json: @user, status: :created
end

def update
user = User.find(params[:id])
user = User.find(params[:id])
if user.update(user_params)
render json: user, status: 202
else
format.json { render :show, status: :ok, location: @booking }
render json: { Error: "Update not successfull" }, status: 400
end
end


private

def user_params
Expand Down
2 changes: 1 addition & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
require ::File.expand_path("../config/environment", __FILE__)
run Rails.application
23 changes: 14 additions & 9 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
require File.expand_path('../boot', __FILE__)
require File.expand_path("../boot", __FILE__)

require 'rails/all'
require "rails/all"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
# you"ve limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module BucketList
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Settings in config/environments/*
# take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# Set Time.zone default to the specified zone and make
# Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time
# zone names. Default is UTC.
# config.time_zone = "Central Time (US & Canada)"

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# The default locale is :en and all translations from
# config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join
# ("my", "locales", "*.{rb,yml}").to_s]
# config.i18n.default_locale = :de

# Do not swallow errors in after_commit/after_rollback callbacks.
Expand Down
4 changes: 2 additions & 2 deletions config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
require "bundler/setup" # Set up gems listed in the Gemfile.
2 changes: 1 addition & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Load the Rails application.
require File.expand_path('../application', __FILE__)
require File.expand_path("../application", __FILE__)
code = "0aefa8b9e07212c7010d484ab1e0ddd7df74ff120e896f9ae0ae56c327cf6dcf"
CODECLIMATE_REPO_TOKEN = code
# Initialize the Rails application.
Expand Down
12 changes: 7 additions & 5 deletions config/initializers/secret_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
# If you change this key, all old signed cookies will become invalid!

# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# no regular words or you"ll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.

# Make sure your secret_key_base is kept private
# if you're sharing your code publicly.
# if you"re sharing your code publicly.

# Although this is not needed for an api-only application, rails4
# requires secret_key_base or secret_token to be defined, otherwise an
# Although this is not needed for an api-only application, rails4
# requires secret_key_base or secret_token to be defined, otherwise an
# error is raised.
# Using secret_token for rails3 compatibility. Change to secret_key_base
# to avoid deprecation warning.
# Can be safely removed in a rails3 api-only application.
BucketList::Application.config.secret_token = 'e40a05f59b6133f17cf566f821123d49b1c35dbb966b612e5ef2e717915eba505658565bb5004dd8e3326063eefa1f410ca8431695b14cb9673e9bec2e5a929a'
BucketList::Application.config.secret_token = "e40a05f59b6133f17cf566f821123d49b
1c35dbb966b612e5ef2e717915eba505658565bb5004dd8e3326063eefa1f410ca8431695b14cb96
73e9bec2e5a929a"
Loading

0 comments on commit f1f71a7

Please sign in to comment.