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
164 changes: 2 additions & 162 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,13 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-11-15 15:51:35 UTC using RuboCop version 1.44.1.
# on 2023-12-21 16:12:21 UTC using RuboCop version 1.44.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

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
# Include: **/*.gemspec
Gemspec/OrderedDependencies:
Exclude:
- 'cucumber-wire.gemspec'

# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: leading, trailing
Layout/DotPosition:
Exclude:
- 'lib/cucumber/wire/add_hooks_filter.rb'
- 'lib/cucumber/wire/request_handler.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/ElseAlignment:
Exclude:
- 'lib/cucumber/wire/exception.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleAlignWith, Severity.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Layout/EndAlignment:
Exclude:
- 'lib/cucumber/wire/exception.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Width, AllowedPatterns, IgnoredPatterns.
Layout/IndentationWidth:
Exclude:
- 'lib/cucumber/wire/exception.rb'
# TODO: Nov '23 -> 25 files inspected, 53 offenses detected, 28 offenses autocorrectable

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
Expand All @@ -54,27 +17,6 @@ Layout/MultilineMethodCallIndentation:
Exclude:
- 'lib/cucumber/wire/request_handler.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Layout/SpaceAfterComma:
Exclude:
- 'lib/cucumber/wire/request_handler.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
# SupportedStyles: space, no_space, compact
# SupportedStylesForEmptyBrackets: space, no_space
Layout/SpaceInsideArrayLiteralBrackets:
Exclude:
- 'features/support/fake_wire_server.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
Lint/AmbiguousRegexpLiteral:
Exclude:
- 'features/step_definitions/wire_steps.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowSafeAssignment.
Expand All @@ -101,13 +43,6 @@ Lint/ToJSON:
Exclude:
- 'lib/cucumber/wire/data_packet.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'lib/cucumber/wire/snippet.rb'

# Offense count: 1
Lint/UselessAssignment:
Exclude:
Expand Down Expand Up @@ -141,16 +76,6 @@ Performance/RegexpMatch:
Exclude:
- 'lib/cucumber/wire/configuration.rb'

# Offense count: 8
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SkipBlocks, EnforcedStyle.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Exclude:
- 'spec/cucumber/wire/configuration_spec.rb'
- 'spec/cucumber/wire/connections_spec.rb'
- 'spec/cucumber/wire/data_packet_spec.rb'

# Offense count: 3
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Expand Down Expand Up @@ -190,14 +115,6 @@ Security/YAMLLoad:
Exclude:
- 'lib/cucumber/wire/configuration.rb'

# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: prefer_alias, prefer_alias_method
Style/Alias:
Exclude:
- 'lib/cucumber/wire/protocol/requests.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
Expand All @@ -222,34 +139,6 @@ Style/ConditionalAssignment:
Exclude:
- 'lib/cucumber/wire/connection.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: compact, expanded
Style/EmptyMethod:
Exclude:
- 'lib/cucumber/wire/request_handler.rb'

# Offense count: 24
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
Style/GuardClause:
Exclude:
- 'lib/cucumber/wire/exception.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'Gemfile'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
Expand All @@ -266,12 +155,6 @@ Style/MutableConstant:
Exclude:
- 'lib/cucumber/wire/configuration.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Strict, AllowedNumbers, AllowedPatterns.
Style/NumericLiterals:
MinDigits: 6

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
Style/ParallelAssignment:
Expand All @@ -280,34 +163,6 @@ Style/ParallelAssignment:
- 'lib/cucumber/wire/data_packet.rb'
- 'lib/cucumber/wire/step_argument.rb'

# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'spec/cucumber/wire/configuration_spec.rb'
- 'spec/cucumber/wire/connection_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantBegin:
Exclude:
- 'features/support/fake_wire_server.rb'

# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantPercentQ:
Exclude:
- 'spec/cucumber/wire/configuration_spec.rb'
- 'spec/cucumber/wire/connection_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Exclude:
- 'lib/cucumber/wire/configuration.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RescueModifier:
Expand Down Expand Up @@ -335,18 +190,3 @@ Style/Semicolon:
Style/StringConcatenation:
Exclude:
- 'features/support/fake_wire_server.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinSize.
# SupportedStyles: percent, brackets
Style/SymbolArray:
EnforcedStyle: brackets

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: WordRegex.
# SupportedStyles: percent, brackets
Style/WordArray:
EnforcedStyle: percent
MinSize: 4
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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))
- 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))

### Changed

Expand Down
10 changes: 4 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec

if ENV['CUCUMBER_RUBY_CORE']
gem 'cucumber-core', path: ENV['CUCUMBER_RUBY_CORE']
end
gem 'cucumber-core', path: ENV['CUCUMBER_RUBY_CORE'] if ENV['CUCUMBER_RUBY_CORE']

if ENV['CUCUMBER_RUBY']
gem 'cucumber', path: ENV['CUCUMBER_RUBY']
end
gem 'cucumber', path: ENV['CUCUMBER_RUBY'] if ENV['CUCUMBER_RUBY']
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

require 'rubygems'
require 'bundler'
Bundler::GemHelper.install_tasks

task default: [:unit_tests, :acceptance_tests]
task default: %i[unit_tests acceptance_tests]

task :unit_tests do
sh 'bundle exec rspec'
Expand Down
2 changes: 2 additions & 0 deletions cucumber-wire.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path('lib', __dir__)

Gem::Specification.new do |s|
Expand Down
2 changes: 2 additions & 0 deletions features/step_definitions/aruba_steps.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# frozen_string_literal: true

require 'aruba/cucumber'
8 changes: 5 additions & 3 deletions features/step_definitions/wire_steps.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Given /^there is a wire server (running |)on port (\d+) which understands the following protocol:$/ do |running, port, table|
# frozen_string_literal: true

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
Expand All @@ -8,12 +10,12 @@
start_wire_server if running.strip == 'running'
end

Given /^the wire server takes (.*) seconds to respond to the invoke message$/ do |timeout|
Given(/^the wire server takes (.*) seconds to respond to the invoke message$/) do |timeout|
@server.delay_response(:invoke, timeout.to_f)
start_wire_server
end

Given /^I have environment variable (\w+) set to "([^"]*)"$/ do |variable, value|
Given(/^I have environment variable (\w+) set to "([^"]*)"$/) do |variable, value|
set_environment_variable(variable, value)
end

Expand Down
20 changes: 10 additions & 10 deletions features/support/fake_wire_server.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'json'
require 'socket'

Expand All @@ -23,14 +25,12 @@ def handle_connections(io)
end

def open_session_on(socket, io)
begin
on_message = lambda { |message| io.puts message }
SocketSession.new(socket, @protocol_table, @delays, on_message).start
rescue Exception => e
raise e
ensure
socket.close
end
on_message = lambda { |message| io.puts message }
SocketSession.new(socket, @protocol_table, @delays, on_message).start
rescue Exception => e
raise e
ensure
socket.close
end

class SocketSession
Expand All @@ -56,10 +56,10 @@ def handle(data)
send_response(protocol_entry['response'])
else
serialized_exception = { message: "Not understood: #{data}", backtrace: [] }
send_response(['fail', serialized_exception ].to_json)
send_response(['fail', serialized_exception].to_json)
end
rescue => e
send_response(['fail', { message: e.message, backtrace: e.backtrace, exception: e.class } ].to_json)
send_response(['fail', { message: e.message, backtrace: e.backtrace, exception: e.class }].to_json)
end

def response_to(data)
Expand Down
2 changes: 2 additions & 0 deletions lib/cucumber/wire.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'cucumber/wire/plugin'

return unless respond_to?(:InstallPlugin)
Expand Down
8 changes: 5 additions & 3 deletions lib/cucumber/wire/add_hooks_filter.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# frozen_string_literal: true

module Cucumber
module Wire
class AddHooksFilter < Core::Filter.new(:connections)
def test_case(test_case)
test_case.
with_steps([before_hook(test_case)] + test_case.test_steps + [after_hook(test_case)]).
describe_to receiver
test_case
.with_steps([before_hook(test_case)] + test_case.test_steps + [after_hook(test_case)])
.describe_to receiver
end

def before_hook(test_case)
Expand Down
4 changes: 3 additions & 1 deletion lib/cucumber/wire/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'yaml'
require 'erb'

Expand All @@ -19,7 +21,7 @@ def initialize(args)
end

def timeout(message = nil)
return @timeouts[message.to_s] || 3
@timeouts[message.to_s] || 3
end

def to_s
Expand Down
2 changes: 2 additions & 0 deletions lib/cucumber/wire/connection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'timeout'
require 'cucumber/wire/protocol'
require 'cucumber/wire/exception'
Expand Down
2 changes: 2 additions & 0 deletions lib/cucumber/wire/connections.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'json'
require 'socket'
require 'cucumber/wire/connection'
Expand Down
2 changes: 2 additions & 0 deletions lib/cucumber/wire/data_packet.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'json'

module Cucumber
Expand Down
Loading