Skip to content

Commit

Permalink
update rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
tadyjp committed Nov 26, 2015
1 parent 285cec4 commit 17a4f42
Show file tree
Hide file tree
Showing 32 changed files with 39 additions and 67 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
@@ -1,3 +1,5 @@
inherit_from: .rubocop_todo.yml

AllCops:

# Rails特有のチェックを実行
Expand Down
25 changes: 25 additions & 0 deletions .rubocop_todo.yml
@@ -0,0 +1,25 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2015-11-27 00:49:42 +0900 using RuboCop version 0.35.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 2
# Configuration parameters: EnforcedStyle, SupportedStyles.
Rails/Date:
Exclude:
- 'app/models/post.rb'
- 'spec/models/post_spec.rb'

# Offense count: 14
# Configuration parameters: EnforcedStyle, SupportedStyles.
Rails/TimeZone:
Exclude:
- 'app/models/notification.rb'
- 'app/models/post.rb'
- 'app/models/user.rb'
- 'spec/factories/users.rb'
- 'spec/features/posts_spec.rb'
- 'spec/models/post_spec.rb'
1 change: 0 additions & 1 deletion Capfile
Expand Up @@ -23,4 +23,3 @@ require 'capistrano/rails/migrations'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

2 changes: 1 addition & 1 deletion app/decorators/tag_decorator.rb
Expand Up @@ -40,7 +40,7 @@ def tree_view_node
html = ''

html += %(
<a href="#{ show_path }" data-name="#{model.name}">
<a href="#{show_path}" data-name="#{model.name}">
#{model.name} <span class="badge">#{model.posts.size}</span>
</a>
)
Expand Down
2 changes: 1 addition & 1 deletion app/models/footprint.rb
Expand Up @@ -16,5 +16,5 @@ class Footprint < ActiveRecord::Base
######################################################################
# Named scope
######################################################################
scope :today, -> { where(arel_table[:created_at].gt 1.days.ago) }
scope :today, -> { where(arel_table[:created_at].gt 1.day.ago) }
end
2 changes: 1 addition & 1 deletion app/models/notification.rb
Expand Up @@ -24,7 +24,7 @@ class Notification < ActiveRecord::Base
end)

scope :recent, (lambda do
where(arel_table[:created_at].gt 7.day.ago)
where(arel_table[:created_at].gt 7.days.ago)
end)

######################################################################
Expand Down
2 changes: 1 addition & 1 deletion app/models/post.rb
Expand Up @@ -86,7 +86,7 @@ class Post < ActiveRecord::Base

scope :today, -> { where(arel_table[:updated_at].gt 1.day.ago) }
scope :this_month, -> { where(arel_table[:updated_at].gt 1.month.ago) }
scope :last_month, -> { where(arel_table[:updated_at].gt 2.month.ago).where(arel_table[:updated_at].lt 1.month.ago) }
scope :last_month, -> { where(arel_table[:updated_at].gt 2.months.ago).where(arel_table[:updated_at].lt 1.month.ago) }

######################################################################
# Class method
Expand Down
6 changes: 3 additions & 3 deletions app/models/s3_uploader.rb
Expand Up @@ -5,9 +5,9 @@ class S3Uploader
# @param [String] region: uploading S3 bucket region.
# @param [String] bucket: uploading backet name.
def initialize(access_key_id: Settings.s3.access_key_id,
secret_access_key: Settings.s3.secret_access_key,
region: 'ap-northeast-1',
bucket:)
secret_access_key: Settings.s3.secret_access_key,
region: 'ap-northeast-1',
bucket:)
@s3 = AWS::S3.new(access_key_id: access_key_id,
secret_access_key: secret_access_key,
region: region)
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Expand Up @@ -74,7 +74,7 @@ def self.find_for_google_oauth2(access_token, _signed_in_resource = nil)
u.name = access_token.info['name']
u.image_url = access_token.info['image']
u.password = Devise.friendly_token[0, 20]
u.nickname = (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle[0..4].join
u.nickname = (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).sample(5).join
end

user.google_auth_token = access_token.credentials['token'] if access_token.credentials['token']
Expand Down
2 changes: 1 addition & 1 deletion config.ru
@@ -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
2 changes: 0 additions & 2 deletions lib/tasks/batch.rake
@@ -1,11 +1,9 @@

namespace :batch do

desc 'Tagに関連するPostのcounter_cacheの再生成'
task reset_counters: :environment do
puts "\t[START] batch:reset_counters"
Tag.all.each { |t| Tag.reset_counters(t.id, :posts) }
puts "\t[FINISH] batch:reset_counters"
end

end
4 changes: 1 addition & 3 deletions lib/tasks/migrations.rake
@@ -1,14 +1,12 @@

namespace :migrations do

desc '001 nicknameを自動付与'
task task_001_user_nickname: :environment do
User.all.each do |user|
next if user.nickname.present?

new_nickname = (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle[0..4].join
new_nickname = (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).sample(5).join
user.update_attributes!(nickname: new_nickname)
end
end

end
2 changes: 0 additions & 2 deletions spec/controllers/apis_controller_spec.rb
@@ -1,7 +1,6 @@
require 'rails_helper'

describe ApisController, type: :controller do

describe "GET 'markdown_preview'" do
it 'returns http redirect' do
get 'markdown_preview'
Expand All @@ -17,5 +16,4 @@
expect(response).to be_success
end
end

end
2 changes: 0 additions & 2 deletions spec/controllers/application_controller_spec.rb
@@ -1,11 +1,9 @@
require 'rails_helper'

describe ApplicationController do

pending '#redirect_unless_signed_in'

pending '#after_sign_in_path_for'

pending '#rescue_from'

end
2 changes: 0 additions & 2 deletions spec/controllers/concerns/rv/mailer_spec.rb
Expand Up @@ -3,7 +3,6 @@
class DummyClass; end

describe RV::Mailer do

let(:klass) { DummyClass.new.extend(RV::Mailer) }
let(:alice) { FactoryGirl.create(:alice) }
let(:post) { Post.create title: 'ruby rspec', body: 'This is first espec test: ruby', author: create(:author) }
Expand All @@ -27,5 +26,4 @@ class DummyClass; end
it 'invalid to' do
expect { klass.compose_mail(post, user: alice, to: 'invalid.email') }.to raise_error
end

end
2 changes: 0 additions & 2 deletions spec/controllers/flow_controller_spec.rb
@@ -1,7 +1,6 @@
require 'rails_helper'

describe FlowController, type: :controller do

describe "GET 'show' without login" do
it 'returns http redirect' do
get 'show'
Expand All @@ -17,5 +16,4 @@
expect(response).to be_success
end
end

end
3 changes: 0 additions & 3 deletions spec/controllers/posts_controller_spec.rb
@@ -1,7 +1,6 @@
require 'rails_helper'

describe PostsController, type: :controller do

let(:post) { FactoryGirl.create(:post) }

describe "GET 'show' without login" do
Expand All @@ -12,7 +11,6 @@
end

describe "GET 'show' with login" do

let(:alice) { FactoryGirl.create(:alice) }

it 'returns http success' do
Expand All @@ -29,5 +27,4 @@
expect(Footprint.where(user_id: alice.id, post_id: post.id)).to exist
end
end

end
2 changes: 0 additions & 2 deletions spec/controllers/search_controller_spec.rb
@@ -1,7 +1,6 @@
require 'rails_helper'

describe SearchController, type: :controller do

describe "GET 'show' without login" do
it 'returns http redirect' do
get 'show'
Expand All @@ -17,5 +16,4 @@
expect(response).to be_success
end
end

end
2 changes: 0 additions & 2 deletions spec/controllers/stock_controller_spec.rb
@@ -1,7 +1,6 @@
require 'rails_helper'

describe StockController, type: :controller do

describe "GET 'show' without login" do
it 'returns http redirect' do
get 'show'
Expand All @@ -17,5 +16,4 @@
expect(response).to be_success
end
end

end
2 changes: 0 additions & 2 deletions spec/controllers/tags_controller_spec.rb
@@ -1,7 +1,6 @@
require 'rails_helper'

describe TagsController, type: :controller do

let(:tag) { FactoryGirl.create(:tag_ruby) }

describe "GET 'show' without login" do
Expand All @@ -19,5 +18,4 @@
expect(response).to be_success
end
end

end
2 changes: 0 additions & 2 deletions spec/controllers/templates_controller_spec.rb
@@ -1,7 +1,6 @@
require 'rails_helper'

RSpec.describe TemplatesController, type: :controller do

describe "GET 'show' without template" do
it 'returns http success' do
sign_in FactoryGirl.create(:alice)
Expand All @@ -19,5 +18,4 @@
expect(response).to be_success
end
end

end
2 changes: 0 additions & 2 deletions spec/controllers/users_controller_spec.rb
@@ -1,7 +1,6 @@
require 'rails_helper'

describe UsersController, type: :controller do

describe "GET 'edit'" do
it 'returns http success' do
sign_in FactoryGirl.create(:alice)
Expand All @@ -19,5 +18,4 @@
expect(response).to redirect_to('/user/edit')
end
end

end
2 changes: 0 additions & 2 deletions spec/controllers/watchings_controller_spec.rb
@@ -1,7 +1,6 @@
require 'rails_helper'

RSpec.describe WatchingsController, type: :controller do

describe "GET 'show' without login" do
it 'returns http redirect' do
get 'show'
Expand All @@ -17,5 +16,4 @@
expect(response).to be_success
end
end

end
5 changes: 0 additions & 5 deletions spec/controllers/welcome_controller_spec.rb
@@ -1,7 +1,6 @@
require 'rails_helper'

describe WelcomeController, type: :controller do

describe "GET 'top'" do
it 'should be successful' do
get :top
Expand All @@ -11,11 +10,9 @@
end

describe 'Login' do

let(:user) { FactoryGirl.create(:alice) }

describe "GET 'top'" do

it 'should be successful' do
sign_in FactoryGirl.create(:alice)

Expand All @@ -30,8 +27,6 @@
get :top
expect(assigns(:current_user)).to eq(user)
end

end
end

end
1 change: 0 additions & 1 deletion spec/factories/posts.rb
Expand Up @@ -15,7 +15,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl

FactoryGirl.define do

factory :post do
association :author, factory: :author
title 'sample title'
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/users.rb
Expand Up @@ -45,7 +45,7 @@
email 'author@mail.com'
nickname 'author'
password Devise.friendly_token[0, 20]
google_token_expires_at Time.now - 30.hour
google_token_expires_at Time.now - 30.hours
end

factory :login_user_1, class: User do
Expand Down
2 changes: 0 additions & 2 deletions spec/features/posts_spec.rb
Expand Up @@ -4,7 +4,6 @@
Warden.test_mode!

describe 'Request via js', js: true do

let(:user) { FactoryGirl.create(:login_user_1) }

before do
Expand All @@ -27,5 +26,4 @@
page.driver.reset!
Warden.test_reset!
end

end
1 change: 0 additions & 1 deletion spec/models/notification_spec.rb
Expand Up @@ -16,7 +16,6 @@

describe Notification do
describe 'Instance method' do

before :each do
@alice = create(:alice)
@bob = create(:bob)
Expand Down
3 changes: 0 additions & 3 deletions spec/models/post_spec.rb
Expand Up @@ -16,7 +16,6 @@
require 'date'

describe Post do

describe 'Instance method' do
before :each do
@post = create(:post)
Expand All @@ -26,7 +25,6 @@
end

describe 'Fork' do

it 'duplicated' do
expect(@new_post.id).not_to eq(@post.id)
end
Expand All @@ -50,7 +48,6 @@
it 'valid specified_date' do
expect(@new_post.specified_date).to eq(Date.today)
end

end
end

Expand Down

0 comments on commit 17a4f42

Please sign in to comment.