Skip to content

Rubocop fixes #166

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

Merged
merged 1 commit into from
Feb 27, 2025
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
8 changes: 5 additions & 3 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ jobs:
- name: Set up ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
ruby-version: 3.3
- name: Install dependencies
run: bundle install
- name: Run rubocop
run: bundle exec rubocop
run: |
bundle exec rubocop -v
bundle exec rubocop

clang_format:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -54,7 +56,7 @@ jobs:
- name: Set up ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
ruby-version: 3.3
- name: Install dependencies
run: |
sudo apt-get update -y
Expand Down
4 changes: 2 additions & 2 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require "irb"
require "open3"
require "couchbase"

include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

customer123 = {
"name" => "Douglas Reynholm",
Expand Down Expand Up @@ -105,4 +105,4 @@ alias collection default_collection
# cluster # returns connected cluster
# default_collection # returns default collection (accept bucket name, defaults to "default")
# customer123 # returns sample document
binding.irb # rubocop:disable Lint/Debugger start REPL
binding.irb # rubocop:disable Lint/Debugger -- start REPL
2 changes: 1 addition & 1 deletion bin/init-cluster
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ options = {
sample_buckets: Set.new,
}
default_port = options[:strict_encryption] ? 18091 : 8091
if (options[:cluster_run_nodes]).positive?
if options[:cluster_run_nodes].positive?
default_port = options[:strict_encryption] ? 19000 : 9000
end
options[:port] = ENV.fetch("CB_PORT", default_port).to_i
Expand Down
1 change: 1 addition & 0 deletions bin/jenkins/check-rubocop
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ chruby ruby-${CB_RUBY_VERSION}
bundle config set --local path ${PROJECT_ROOT}/vendor/bundle

bundle install
bundle exec rubocop -v
bundle exec rubocop
8 changes: 4 additions & 4 deletions examples/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

require "couchbase"

include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)

Expand Down Expand Up @@ -202,7 +202,7 @@

# Named parameters
puts "---- named parameters"
options = Cluster::AnalyticsOptions.new
options = Options::Analytics.new
options.named_parameters({user_id: 2})
res = cluster.analytics_query("
USE #{dataverse_name};
Expand All @@ -223,7 +223,7 @@

# Positional parameters
puts "---- positional parameters"
options = Cluster::AnalyticsOptions.new
options = Options::Analytics.new
options.positional_parameters([2])
res = cluster.analytics_query("
USE #{dataverse_name};
Expand Down
4 changes: 2 additions & 2 deletions examples/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# limitations under the License.

require "couchbase"
include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
# initializes {PasswordAuthenticator} internally
options.authenticate("Administrator", "password")
Cluster.connect("couchbase://localhost", options)
Expand Down
4 changes: 2 additions & 2 deletions examples/crud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# limitations under the License.

require "couchbase"
include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

options = Cluster::ClusterOptions.new
options = Options::Cluster.new

options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)
Expand Down
4 changes: 2 additions & 2 deletions examples/managing_analytics_indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
# limitations under the License.

require "couchbase"
include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

def measure(msg)
start = Time.now
yield
printf "%<msg>s in %<elapsed>.2f seconds\n", msg: msg, elapsed: Time.now - start
end

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)

Expand Down
4 changes: 2 additions & 2 deletions examples/managing_buckets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
# limitations under the License.

require "couchbase"
include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

def measure(msg)
start = Time.now
yield
printf "%<msg>s in %<elapsed>.2f seconds\n", msg: msg, elapsed: Time.now - start
end

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)

Expand Down
4 changes: 2 additions & 2 deletions examples/managing_collections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

require "couchbase"
include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

def measure(msg)
start = Time.now
Expand All @@ -26,7 +26,7 @@ def measure(msg)
bucket_name = "travel-sample"
scope_name = "myapp"

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)
bucket = cluster.bucket(bucket_name)
Expand Down
4 changes: 2 additions & 2 deletions examples/managing_query_indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

require "couchbase"
include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

def measure(msg)
start = Time.now
Expand All @@ -36,7 +36,7 @@ def display_indexes(indexes, bucket_name)

bucket_name = "beer-sample"

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)

Expand Down
4 changes: 2 additions & 2 deletions examples/managing_search_indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
# limitations under the License.

require "couchbase"
include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

def measure(msg)
start = Time.now
yield
printf "%<msg>s in %<elapsed>.2f seconds\n", msg: msg, elapsed: Time.now - start
end

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)

Expand Down
6 changes: 3 additions & 3 deletions examples/managing_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# limitations under the License.

require "couchbase"
include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)

Expand Down Expand Up @@ -71,7 +71,7 @@

# Using a user created in the SDK to access data
bucket_name = "travel-sample"
options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("testUsername", "testPassword")
user_cluster = Cluster.connect("couchbase://localhost", options)
user_bucket = user_cluster.bucket(bucket_name)
Expand Down
4 changes: 2 additions & 2 deletions examples/managing_view_indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

require "couchbase"
include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

def measure(msg)
start = Time.now
Expand All @@ -38,7 +38,7 @@ def display_indexes(manager, namespace)

bucket_name = "beer-sample"

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)

Expand Down
6 changes: 3 additions & 3 deletions examples/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

require "couchbase"

include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)

cluster.bucket("travel-sample") # this is necessary for 6.0.x

options = Cluster::QueryOptions.new
options = Options::Query.new
options.named_parameters({type: "hotel"})
options.metrics = true
res = cluster.query("SELECT * FROM `travel-sample` WHERE type = $type LIMIT 10", options)
Expand Down
8 changes: 4 additions & 4 deletions examples/query_with_consistency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

require "couchbase"

include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)

Expand All @@ -42,7 +42,7 @@
"data" => random_number,
})

options = Cluster::QueryOptions.new
options = Options::Query.new
options.timeout = 10_000
options.positional_parameters(["Brass"])
options.scan_consistency = :request_plus
Expand Down Expand Up @@ -73,7 +73,7 @@
state = MutationState.new(res.mutation_token)
# state.add(*tokens) could be used to add more tokens

options = Cluster::QueryOptions.new
options = Options::Query.new
options.timeout = 10_000
options.positional_parameters(["Brass"])
options.consistent_with(state)
Expand Down
4 changes: 2 additions & 2 deletions examples/range_scan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

require 'couchbase'

include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)

Expand Down
8 changes: 4 additions & 4 deletions examples/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

require "couchbase"

include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)

Expand Down Expand Up @@ -136,7 +136,7 @@

# search with facets advanced sort
query = Cluster::SearchQuery.match_phrase("hop beer")
options = Cluster::SearchOptions.new
options = Options::Search.new
options.limit = 10
options.fields = %w[name]
options.highlight_style = :html
Expand Down Expand Up @@ -168,7 +168,7 @@
query = Cluster::SearchQuery.term("beer")
query.field = "type"

options = Cluster::SearchOptions.new
options = Options::Search.new
options.facets = {}

term_facet = Cluster::SearchFacet.term("name")
Expand Down
6 changes: 3 additions & 3 deletions examples/search_with_consistency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

require "couchbase"

include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)

Expand Down Expand Up @@ -85,7 +85,7 @@
# state.add(*tokens) could be used to add more tokens

query = Cluster::SearchQuery.term("doorknob")
options = Cluster::SearchOptions.new
options = Options::Search.new
options.timeout = 10_000
options.consistent_with(state)
res = cluster.search_query(search_index_name, query, options)
Expand Down
4 changes: 2 additions & 2 deletions examples/subdocument.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# limitations under the License.

require "couchbase"
include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)
bucket = cluster.bucket("default")
Expand Down
10 changes: 5 additions & 5 deletions examples/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@

require "couchbase"

include Couchbase # rubocop:disable Style/MixinUsage for brevity
include Couchbase # rubocop:disable Style/MixinUsage -- for brevity

options = Cluster::ClusterOptions.new
options = Options::Cluster.new
options.authenticate("Administrator", "password")
cluster = Cluster.connect("couchbase://localhost", options)

bucket = cluster.bucket("beer-sample")
collection = bucket.default_collection

options = Bucket::ViewOptions.new
options = Options::View.new
options.reduce = true
options.group_level = 1
res = bucket.view_query("beer", "by_location", options)
Expand All @@ -34,7 +34,7 @@
puts "#{row.key.first}: #{row.value} breweries"
end

options = Bucket::ViewOptions.new
options = Options::View.new
options.limit = 10
options.order = :descending
res = bucket.view_query("beer", "brewery_beers", options)
Expand All @@ -52,7 +52,7 @@
"type" => "brewery",
})
puts "\nRequest with consistency. Generated brewery name: #{unique_brewery_id}"
options = Bucket::ViewOptions.new
options = Options::View.new
options.start_key = ["random_brewery:"]
options.scan_consistency = :request_plus
res = bucket.view_query("beer", "brewery_beers", options)
Expand Down
Loading
Loading