Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: 💄 さらに $ bundle exec rubocop -A . を実行した #512

Merged
merged 1 commit into from
Oct 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# inherit_from: .rubocop_todo.yml

require:
- rubocop-rails

AllCops:
NewCops: enable
DisplayCopNames: true
Exclude:
- 'vendor/**/*'
- 'node_modules/**/*'
- 'spec/**/*'
- 'db/schema.rb'
- 'db/**/*'
- 'config/**/*'
- 'Guardfile'
- 'bin/**/*'
- 'tmp/**/*'

Style/Documentation:
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false

Style/StringLiterals:
EnforcedStyle: single_quotes

Style/StringLiteralsInInterpolation:
EnforcedStyle: single_quotes

Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: comma

Metrics/BlockLength:
Max: 52

Metrics/ClassLength:
Max: 500

Metrics/CyclomaticComplexity:
Max: 16

Metrics/MethodLength:
Max: 65

Metrics/PerceivedComplexity:
Max: 17

Metrics/ModuleLength:
Max: 160
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
if Rails.env == 'YOUR_ENVIRONMENT'
if Rails.env.YOUR_ENVIRONMENT?
USERNAME = Rails.application.credentials.digest_auth[:username].freeze
PASSWORD = Rails.application.credentials.digest_auth[:password].freeze

Expand Down
8 changes: 4 additions & 4 deletions app/lib/operate_spreadsheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def self.session
client_secret: Rails.application.credentials.spreadsheet_api[:client_secret],
scope: [
'https://www.googleapis.com/auth/drive',
'https://spreadsheets.google.com/feeds/'
'https://spreadsheets.google.com/feeds/',
],
refresh_token: Rails.application.credentials.spreadsheet_api[:refresh_token]
)
Expand All @@ -31,7 +31,7 @@ def self.master_data
is_retweet: 0
}
tweeted_at_validation = {
tweeted_at: '2018-06-22 21:00:00'.in_time_zone('Tokyo')..'2018-06-24 09:59:59'.in_time_zone('Tokyo')
tweeted_at: ('2018-06-22 21:00:00'.in_time_zone('Tokyo'))..('2018-06-24 09:59:59'.in_time_zone('Tokyo'))
}
user_id_validation = {
user_id: 28
Expand Down Expand Up @@ -72,7 +72,7 @@ def self.divided_sheets
tweeted_at_index = 18 # R列

# TODO: whereの条件を分割する
tweets_ascending = Tweet.where(is_retweet: 0).where(tweeted_at: '2018-06-22 21:00:00'.in_time_zone('Tokyo')..'2018-06-24 09:00:00'.in_time_zone('Tokyo')).where.not(user_id: 28).order(tweeted_at: :asc)
tweets_ascending = Tweet.where(is_retweet: 0).where(tweeted_at: ('2018-06-22 21:00:00'.in_time_zone('Tokyo'))..('2018-06-24 09:00:00'.in_time_zone('Tokyo'))).where.not(user_id: 28).order(tweeted_at: :asc)

# TODO: NOT DRY
target_worksheets = [
Expand All @@ -95,7 +95,7 @@ def self.divided_sheets
'ツイ 17',
'ツイ 18',
'ツイ 19',
'ツイ 20'
'ツイ 20',
]

# 100 ごとに分割
Expand Down
4 changes: 1 addition & 3 deletions app/lib/twitter_api/search_tweet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ def self.search_word_tweet_exists?(search_word:)
# TODO: 汚い
if SearchWord.where(word: search_word).first.nil?
false
elsif SearchWord.where(word: search_word).first.tweets.empty?
false
else
true
!SearchWord.where(word: search_word).first.tweets.empty?
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/lib/twitter_api/upsert_objects/search_words_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def self.upsert(search_word:)
word: search_word
},
{
created_at: Time.now,
updated_at: Time.now
created_at: Time.zone.now,
updated_at: Time.zone.now
}
)
end
Expand Down
4 changes: 2 additions & 2 deletions app/lib/twitter_api/upserted_columns_hash/tweet_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def all_columns(tweet_object, search_word: nil)
text: kill_nil(tweet_object.attrs[:full_text]),
search_word_id: kill_nil(search_word_id),

created_at: Time.now,
updated_at: Time.now
created_at: Time.zone.now,
updated_at: Time.zone.now
}
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/lib/twitter_api/upserted_columns_hash/user_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def all_columns(user_object)
connections: kill_nil(user_object.connections, default_value: 'NOTHING'),
email: kill_nil(user_object.email, default_value: 'NOTHING'),

created_at: Time.now,
updated_at: Time.now
created_at: Time.zone.now,
updated_at: Time.zone.now
}
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/tweet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Tweet < ApplicationRecord
}

tweeted_at_validation = {
tweeted_at: '2018-06-22 21:00:00'.in_time_zone('Tokyo')..'2018-06-24 09:59:59'.in_time_zone('Tokyo')
tweeted_at: ('2018-06-22 21:00:00'.in_time_zone('Tokyo'))..('2018-06-24 09:59:59'.in_time_zone('Tokyo'))
}

user_id = User.find_by(screen_name: 'gensosenkyo').nil? ? 0 : User.find_by(screen_name: 'gensosenkyo').id
Expand All @@ -30,7 +30,7 @@ class Tweet < ApplicationRecord

# now_counting
tweeted_at_validation_for_now_counting = {
tweeted_at: '2018-06-30 12:00:00'.in_time_zone('Tokyo')..'2018-07-01 23:59:59'.in_time_zone('Tokyo')
tweeted_at: ('2018-06-30 12:00:00'.in_time_zone('Tokyo'))..('2018-07-01 23:59:59'.in_time_zone('Tokyo'))
}

scope :now_counting_tweets_desc, lambda {
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class User < ApplicationRecord
def valid_condition_for_vote
{
is_retweet: 0,
tweeted_at: '2018-06-22 21:00:00'.in_time_zone('Tokyo')..'2018-06-24 09:59:59'.in_time_zone('Tokyo')
tweeted_at: ('2018-06-22 21:00:00'.in_time_zone('Tokyo'))..('2018-06-24 09:59:59'.in_time_zone('Tokyo'))
}
end

Expand Down