Skip to content

Commit

Permalink
Merge pull request #348 from cookpad/nekketsuuu-rubocop
Browse files Browse the repository at this point in the history
Lint by RuboCop
  • Loading branch information
nekketsuuu authored Apr 18, 2024
2 parents e40f570 + 596161d commit b7f0976
Show file tree
Hide file tree
Showing 20 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
cache: 'npm'
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
ruby-version: .ruby-version
bundler-cache: true
- name: Setup DB
run: bin/rails db:create ridgepole:apply
Expand Down
2 changes: 1 addition & 1 deletion app/batches/import_table_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def self.import_column_memos!(source_table, table_memo)
columns.each_with_index do |column, position|
column_memo = column_memos.find { |memo| memo.name == column.name } || table_memo.column_memos.build(name: column.name)
column_memo.linked = true
column_memo.assign_attributes(sql_type: column.sql_type, default: column.default, nullable: column.null, position: position)
column_memo.assign_attributes(sql_type: column.sql_type, default: column.default, nullable: column.null, position:)
column_memo.save! if column_memo.has_changes_to_save?

Rails.logger.info "[Update Column] #{column_memo.name} column" if column_memo.saved_changes?
Expand Down
2 changes: 1 addition & 1 deletion app/batches/synchronize_data_sources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def self.import_table_memo!(schema_memo, table_memos, source_table)
columns.each_with_index do |column, position|
column_memo = column_memos.find { |memo| memo.name == column.name } || table_memo.column_memos.build(name: column.name)
column_memo.linked = true
column_memo.assign_attributes(sql_type: column.sql_type, default: column.default, nullable: column.null, position: position)
column_memo.assign_attributes(sql_type: column.sql_type, default: column.default, nullable: column.null, position:)
column_memo.save! if column_memo.changed?
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/data_sources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@ def create_or_update_bigquery_config(data_source)
bigquery_config_params[:credentials] = bigquery_config_params[:credentials].read
end

BigqueryConfig.find_or_initialize_by(data_source: data_source).update!(bigquery_config_params)
BigqueryConfig.find_or_initialize_by(data_source:).update!(bigquery_config_params)
end
end
2 changes: 1 addition & 1 deletion app/controllers/database_memos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ def destroy(id)

def redirect_named_path(id = nil)
return unless id =~ /\A\d+\z/
redirect_to database_memo_path(DatabaseMemo.where(id: id).pluck(:name).first)
redirect_to database_memo_path(DatabaseMemo.where(id:).pluck(:name).first)
end
end
4 changes: 2 additions & 2 deletions app/controllers/favorite_tables_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class FavoriteTablesController < ApplicationController
def create(table_memo_id)
@favorite_table = FavoriteTable.create!(user_id: current_user.id, table_memo_id: table_memo_id)
@favorite_table = FavoriteTable.create!(user_id: current_user.id, table_memo_id:)
end

def destroy(table_memo_id)
@favorite_table = FavoriteTable.find_by!(user_id: current_user.id, table_memo_id: table_memo_id)
@favorite_table = FavoriteTable.find_by!(user_id: current_user.id, table_memo_id:)
@favorite_table.destroy!
end
end
2 changes: 1 addition & 1 deletion app/controllers/schema_memos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class SchemaMemosController < ApplicationController
before_action :redirect_named_path, only: :show

def show(database_name, name)
@schema_memo = SchemaMemo.includes(table_memos: [:logs, :column_memos]).joins(:database_memo).merge(DatabaseMemo.where(name: database_name)).where(name: name).take!
@schema_memo = SchemaMemo.includes(table_memos: [:logs, :column_memos]).joins(:database_memo).merge(DatabaseMemo.where(name: database_name)).where(name:).take!
redirect_to database_memo_path(@schema_memo.database_memo.name) if @schema_memo.single_schema?
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/table_memos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def show(database_name, schema_name, name)
includes(column_memos: :logs).
joins(:schema_memo).
merge(SchemaMemo.where(name: schema_name).joins(:database_memo).merge(DatabaseMemo.where(name: database_name))).
where(name: name).
where(name:).
take!
@view_meta_data = @table_memo.view_meta_data
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/description_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def build_log(user_id)
current_revision = last_log.try(:revision).to_i
logs.build(
revision: current_revision + 1,
user_id: user_id,
user_id:,
description: self.description,
description_diff: diff(last_log.try(:description), self.description),
)
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/data_source_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
trait :bigquery_adapter do
adapter { "bigquery" }
after(:create) do |data_source|
FactoryBot.create(:bigquery_config, data_source: data_source)
FactoryBot.create(:bigquery_config, data_source:)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe HTML::Pipeline::AutolinkKeywordFilter do
describe "#call" do
let(:filter) { HTML::Pipeline::AutolinkKeywordFilter.new(doc, autolink_keywords: autolink_keywords) }
let(:filter) { HTML::Pipeline::AutolinkKeywordFilter.new(doc, autolink_keywords:) }
let(:doc) { Nokogiri::HTML::DocumentFragment.parse(html) }
let(:autolink_keywords) { {
"ruby" => "https://www.ruby-lang.org/",
Expand Down
6 changes: 3 additions & 3 deletions spec/models/autolink_keyword_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
describe AutolinkKeyword, type: :model do
describe ".links" do
let(:database_memo) { FactoryBot.create(:database_memo, name: "db") }
let(:schema_memo) { FactoryBot.create(:schema_memo, database_memo: database_memo, name: "myapp") }
let(:schema_memo) { FactoryBot.create(:schema_memo, database_memo:, name: "myapp") }
before do
FactoryBot.create(:table_memo, schema_memo: schema_memo, name: "books")
FactoryBot.create(:table_memo, schema_memo:, name: "books")
FactoryBot.create(:keyword, name: "difficult-word", description: "Difficult!")
end

Expand All @@ -24,7 +24,7 @@
"myapp.books" => "/databases/db/myapp/books",
"difficult-word" => "/keywords/difficult-word",
)
memo = FactoryBot.create(:table_memo, schema_memo: schema_memo, name: "blogs")
memo = FactoryBot.create(:table_memo, schema_memo:, name: "blogs")
expect(AutolinkKeyword.links).to eq(
"books" => "/databases/db/myapp/books",
"myapp.books" => "/databases/db/myapp/books",
Expand Down
4 changes: 2 additions & 2 deletions spec/models/data_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@

context "with ignored pattern" do
it "ignores specified table" do
FactoryBot.create(:ignored_table, data_source: data_source, pattern: "data_sources")
FactoryBot.create(:ignored_table, data_source:, pattern: "data_sources")
expect(data_source.data_source_tables.map(&:table_name)).not_to include("data_sources")
end

it "ignores specified schema" do
FactoryBot.create(:ignored_table, data_source: data_source, pattern: "public")
FactoryBot.create(:ignored_table, data_source:, pattern: "public")
expect(data_source.data_source_tables.map(&:table_name)).to eq []
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/data_sources_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@

describe "#edit" do
let!(:data_source) { FactoryBot.create(:data_source) }
let!(:database_memo) { FactoryBot.create(:database_memo, name: "db", data_source: data_source) }
let!(:schema_memo) { FactoryBot.create(:schema_memo, database_memo: database_memo, name: "myapp") }
let!(:database_memo) { FactoryBot.create(:database_memo, data_source:, name: "db") }
let!(:schema_memo) { FactoryBot.create(:schema_memo, database_memo:, name: "myapp") }

it "shows form" do
get edit_data_source_path(data_source)
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/favorite_tables_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let(:user) { FactoryBot.create(:user) }
let(:table_memo) { FactoryBot.create(:table_memo) }
before do
login!(user: user)
login!(user:)
end

describe "#create" do
Expand All @@ -19,7 +19,7 @@

describe "#destroy" do
before do
FactoryBot.create(:favorite_table, user: user, table_memo: table_memo)
FactoryBot.create(:favorite_table, user:, table_memo:)
end

it "destroys favorite table" do
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/ignored_tables_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe :ignored_tables, type: :request do
let(:user) { FactoryBot.create(:user, admin: true) }
before do
login!(user: user)
login!(user:)
end

describe "#index" do
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/schema_memos_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
describe "#show" do
context "with multiple schemas" do
before do
FactoryBot.create(:schema_memo, database_memo: database_memo)
FactoryBot.create(:schema_memo, database_memo:)
end

it "shows memo" do
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
describe :settings, type: :request do
let(:user) { FactoryBot.create(:user) }
let(:data_source) { FactoryBot.create(:data_source, name: "test_ds") }
let!(:ignored_table) { FactoryBot.create(:ignored_table, data_source: data_source) }
let!(:ignored_table) { FactoryBot.create(:ignored_table, data_source:) }
before do
login!(user: user)
login!(user:)
end

describe "#show" do
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe :users, type: :request do
let(:user) { FactoryBot.create(:user) }
before do
login!(user: user)
login!(user:)
end

describe "#index" do
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helpers/request_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ def self.last_response=(response)

def set_rack_session(hash)
data = ::RackSessionAccess.encode(hash)
put RackSessionAccess.path, params: { data: data }
put RackSessionAccess.path, params: { data: }
end

def login!(user: nil, admin: false)
user ||= FactoryBot.create(:user, admin: admin)
user ||= FactoryBot.create(:user, admin:)
set_rack_session(user_id: user.id)
end

Expand Down

0 comments on commit b7f0976

Please sign in to comment.