From f64d3c3e1da25317888a626166491d66d7ec2098 Mon Sep 17 00:00:00 2001 From: Watson Date: Sat, 11 Nov 2023 15:49:21 +0900 Subject: [PATCH] Fix rubocop error --- .rubocop.yml | 3 ++ .rubocop_todo.yml | 33 ++++++++++++++++++-- example/benchmark_insert.rb | 62 +++++++++++++++++++++---------------- example/benchmark_select.rb | 20 ++++++------ 4 files changed, 80 insertions(+), 38 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9414ac6..531df40 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -32,6 +32,9 @@ Metrics/MethodLength: Minitest/MultipleAssertions: Enabled: false +Style/BlockComments: + Enabled: false + Style/ClassVars: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5578f5f..d77404c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,25 +1,52 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-11-03 17:03:03 UTC using RuboCop version 1.57.2. +# on 2023-11-11 06:48:00 UTC using RuboCop version 1.57.2. # 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: 3 +# Offense count: 4 +# Configuration parameters: AllowComments, AllowEmptyLambdas. +Lint/EmptyBlock: + Exclude: + - 'example/benchmark_insert.rb' + - 'example/benchmark_select.rb' + +# Offense count: 8 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to +Naming/MethodParameterName: + Exclude: + - 'example/benchmark_insert.rb' + - 'example/benchmark_select.rb' + +# Offense count: 2 +# Configuration parameters: AllowedChars. +# AllowedChars: © +Style/AsciiComments: + Exclude: + - 'example/benchmark_insert.rb' + - 'example/benchmark_select.rb' + +# Offense count: 7 # Configuration parameters: AllowedConstants. Style/Documentation: Exclude: - 'spec/**/*' - 'test/**/*' + - 'example/benchmark_insert.rb' + - 'example/benchmark_select.rb' - 'ext/ilios/extconf.rb' - 'lib/ilios.rb' -# Offense count: 4 +# Offense count: 16 # Configuration parameters: RequireForNonPublicMethods. Style/DocumentationMethod: Exclude: - 'spec/**/*' - 'test/**/*' + - 'example/benchmark_insert.rb' + - 'example/benchmark_select.rb' - 'ext/ilios/extconf.rb' - 'lib/ilios.rb' diff --git a/example/benchmark_insert.rb b/example/benchmark_insert.rb index fb6f06f..d0ca70d 100644 --- a/example/benchmark_insert.rb +++ b/example/benchmark_insert.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bundler/inline' gemfile do source 'https://rubygems.org' @@ -7,10 +9,9 @@ gem 'ilios' end - Ilios::Cassandra.config = { keyspace: 'ilios', - hosts: ['127.0.0.1'], + hosts: ['127.0.0.1'] } # Create new table @@ -30,7 +31,6 @@ CQL Ilios::Cassandra.session.execute(statement) - class BenchmarkCassandra def initialize @cluster = Cassandra.cluster @@ -40,25 +40,31 @@ def initialize def run_execute(x) x.report('cassandra-driver:execute') do - @session.execute(statement, { - arguments: { - id: Random.rand(2**40), - message: 'hello', - created_at: Time.now + @session.execute( + statement, + { + arguments: { + id: Random.rand(2**40), + message: 'hello', + created_at: Time.now + } } - }) + ) end end def run_execute_async(x) x.report('cassandra-driver:execute_async') do - future = @session.execute_async(statement, { - arguments: { - id: Random.rand(2**40), - message: 'hello', - created_at: Time.now + future = @session.execute_async( + statement, + { + arguments: { + id: Random.rand(2**40), + message: 'hello', + created_at: Time.now + } } - }) + ) future.on_success do |rows| end end @@ -78,22 +84,26 @@ def statement class BenchmarkIlios def run_execute(x) x.report('ilios:execute') do - statement.bind({ - id: Random.rand(2**40), - message: 'hello', - created_at: Time.now - }) + statement.bind( + { + id: Random.rand(2**40), + message: 'hello', + created_at: Time.now + } + ) Ilios::Cassandra.session.execute(statement) end end def run_execute_async(x) x.report('ilios:execute_async') do - statement.bind({ - id: Random.rand(2**40), - message: 'hello', - created_at: Time.now - }) + statement.bind( + { + id: Random.rand(2**40), + message: 'hello', + created_at: Time.now + } + ) future = Ilios::Cassandra.session.execute_async(statement) future.on_success do |results| results.each do |row| @@ -120,7 +130,7 @@ def statement sleep 10 -puts "" +puts '' Benchmark.ips do |x| BenchmarkIlios.new.run_execute(x) BenchmarkIlios.new.run_execute_async(x) diff --git a/example/benchmark_select.rb b/example/benchmark_select.rb index b495b7c..3805081 100644 --- a/example/benchmark_select.rb +++ b/example/benchmark_select.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bundler/inline' gemfile do source 'https://rubygems.org' @@ -7,10 +9,9 @@ gem 'ilios' end - Ilios::Cassandra.config = { keyspace: 'ilios', - hosts: ['127.0.0.1'], + hosts: ['127.0.0.1'] } # Create new table @@ -40,15 +41,16 @@ CQL 1000.times do - statement.bind({ - id: Random.rand(2**40), - message: 'hello', - created_at: Time.now - }) + statement.bind( + { + id: Random.rand(2**40), + message: 'hello', + created_at: Time.now + } + ) Ilios::Cassandra.session.execute(statement) end - class BenchmarkCassandra def initialize @cluster = Cassandra.cluster @@ -108,7 +110,7 @@ def statement sleep 10 -puts "" +puts '' Benchmark.ips do |x| BenchmarkIlios.new.run_execute(x) BenchmarkIlios.new.run_execute_async(x)