Skip to content

Commit

Permalink
rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
1021ky committed Nov 9, 2024
1 parent a36b17f commit 6eb01eb
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 32 deletions.
3 changes: 3 additions & 0 deletions .config/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AllCops:
Exclude:
- 'generated/**/*.rb'
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
inherit_from: .rubocop_todo.yml
125 changes: 125 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-11-09 13:19:03 UTC using RuboCop version 1.66.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
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_argument, with_fixed_indentation
Layout/ArgumentAlignment:
Exclude:
- 'bin/webpack'
- 'bin/webpack-dev-server'

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: leading, trailing
Layout/DotPosition:
Exclude:
- 'bin/yarn'

# Offense count: 35
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLineAfterMagicComment:
Enabled: false

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, no_empty_lines
Layout/EmptyLinesAroundBlockBody:
Exclude:
- 'db/schema.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
Layout/EmptyLinesAroundClassBody:
Exclude:
- 'config/application.rb'

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented, indented_relative_to_receiver
Layout/MultilineMethodCallIndentation:
Exclude:
- 'bin/yarn'

# Offense count: 2
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 47

# Offense count: 5
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'test/channels/application_cable/connection_test.rb'
- 'test/test_helper.rb'

# Offense count: 3
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'config/application.rb'

# Offense count: 56
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: InverseMethods, InverseBlocks.
Style/InverseMethods:
Exclude:
- 'bin/yarn'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinDigits, Strict, AllowedNumbers, AllowedPatterns.
Style/NumericLiterals:
Exclude:
- 'db/schema.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SafeForConstants.
Style/RedundantFetchBlock:
Exclude:
- 'config/puma.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Style/StderrPuts:
Exclude:
- 'bin/yarn'

# Offense count: 152
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Enabled: false

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: .
# SupportedStyles: percent, brackets
Style/SymbolArray:
EnforcedStyle: percent
MinSize: 10
4 changes: 3 additions & 1 deletion app/controllers/admin/top_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# typed: strict
class Admin::TopController < ApplicationController
module Admin
class TopController < ApplicationController
end
end
11 changes: 8 additions & 3 deletions app/controllers/api/top_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# typed: false
class Api::TopController < ApplicationController
def index
render action ":index"
module Api
#
# Topページ用コントローラー
#
class TopController < ApplicationController
def index
render action ":index"
end
end
end
11 changes: 8 additions & 3 deletions app/controllers/user/top_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# typed: false
class User::TopController < ApplicationController
def index
render action ":index"
module User
#
# ユーザートップのコントローラー
#
class TopController < ApplicationController
def index
render action ":index"
end
end
end
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@

# 開発環境はwebconsoleを使えるようにする
# まだデプロイ先が決まっていないので、全てのIPからのアクセスを許可する
config.web_console.allowed_ips instead = ['0.0.0.0/24']
config.web_console.allowed_ips ['0.0.0.0/24']
end
4 changes: 2 additions & 2 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
config.log_level = :info

# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
config.log_tags = [:request_id]

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
Expand Down Expand Up @@ -90,7 +90,7 @@
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
Expand Down
3 changes: 3 additions & 0 deletions db/migrate/20240929232900_create_x_users.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# typed: true

#
# ユーザー追加
#
class CreateXUsers < ActiveRecord::Migration[6.1]
def change
# 登録したら基本的に変えないデータ
Expand Down
3 changes: 3 additions & 0 deletions db/migrate/20241002234905_create_tweets.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#
# Tweetsテーブル追加
#
class CreateTweets < ActiveRecord::Migration[6.1]
def change
create_table :tweets do |t|
Expand Down
44 changes: 22 additions & 22 deletions spec/experiments/string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@

# Stringクラスのテスト(文字列で指定することも可能)
describe String do
# インスタンスメソッド<<のテスト(慣用的に#をつけるとインスタンスメソッドを表す)
describe "#<<" do
example "文字の追加" do
# pendingを使うと保留中のテストとしてマークできて、失敗してもfailuresには含まれない
# 実行はされて、もしテストが通るのならば、failureとして扱われる
# pending("保留中のテスト")
# インスタンスメソッド<<のテスト(慣用的に#をつけるとインスタンスメソッドを表す)
describe "#<<" do
example "文字の追加" do
# pendingを使うと保留中のテストとしてマークできて、失敗してもfailuresには含まれない
# 実行はされて、もしテストが通るのならば、failureとして扱われる
# pending("保留中のテスト")

# 単にスキップしたいときはexampleをexampleメソッドに変えてしまう。pendingと違って保留理由のメッセージは表示されない
# 単にスキップしたいときはexampleをexampleメソッドに変えてしまう。pendingと違って保留理由のメッセージは表示されない

# given
s = "ABC"
# when
s << "D"
# then
expect(s.size).to eq(4)
end
example "nilの追加はできない", :exception do
# given
s = "ABC"
# when then
# expectには、ブロックを渡すこともできる
expect { s << nil }.to raise_error(TypeError)
end
# given
s = "ABC"
# when
s << "D"
# then
expect(s.size).to eq(4)
end
end
example "nilの追加はできない", :exception do
# given
s = "ABC"
# when then
# expectには、ブロックを渡すこともできる
expect { s << nil }.to raise_error(TypeError)
end
end
end

0 comments on commit 6eb01eb

Please sign in to comment.