Skip to content

Commit 64609b0

Browse files
authored
Merge pull request #73 from yochiyochirb/as-you-wish-rubocop
Rubocopの警告を潰した
2 parents f488f96 + 8e244d2 commit 64609b0

17 files changed

Lines changed: 87 additions & 163 deletions

.rubocop_todo.yml

Lines changed: 2 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,28 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2016-08-29 13:11:03 +0900 using RuboCop version 0.42.0.
3+
# on 2016-08-30 16:55:44 +0900 using RuboCop version 0.42.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 2
10-
# Configuration parameters: AllowSafeAssignment.
11-
Lint/AssignmentInCondition:
12-
Exclude:
13-
- 'app/channels/application_cable/connection.rb'
14-
- 'app/helpers/emoji_helper.rb'
15-
16-
# Offense count: 3
17-
Lint/UselessAssignment:
18-
Exclude:
19-
- 'app/helpers/auto_link_helper.rb'
20-
21-
# Offense count: 1
22-
Metrics/AbcSize:
23-
Max: 17
24-
25-
# Offense count: 2
26-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
27-
# URISchemes: http, https
28-
Metrics/LineLength:
29-
Max: 278
30-
319
# Offense count: 1
3210
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
3311
Style/FileName:
3412
Exclude:
3513
- 'config/initializers/slack-ruby-client.rb'
3614

37-
# Offense count: 3
38-
# Cop supports --auto-correct.
39-
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
40-
# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
41-
Style/HashSyntax:
42-
Exclude:
43-
- 'db/migrate/20160414062322_sorcery_core.rb'
44-
- 'db/migrate/20160414062855_sorcery_external.rb'
45-
46-
# Offense count: 2
47-
# Cop supports --auto-correct.
48-
# Configuration parameters: SupportedStyles, IndentationWidth.
49-
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
50-
Style/IndentArray:
51-
EnforcedStyle: consistent
52-
53-
# Offense count: 5
54-
# Cop supports --auto-correct.
55-
# Configuration parameters: Width.
56-
Style/IndentationWidth:
57-
Exclude:
58-
- 'app/channels/application_cable/connection.rb'
59-
- 'app/controllers/application_controller.rb'
60-
- 'app/controllers/posts_controller.rb'
61-
- 'app/jobs/post_preview_job.rb'
62-
- 'db/migrate/20160827120217_create_versions.rb'
63-
64-
# Offense count: 2
65-
# Cop supports --auto-correct.
66-
Style/RedundantSelf:
67-
Exclude:
68-
- 'app/models/post.rb'
69-
70-
# Offense count: 3
71-
# Cop supports --auto-correct.
72-
# Configuration parameters: AllowForAlignment.
73-
Style/SpaceAroundOperators:
74-
Exclude:
75-
- 'app/helpers/auto_link_helper.rb'
76-
7715
# Offense count: 4
7816
# Cop supports --auto-correct.
7917
Style/SpaceInsideBrackets:
8018
Exclude:
8119
- 'config/environments/production.rb'
8220

83-
# Offense count: 6
84-
# Cop supports --auto-correct.
85-
Style/SpaceInsidePercentLiteralDelimiters:
86-
Exclude:
87-
- 'app/controllers/posts_controller.rb'
88-
- 'config/initializers/assets.rb'
89-
- 'config/routes.rb'
90-
91-
# Offense count: 10
21+
# Offense count: 7
9222
# Cop supports --auto-correct.
9323
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
9424
# SupportedStyles: single_quotes, double_quotes
9525
Style/StringLiterals:
9626
Exclude:
9727
- 'config/environments/production.rb'
9828
- 'config/puma.rb'
99-
- 'db/migrate/20160827120217_create_versions.rb'
100-
101-
# Offense count: 2
102-
# Cop supports --auto-correct.
103-
# Configuration parameters: EnforcedStyle, SupportedStyles.
104-
# SupportedStyles: final_newline, final_blank_line
105-
Style/TrailingBlankLines:
106-
Exclude:
107-
- 'app/helpers/markdown_helper.rb'
108-
- 'db/migrate/20160414062322_sorcery_core.rb'

app/channels/application_cable/connection.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ def connect
88

99
protected
1010

11-
def find_verified_user
12-
if current_user = User.find_by(id: cookies.signed[:user_id])
13-
current_user
14-
else
15-
reject_unauthorized_connection
11+
def find_verified_user
12+
if (current_user = User.find_by(id: cookies.signed[:user_id]))
13+
current_user
14+
else
15+
reject_unauthorized_connection
16+
end
1617
end
17-
end
1818
end
1919
end

app/channels/post_channel.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Be sure to restart your server when you modify this file. Action Cable runs in a loop that does not support auto reloading.
21
class PostChannel < ApplicationCable::Channel
32
def subscribed
43
@post_channel_id = SecureRandom.hex

app/controllers/application_controller.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ class ApplicationController < ActionController::Base
88

99
private
1010

11-
def current_user
12-
@current_user ||= User.find(session["user_id"]) if session[:user_id]
13-
end
11+
def current_user
12+
@current_user ||= User.find(session["user_id"]) if session[:user_id]
13+
end
1414

15-
def logged_in?
16-
current_user ? true : false
17-
end
15+
def logged_in?
16+
current_user ? true : false
17+
end
1818

19-
def require_login
20-
redirect_to login_path, alert: "Please login" unless logged_in?
21-
end
19+
def require_login
20+
redirect_to login_path, alert: "Please login" unless logged_in?
21+
end
2222
end

app/controllers/posts_controller.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class PostsController < ApplicationController
2-
before_action :set_post, only: %i( show edit update destroy )
2+
before_action :set_post, only: %i(show edit update destroy)
33

44
def index
55
@posts = Post.all.order(updated_at: :desc)
@@ -40,11 +40,11 @@ def destroy
4040

4141
private
4242

43-
def set_post
44-
@post = Post.find(params[:id])
45-
end
43+
def set_post
44+
@post = Post.find(params[:id])
45+
end
4646

47-
def post_params
48-
params.require(:post).permit(:title, :body)
49-
end
47+
def post_params
48+
params.require(:post).permit(:title, :body)
49+
end
5050
end

app/controllers/sessions_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def create
1717

1818
# Use cookies for ActionCable authorization
1919
cookies.signed[:user_id] = session[:user_id] = user.id
20-
redirect_to root_url, notice: "Logged in with #{auth['provider'].titleize}"
20+
redirect_to root_url, notice: "Logged in with Slack"
2121
end
2222

2323
def destroy

app/helpers/auto_link_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module AutoLinkHelper
22
def auto_link(source)
3-
Rinku.auto_link(source, mode=:urls, link_attr=nil, skip_tags=nil)
3+
Rinku.auto_link(source, :urls, nil, nil)
44
end
55
end

app/helpers/emoji_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module EmojiHelper
22
def emojify(content)
33
return "" if content.blank?
44
content.gsub(/:([\w+-]+):/) do |match|
5-
if emoji = Emoji.find_by_alias(Regexp.last_match[1])
5+
if (emoji = Emoji.find_by_alias(Regexp.last_match[1]))
66
%(<img alt="#{Regexp.last_match[1]}" ) \
77
+ %(src="#{image_path("emoji/#{emoji.image_filename}")}" ) \
88
+ %(style="vertical-align:middle" width="20" height="20" />)

app/helpers/markdown_helper.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ def markdown_to_html(source)
44
Kramdown::Document.new(source, input: "GFM", syntax_highlighter: "rouge").to_html
55
end
66
end
7-

app/jobs/post_preview_job.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ def perform(channel_id:, source:)
88

99
private
1010

11-
def render_preview(source)
12-
ApplicationController.renderer.render partial: "posts/preview",
13-
locals: {
14-
title: source["title"],
15-
body: source["body"]
16-
}
17-
end
11+
def render_preview(source)
12+
ApplicationController.renderer.render partial: "posts/preview",
13+
locals: {
14+
title: source["title"],
15+
body: source["body"]
16+
}
17+
end
1818
end

0 commit comments

Comments
 (0)