Skip to content
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
16 changes: 15 additions & 1 deletion .github/workflows/bson-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ name: CI
on: [push, pull_request]

jobs:
rubocop:
runs-on: ubuntu-latest
env:
CI: true
steps:
- uses: actions/checkout@v3
- name: Set up Ruby 3.4
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.4
bundler-cache: true
- name: Run RuboCop
run: bundle exec rubocop --parallel

build:
name: >-
${{ matrix.os }} ${{ matrix.ruby }}
Expand All @@ -20,7 +34,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu, macos, windows ]
ruby: [ 2.7, 3.0, 3.1, 3.2, 3.3, head ]
ruby: [ 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, head ]
include:
- { os: windows , ruby: mingw }
exclude:
Expand Down
5 changes: 3 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
require:
plugins:
- rubocop-performance
- rubocop-rake
- rubocop-rspec

AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 2.6
NewCops: enable
Exclude:
- 'spec/shared/**/*'
- 'tmp/**/*'
- 'vendor/**/*'

Bundler:
Enabled: true
Expand Down
15 changes: 8 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ group :development, :test do
# https://github.com/jruby/jruby/wiki/UsingTheJRubyDebugger
gem 'ruby-debug', platforms: :jruby

# Ruby 2.5 wants an older version of rubocop. Rather than try to
# please everybody, we'll just not install rubocop for Ruby 2.5.
if RUBY_VERSION > "2.5.99"
gem 'rubocop', '~> 1.45.1'
gem 'rubocop-performance', '~> 1.16.0'
gem 'rubocop-rake', '~> 0.6.0'
gem 'rubocop-rspec', '~> 2.18.1'
# JRuby 9.3 reports RUBY_VERSION as 2.6, and the latest versions of Rubocop
# wants 2.7 or higher. It enough to use rubocop only on MRI, so we can skip
# it on JRuby.
unless RUBY_PLATFORM =~ /java/
gem 'rubocop', '~> 1.75.5'
gem 'rubocop-performance', '~> 1.25.0'
gem 'rubocop-rake', '~> 0.7.1'
gem 'rubocop-rspec', '~> 3.6.0'
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/bson/binary.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

# rubocop:todo all
# Copyright (C) 2009-2020 MongoDB Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion lib/bson/object_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def repair(object)
# NUM2UINT. Further, the spec dictates that the time component of an
# ObjectID must be no more than 4 bytes long, so the spec itself is
# constrained in this regard.
MAX_INTEGER = 2 ** 32
MAX_INTEGER = 2**32

# Returns an integer timestamp (seconds since the Epoch). Primarily used
# by the generator to produce object ids.
Expand Down
6 changes: 3 additions & 3 deletions lib/bson/regexp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ def bson_options
end

def bson_extended
(options & ::Regexp::EXTENDED).zero? ? NO_VALUE : EXTENDED_VALUE
options.nobits?(::Regexp::EXTENDED) ? NO_VALUE : EXTENDED_VALUE
end

def bson_ignorecase
(options & ::Regexp::IGNORECASE).zero? ? NO_VALUE : IGNORECASE_VALUE
options.nobits?(::Regexp::IGNORECASE) ? NO_VALUE : IGNORECASE_VALUE
end

def bson_dotall
# Ruby Regexp's MULTILINE is equivalent to BSON's dotall value
(options & ::Regexp::MULTILINE).zero? ? NO_VALUE : NEWLINE_VALUE
options.nobits?(::Regexp::MULTILINE) ? NO_VALUE : NEWLINE_VALUE
end

# Represents the raw values for the regular expression.
Expand Down
1 change: 0 additions & 1 deletion lib/bson/vector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
module BSON
# Vector of numbers along with metadata for binary interoperability.
class Vector < ::Array

# @return [ Integer ] The data type stored in the vector.
attr_reader :dtype

Expand Down
2 changes: 0 additions & 2 deletions spec/runners/binary_vector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def invalid_tests
end

class Test

attr_reader :canonical_bson, :description, :dtype, :padding, :vector

def initialize(spec, test)
Expand All @@ -49,7 +48,6 @@ def document_from_canonical_bson
bson_bytes = decode_hex(@canonical_bson)
buffer = BSON::ByteBuffer.new(bson_bytes)
BSON::Document.from_bson(buffer)

end

def canonical_bson_from_document(use_vector_type: false, validate_vector_data: false)
Expand Down