Skip to content

Commit

Permalink
Merge pull request #710 from cucumber/even-more-rubocop-cleanups
Browse files Browse the repository at this point in the history
Even more RuboCop cleanups
  • Loading branch information
mvz authored Apr 12, 2020
2 parents 5caa1f8 + 975a2c1 commit 39e1135
Show file tree
Hide file tree
Showing 74 changed files with 566 additions and 422 deletions.
14 changes: 6 additions & 8 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%w': ()

# SupportedStyles: percent, brackets
Style/SymbolArray:
EnforcedStyle: brackets

# Code is currently broken with frozen string literal comments applied.
# TODO: Enable and fix build
Style/FrozenStringLiteralComment:
Enabled: false

# TODO: This is placed in here so the auto-gen-config doesn't destroy these.
# Most of these need to be manually tackled, the LineLength value currently is good enough to stop most of
# these leaking through into the codebase
# Offense count: 375+
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
# Be relatively lenient with line length
Layout/LineLength:
Max: 140
Max: 94

# We only permit it in this one area which is internal code testing. Never exposed to users
Security/Eval:
Expand Down
128 changes: 9 additions & 119 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-04-11 12:33:09 +0200 using RuboCop version 0.79.0.
# on 2020-04-11 14:49:42 +0200 using RuboCop version 0.79.0.
# 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: 2
# Cop supports --auto-correct.
# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
Layout/EmptyLineBetweenDefs:
Exclude:
- 'lib/aruba/api/core.rb'

# Offense count: 2
# Cop supports --auto-correct.
Layout/EmptyLines:
Exclude:
- 'lib/aruba/api/core.rb'

# Offense count: 7
Lint/AmbiguousBlockAssociation:
Exclude:
Expand All @@ -40,30 +27,30 @@ Lint/Void:
Metrics/AbcSize:
Max: 116

# Offense count: 74
# Offense count: 75
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 593
Max: 604

# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 153
Max: 158

# Offense count: 5
Metrics/CyclomaticComplexity:
Max: 12

# Offense count: 27
# Offense count: 28
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 47
Max: 59

# Offense count: 2
# Offense count: 3
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 171
Max: 182

# Offense count: 3
# Configuration parameters: CountKeywordArgs.
Expand Down Expand Up @@ -106,17 +93,6 @@ Naming/MethodParameterName:
- 'lib/aruba/platforms/unix_platform.rb'
- 'lib/aruba/tasks/docker_helpers.rb'

# Offense count: 1
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
# NamePrefix: is_, has_, have_
# ForbiddenPrefixes: is_, has_, have_
# AllowedMethods: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicateName:
Exclude:
- 'spec/**/*'
- 'lib/aruba/matchers/base/base_matcher.rb'

# Offense count: 1
Performance/Caller:
Exclude:
Expand All @@ -141,20 +117,6 @@ Style/CaseEquality:
Exclude:
- 'lib/aruba/matchers/base/object_formatter.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/CharacterLiteral:
Exclude:
- 'spec/support/shared_contexts/aruba.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: is_a?, kind_of?
Style/ClassCheck:
Exclude:
- 'lib/aruba/api/filesystem.rb'

# Offense count: 1
Style/CommentedKeyword:
Exclude:
Expand All @@ -179,7 +141,7 @@ Style/EvalWithLocation:
Exclude:
- 'spec/support/helpers/reporting.rb'

# Offense count: 84
# Offense count: 83
# Configuration parameters: EnforcedStyle.
# SupportedStyles: annotated, template, unannotated
Style/FormatStringToken:
Expand All @@ -190,24 +152,6 @@ Style/IdenticalConditionalBranches:
Exclude:
- 'lib/aruba/hooks.rb'

# Offense count: 7
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Exclude:
- 'lib/aruba/cucumber/command.rb'
- 'lib/aruba/matchers/collection/include_an_object.rb'
- 'lib/aruba/platforms/unix_environment_variables.rb'
- 'lib/aruba/setup.rb'
- 'spec/aruba/platform/windows_environment_variables_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: line_count_dependent, lambda, literal
Style/Lambda:
Exclude:
- 'spec/aruba/hooks_spec.rb'

# Offense count: 5
Style/MethodMissingSuper:
Exclude:
Expand All @@ -216,14 +160,6 @@ Style/MethodMissingSuper:
- 'lib/aruba/platforms/command_monitor.rb'
- 'lib/aruba/tasks/docker_helpers.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: AllowedMethods.
# AllowedMethods: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with
Style/NestedParenthesizedCalls:
Exclude:
- 'spec/aruba/matchers/collection_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
Expand All @@ -233,14 +169,6 @@ Style/NumericPredicate:
- 'spec/**/*'
- 'lib/aruba/contracts/is_power_of_two.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'Rakefile'
- 'lib/aruba/api/bundler.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
Expand All @@ -249,41 +177,3 @@ Style/RegexpLiteral:
Exclude:
- 'lib/aruba/cucumber/command.rb'
- 'lib/aruba/cucumber/file.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, explicit
Style/RescueStandardError:
Exclude:
- 'lib/aruba/contracts/absolute_path.rb'
- 'lib/aruba/contracts/is_power_of_two.rb'
- 'lib/aruba/contracts/relative_path.rb'
- 'lib/aruba/event_bus/name_resolver.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowAsExpressionSeparator.
Style/Semicolon:
Exclude:
- 'lib/aruba/platforms/aruba_fixed_size_file_creator.rb'

# Offense count: 35
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: only_raise, only_fail, semantic
Style/SignalException:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/StderrPuts:
Exclude:
- 'lib/aruba/initializer.rb'

# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: MinSize.
# SupportedStyles: percent, brackets
Style/SymbolArray:
EnforcedStyle: brackets
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ source 'https://rubygems.org'
gemspec

# Load local Gemfile
load File.expand_path('Gemfile.local', __dir__) if File.file? File.expand_path('Gemfile.local', __dir__)
if File.file? File.expand_path('Gemfile.local', __dir__)
load File.expand_path('Gemfile.local', __dir__)
end

unless RUBY_PLATFORM.include?('java')
gem 'byebug', '~> 11.0'
Expand Down
10 changes: 6 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ require 'cucumber/rake/task'
require 'rspec/core/rake_task'

Cucumber::Rake::Task.new do |t|
t.cucumber_opts = %w{--format progress}
t.cucumber_opts = %w(--format progress)
end

Cucumber::Rake::Task.new('cucumber:wip', 'Run Cucumber features '\
'which are "WORK IN PROGRESS" and '\
'are allowed to fail') do |t|
t.cucumber_opts = %w{--format progress}
t.cucumber_opts = %w(--format progress)
t.profile = 'wip'
end

Expand Down Expand Up @@ -53,7 +53,8 @@ namespace :docker do
args.with_defaults(version: 'latest')
args.with_defaults(cache: true)

docker_compose_file = Aruba::DockerComposeFile.new(File.expand_path('docker-compose.yml', __dir__))
docker_compose_file =
Aruba::DockerComposeFile.new(File.expand_path('docker-compose.yml', __dir__))
docker_run_instance = Aruba::DockerRunInstance.new(docker_compose_file, :base)

builder = Aruba::DockerBuildCommandLineBuilder.new(
Expand All @@ -67,7 +68,8 @@ namespace :docker do

desc 'Run docker container'
task :run, :command do |_, args|
docker_compose_file = Aruba::DockerComposeFile.new(File.expand_path('docker-compose.yml', __dir__))
docker_compose_file =
Aruba::DockerComposeFile.new(File.expand_path('docker-compose.yml', __dir__))
docker_run_instance = Aruba::DockerRunInstance.new(docker_compose_file, :base)

builder = Aruba::DockerRunCommandLineBuilder.new(
Expand Down
6 changes: 4 additions & 2 deletions aruba.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ Gem::Specification.new do |spec|
spec.name = 'aruba'
spec.version = Aruba::VERSION
spec.author = 'Aslak Hellesøy, Matt Wynne and other Aruba Contributors'
spec.description = 'Extension for popular TDD and BDD frameworks like "Cucumber", "RSpec" and "Minitest",
to make testing commandline applications meaningful, easy and fun.'
spec.description = <<~TEXT
Extension for popular TDD and BDD frameworks like "Cucumber", "RSpec" and "Minitest",
to make testing commandline applications meaningful, easy and fun.
TEXT
spec.summary = "aruba-#{spec.version}"
spec.license = 'MIT'
spec.email = 'cukes@googlegroups.com'
Expand Down
11 changes: 7 additions & 4 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@

command_name = "#{scenario.feature.name} #{scenario.name}"

# Used in simplecov_setup so that each scenario has a different name and their coverage results are merged instead
# of overwriting each other as 'Cucumber Features'
# Used in simplecov_setup so that each scenario has a different name and
# their coverage results are merged instead of overwriting each other as
# 'Cucumber Features'
ENV['SIMPLECOV_COMMAND_NAME'] = command_name.to_s

simplecov_setup_pathname = Pathname.new(__FILE__).expand_path.parent.join('simplecov_setup')
simplecov_setup_pathname =
Pathname.new(__FILE__).expand_path.parent.join('simplecov_setup')

# set environment variable so child processes will merge their coverage data with parent process's coverage data.
# set environment variable so child processes will merge their coverage data
# with parent process's coverage data.
ENV['RUBYOPT'] = "-r#{simplecov_setup_pathname} #{ENV['RUBYOPT']}"
end
3 changes: 2 additions & 1 deletion fixtures/cli-app/cli-app.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Gem::Specification.new do |spec|
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
# delete this section to allow pushing this gem to any host.

spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.files = `git ls-files -z`.split("\x0")
.reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
Expand Down
3 changes: 2 additions & 1 deletion fixtures/cli-app/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

require_relative 'support/aruba'

::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__))
.each { |f| require_relative f }
3 changes: 2 additions & 1 deletion fixtures/empty-app/cli-app.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Gem::Specification.new do |spec|
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
# delete this section to allow pushing this gem to any host.

spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.files = `git ls-files -z`.split("\x0")
.reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
Expand Down
2 changes: 1 addition & 1 deletion lib/aruba/api/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Bundler

# Unset variables used by bundler
def unset_bundler_env_vars
%w[RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE].each do |key|
%w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE).each do |key|
delete_environment_variable(key)
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/aruba/api/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ def close_input
private

def prepare_command(cmd, opts)
exit_timeout = opts[:exit_timeout].nil? ? aruba.config.exit_timeout : opts[:exit_timeout]
io_wait_timeout = opts[:io_wait_timeout].nil? ? aruba.config.io_wait_timeout : opts[:io_wait_timeout]
stop_signal = opts[:stop_signal].nil? ? aruba.config.stop_signal : opts[:stop_signal]
startup_wait_time = opts[:startup_wait_time].nil? ? aruba.config.startup_wait_time : opts[:startup_wait_time]
exit_timeout = opts[:exit_timeout] || aruba.config.exit_timeout
io_wait_timeout = opts[:io_wait_timeout] || aruba.config.io_wait_timeout
stop_signal = opts[:stop_signal] || aruba.config.stop_signal
startup_wait_time = opts[:startup_wait_time] || aruba.config.startup_wait_time

cmd = replace_variables(cmd)

Expand Down
Loading

0 comments on commit 39e1135

Please sign in to comment.