Skip to content
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

Ruby / Rubocop bump #71

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
ruby: ['2.6', '2.7', '3.0', '3.1', '3.2']
ruby: ['3.0', '3.1', '3.2', '3.3']
include:
- os: macos-latest
ruby: '3.2'
ruby: '3.3'

runs-on: ${{ matrix.os }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
ruby: ['2.6', '2.7', '3.0', '3.1', '3.2']
ruby: ['3.0', '3.1', '3.2', '3.3']
include:
- os: macos-latest
ruby: '3.2'
ruby: '3.3'

runs-on: ${{ matrix.os }}
steps:
Expand Down
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ require:
- rubocop-rspec

AllCops:
TargetRubyVersion: 2.6
TargetRubyVersion: 3.0
NewCops: enable

Gemspec/DevelopmentDependencies:
Enabled: false

# Disabled on our repo's to enable polyglot-release
Gemspec/RequireMFA:
Enabled: false
Expand Down
69 changes: 9 additions & 60 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,31 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-12-21 16:12:21 UTC using RuboCop version 1.44.1.
# on 2024-09-26 14:25:12 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.

# TODO: Nov '23 -> 25 files inspected, 132 offenses detected, 102 offenses autocorrectable
# TODO: Nov '23 -> 25 files inspected, 53 offenses detected, 28 offenses autocorrectable

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented, indented_relative_to_receiver
Layout/MultilineMethodCallIndentation:
Exclude:
- 'lib/cucumber/wire/request_handler.rb'
# TODO: Sep '24 -> 25 files inspected, 37 offenses detected, 19 offenses autocorrectable

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
Exclude:
- 'features/step_definitions/wire_steps.rb'
- 'features/support/fake_wire_server.rb'

# Offense count: 2
# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Exclude:
- 'spec/cucumber/wire/connection_spec.rb'

# Offense count: 1
Lint/RescueException:
Exclude:
- 'features/support/fake_wire_server.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Lint/ToJSON:
Exclude:
- 'lib/cucumber/wire/data_packet.rb'

# Offense count: 1
# Configuration parameters: AutoCorrect.
Lint/UselessAssignment:
Exclude:
- 'lib/cucumber/wire/connection.rb'
Expand All @@ -54,12 +36,12 @@ Lint/UselessRescue:
- 'features/support/fake_wire_server.rb'

# Offense count: 2
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 21

# Offense count: 2
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 13

Expand All @@ -83,15 +65,13 @@ RSpec/ExampleLength:

# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: .
# Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, each, example
RSpec/HookArgument:
EnforcedStyle: each

# Offense count: 2
RSpec/LeakyConstantDeclaration:
Exclude:
- 'spec/cucumber/wire/configuration_spec.rb'
- 'spec/cucumber/wire/connection_spec.rb'
- 'spec/cucumber/wire/exception_spec.rb'

# Offense count: 3
RSpec/MultipleExpectations:
Expand All @@ -104,28 +84,12 @@ RSpec/VerifiedDoubles:
- 'spec/cucumber/wire/connection_spec.rb'
- 'spec/cucumber/wire/connections_spec.rb'

# Offense count: 2
Rake/Desc:
Exclude:
- 'Rakefile'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Security/YAMLLoad:
Exclude:
- 'lib/cucumber/wire/configuration.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
# FunctionalMethods: let, let!, subject, watch
# AllowedMethods: lambda, proc, it
Style/BlockDelimiters:
Exclude:
- 'features/step_definitions/wire_steps.rb'

# Offense count: 2
Style/ClassVars:
Exclude:
Expand Down Expand Up @@ -155,14 +119,6 @@ Style/MutableConstant:
Exclude:
- 'lib/cucumber/wire/configuration.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
Style/ParallelAssignment:
Exclude:
- 'features/support/fake_wire_server.rb'
- 'lib/cucumber/wire/data_packet.rb'
- 'lib/cucumber/wire/step_argument.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RescueModifier:
Expand All @@ -183,10 +139,3 @@ Style/RescueStandardError:
Style/Semicolon:
Exclude:
- 'lib/cucumber/wire/connection.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'features/support/fake_wire_server.rb'
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo

## [Unreleased]
### Added
- Added some basic rubocop compliance to suite (More fixes to come) ([#69](https://github.com/cucumber/cucumber-ruby-wire/pull/69) [#70](https://github.com/cucumber/cucumber-ruby-wire/pull/70))
- Added some basic rubocop compliance to suite (More fixes to come) ([#69](https://github.com/cucumber/cucumber-ruby-wire/pull/69) [#70](https://github.com/cucumber/cucumber-ruby-wire/pull/70) [#71](https://github.com/cucumber/cucumber-ruby-wire/pull/71))

### Changed
- Minimum ruby version is now 3.0 ([#71](https://github.com/cucumber/cucumber-ruby-wire/pull/71))

### Fixed

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[![Test cucumber-wire](https://github.com/cucumber/cucumber-ruby-wire/actions/workflows/cucumber-ruby-wire.yml/badge.svg)](https://github.com/cucumber/cucumber-ruby-wire/actions/workflows/cucumber-ruby-wire.yml)
[![Test cucumber-wire](https://github.com/cucumber/cucumber-ruby-wire/actions/workflows/test.yaml/badge.svg)](https://github.com/cucumber/cucumber-ruby-wire/actions/workflows/test.yaml)

# cucumber-wire

This gem was extracted from the [cucumber gem](https://github.com/cucumber/cucumber-ruby), and remains a runtime dependency to that gem.
This gem was extracted from the [cucumber gem](https://github.com/cucumber/cucumber-ruby)

Its tests are a bit hairy and prone to the occasional flicker.
This is available as an optional runtime dependency for cucumber-ruby and also as a runtime dependency for cucumber cpp.

In the future, it may become an opt-in plugin rather than a direct dependency on every Cucumber.
The tests here are a bit hairy and prone to the occasional flicker.

## Configuration

Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ Bundler::GemHelper.install_tasks

task default: %i[unit_tests acceptance_tests]

desc 'Unit tests for Cucumber Ruby Wire'
task :unit_tests do
sh 'bundle exec rspec'
end

desc 'Acceptance tests for Cucumber Ruby Wire'
task :acceptance_tests do
sh 'bundle exec cucumber'
end
22 changes: 11 additions & 11 deletions cucumber-wire.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ Gem::Specification.new do |s|
s.homepage = 'http://cucumber.io'
s.platform = Gem::Platform::RUBY
s.license = 'MIT'
s.required_ruby_version = '>= 2.6'
s.required_rubygems_version = '>= 3.0.3'
s.required_ruby_version = '>= 3.0'
s.required_rubygems_version = '>= 3.2.8'

s.add_dependency 'cucumber-core', '> 10.1', '< 14'
s.add_dependency 'cucumber-core', '> 11', '< 15'
s.add_dependency 'cucumber-cucumber-expressions', '> 14', '< 18'

s.add_development_dependency 'aruba', '~> 2.0'
s.add_development_dependency 'cucumber', '> 7.1', '< 10'
s.add_development_dependency 'rake', '~> 13.1'
s.add_development_dependency 'rspec', '~> 3.12'
s.add_development_dependency 'rubocop', '~> 1.44.1'
s.add_development_dependency 'aruba', '~> 2.2'
s.add_development_dependency 'cucumber', '> 8', '< 10'
s.add_development_dependency 'rake', '~> 13.2'
s.add_development_dependency 'rspec', '~> 3.13'
s.add_development_dependency 'rubocop', '~> 1.66.1'
s.add_development_dependency 'rubocop-packaging', '~> 0.5.2'
s.add_development_dependency 'rubocop-performance', '~> 1.17.1'
s.add_development_dependency 'rubocop-rake', '~> 0.5.0'
s.add_development_dependency 'rubocop-rspec', '~> 2.14.2'
s.add_development_dependency 'rubocop-performance', '~> 1.22.1'
s.add_development_dependency 'rubocop-rake', '~> 0.6.0'
s.add_development_dependency 'rubocop-rspec', '~> 3.0.5'

s.files = Dir['CHANGELOG.md', 'CHANGELOG.old.md', 'CONTRIBUTING.md', 'README.md', 'LICENSE', 'lib/**/*']
s.rdoc_options = ['--charset=UTF-8']
Expand Down
6 changes: 3 additions & 3 deletions features/step_definitions/wire_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Given(/^there is a wire server (running |)on port (\d+) which understands the following protocol:$/) do |running, port, table|
protocol = table.hashes.map do |table_hash|
table_hash['response'] = table_hash['response'].gsub(/\n/, '\n')
table_hash['response'] = table_hash['response'].gsub("\n", '\n')
table_hash
end

Expand All @@ -29,10 +29,10 @@ module WireHelper
def start_wire_server
@messages_received = []
reader, writer = IO.pipe
@wire_pid = fork {
@wire_pid = fork do
reader.close
@server.run(writer)
}
end
writer.close
Thread.new do
while message = reader.gets
Expand Down
5 changes: 3 additions & 2 deletions features/support/fake_wire_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

class FakeWireServer
def initialize(port, protocol_table)
@port, @protocol_table = port, protocol_table
@port = port
@protocol_table = protocol_table
@delays = {}
end

Expand Down Expand Up @@ -69,7 +70,7 @@ def response_to(data)
end

def send_response(response)
@socket.puts response + "\n"
@socket.puts("#{response}\n")
end

def delay(data)
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/wire/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.from_file(wire_file)
def initialize(args)
@host = args['host']
@port = args['port']
@unix = args['unix'] if RUBY_PLATFORM !~ /mingw|mswin/
@unix = args['unix'] unless RUBY_PLATFORM.match?(/mingw|mswin/)
@timeouts = DEFAULT_TIMEOUTS.merge(args['timeout'] || {})
end

Expand Down
5 changes: 3 additions & 2 deletions lib/cucumber/wire/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def call_remote(request_handler, message, params)
response = fetch_data_from_socket(@config.timeout(message))
response.handle_with(request_handler)
rescue Timeout::Error => e
backtrace = e.backtrace; backtrace.shift # because Timeout puts some wierd stuff in there
backtrace = e.backtrace
backtrace.shift # because Timeout puts some wierd stuff in there
raise Timeout::Error, "Timed out calling wire server with message '#{message}'", backtrace
end
end
Expand Down Expand Up @@ -59,7 +60,7 @@ def socket
else
@socket = TCPSocket.new(@config.host, @config.port)
end
rescue Errno::ECONNREFUSED => exception
rescue Errno::ECONNREFUSED
raise(ConnectionError, "Unable to contact the wire server at #{@config}. Is it up?")
end
end
Expand Down
7 changes: 4 additions & 3 deletions lib/cucumber/wire/data_packet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ def parse(raw)
attr_reader :message, :params

def initialize(message, params = nil)
@message, @params = message, params
@message = message
@params = params
end

def to_json
def to_json(*_args)
packet = [@message]
packet << @params if @params
JSON.generate(packet)
end

def handle_with(handler)
handler.send("handle_#{@message}", @params)
handler.send(:"handle_#{@message}", @params)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/wire/exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def to_s
end

def initialize(args, config)
super args['message']
super(args['message'])

if args['exception']
self.class.extend(CanSetName)
Expand Down
12 changes: 7 additions & 5 deletions lib/cucumber/wire/request_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ def handle_success(params); end

# Props to Rails
def underscore(camel_cased_word)
camel_cased_word.to_s.gsub(/::/, '/')
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.tr('-', '_')
.downcase
camel_cased_word
.to_s
.gsub('::', '/')
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.tr('-', '_')
.downcase
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/cucumber/wire/step_argument.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class StepArgument
attr_reader :offset

def initialize(offset, val)
@offset, @value = offset, val
@offset = offset
@value = val
end

def value(_current_world)
Expand Down
6 changes: 5 additions & 1 deletion lib/cucumber/wire/step_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ def initialize(connection, data, registry)
@connection = connection
@registry = registry
@id = data['id']
@regexp_source = Regexp.new(data['regexp']) rescue data['regexp'] || 'Unknown'
@regexp_source = begin
Regexp.new(data['regexp'])
rescue StandardError
data['regexp'] || 'Unknown'
end
@expression = registry.create_expression(@regexp_source)
@location = Core::Test::Location.from_file_colon_line(data['source'] || 'unknown:0')
end
Expand Down
Loading
Loading