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

Update RuboCop and introduce RuboCop-RSpec #712

Merged
merged 26 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b72c28e
Auto-update rubocop to 0.84.0
mvz May 31, 2020
5cebecd
Enable new cops from RuboCop 0.83 and 0.84
mvz May 31, 2020
283e5d8
Add rubocop-rspec
mvz May 31, 2020
7b7da74
Autocorrect rubocop-rspec offenses
mvz May 31, 2020
4fd1c64
Regenerate RuboCop TODO file
mvz May 31, 2020
bc61e36
Autocorrect Lint/AmbiguousRegexpLiteral
mvz May 31, 2020
d2dd134
Correct RSpec/ExpectActual offense
mvz May 31, 2020
49284a4
Autocorrect Style/RegexpLiteral
mvz May 31, 2020
a0b9361
Fix Style/NumericPredicate offense
mvz May 31, 2020
fc44042
Correct several Style/MethodMissingSuper offenses
mvz May 31, 2020
233740a
Fix Style/IdenticalConditionalBranches offense
mvz May 31, 2020
d6dee7e
Replace eval with simple case statement
mvz May 31, 2020
858c425
Fix Style/CommentedKeyword offense
mvz May 31, 2020
917cdc3
Correct one Style/AccessModifierDeclarations offense
mvz May 31, 2020
5e739ae
Correct RSpec/VoidExpect offenses
mvz May 31, 2020
a00bf63
Fix RSpec/ScatteredSetup offenses
mvz May 31, 2020
dbe959a
Wrap long line
mvz May 31, 2020
b59d30f
Fix RSpec/RepeatedExampleGroupDescription offenses
mvz May 31, 2020
1d3aaa8
Fix RSpec/RepeatedDescription offense
mvz May 31, 2020
9117a1a
Fix RSpec/VerifiedDoubles offense
mvz May 31, 2020
bab8af3
Fix RSpec/NamedSubject offenses
mvz May 31, 2020
ea0053c
Fix RSpec/MessageSpies offense
mvz May 31, 2020
92d2c96
Fix RSpec/LetSetup offenses
mvz May 31, 2020
3b46baa
Fix RSpec/LeakyConstantDeclaration offenses
mvz May 31, 2020
62766b5
Move old spec setup to where it belongs
mvz May 31, 2020
8da2b6a
Regenerate RuboCop TODO file
mvz May 31, 2020
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
14 changes: 8 additions & 6 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require:
- rubocop-performance
- rubocop-rspec

AllCops:
Exclude:
Expand All @@ -26,9 +27,13 @@ Style/FrozenStringLiteralComment:
Layout/LineLength:
Max: 94

# Enable new cops from RuboCop 0.80, 0.81 and 0.82
# Enable new cops from RuboCop 0.80, 0.81 and 0.84
Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true
Layout/SpaceAroundMethodCallOperator:
Enabled: true
Lint/DeprecatedOpenSSLConstant:
Enabled: true
Lint/RaiseException:
Enabled: true
Lint/StructNewOverride:
Expand All @@ -41,10 +46,7 @@ Style/HashTransformKeys:
Enabled: true
Style/HashTransformValues:
Enabled: true

# We only permit it in this one area which is internal code testing. Never exposed to users
Security/Eval:
Exclude:
- spec/support/helpers/reporting.rb
Style/SlicingWithRange:
Enabled: true

inherit_from: .rubocop_todo.yml
141 changes: 89 additions & 52 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-04-11 14:49:42 +0200 using RuboCop version 0.79.0.
# on 2020-05-31 23:12:24 +0200 using RuboCop version 0.84.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
Expand All @@ -11,34 +11,31 @@ Lint/AmbiguousBlockAssociation:
Exclude:
- 'lib/aruba/platforms/announcer.rb'

# Offense count: 12
Lint/AmbiguousRegexpLiteral:
Exclude:
- 'lib/aruba/cucumber/testing_frameworks.rb'

# Offense count: 2
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'lib/aruba/platforms/announcer.rb'
- 'lib/aruba/platforms/unix_environment_variables.rb'

# Offense count: 27
# Offense count: 26
# Configuration parameters: IgnoredMethods.
Metrics/AbcSize:
Max: 116

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

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

# Offense count: 5
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 12

Expand All @@ -58,6 +55,7 @@ Metrics/ParameterLists:
Max: 8

# Offense count: 5
# Configuration parameters: IgnoredMethods.
Metrics/PerceivedComplexity:
Max: 13

Expand All @@ -80,14 +78,13 @@ Naming/MemoizedInstanceVariableName:
Exclude:
- 'lib/aruba/api/core.rb'

# Offense count: 16
# Offense count: 14
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at, ip, db, os
# AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp
Naming/MethodParameterName:
Exclude:
- 'lib/aruba/aruba_path.rb'
- 'lib/aruba/config_wrapper.rb'
- 'lib/aruba/matchers/base/object_formatter.rb'
- 'lib/aruba/platforms/announcer.rb'
- 'lib/aruba/platforms/aruba_logger.rb'
- 'lib/aruba/platforms/unix_platform.rb'
Expand All @@ -98,30 +95,101 @@ Performance/Caller:
Exclude:
- 'lib/aruba/platforms/unix_platform.rb'

# Offense count: 51
# Configuration parameters: Prefixes.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/aruba/api/filesystem_spec.rb'
- 'spec/aruba/api/runtime_spec.rb'
- 'spec/aruba/api_spec.rb'
- 'spec/aruba/matchers/command_spec.rb'
- 'spec/aruba/matchers/file_spec.rb'
- 'spec/aruba/matchers/path_spec.rb'
- 'spec/aruba/platform/windows_environment_variables_spec.rb'
- 'spec/support/shared_contexts/aruba.rb'

# Offense count: 10
RSpec/DescribeClass:
Exclude:
- 'spec/aruba/api/runtime_spec.rb'
- 'spec/aruba/jruby_spec.rb'
- 'spec/aruba/matchers/collection_spec.rb'
- 'spec/aruba/matchers/command/have_output_size_spec.rb'
- 'spec/aruba/matchers/command_spec.rb'
- 'spec/aruba/matchers/directory_spec.rb'
- 'spec/aruba/matchers/file_spec.rb'
- 'spec/aruba/matchers/path_spec.rb'
- 'spec/aruba/platform/simple_table_spec.rb'
- 'spec/aruba/rspec_spec.rb'

# Offense count: 19
# Configuration parameters: Max.
RSpec/ExampleLength:
Exclude:
- 'spec/aruba/api/core_spec.rb'
- 'spec/aruba/api/filesystem_spec.rb'
- 'spec/aruba/aruba_path_spec.rb'
- 'spec/aruba/matchers/collection_spec.rb'

# Offense count: 4
# Configuration parameters: CustomTransform, IgnoreMethods.
RSpec/FilePath:
Exclude:
- 'spec/aruba/platform/windows_environment_variables_spec.rb'
- 'spec/aruba/platforms/command_monitor_spec.rb'
- 'spec/event_bus/name_resolver_spec.rb'
- 'spec/event_bus_spec.rb'

# Offense count: 298
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Exclude:
- 'spec/aruba/api/bundler_spec.rb'
- 'spec/aruba/api/commands_spec.rb'
- 'spec/aruba/api/core_spec.rb'
- 'spec/aruba/api/filesystem_spec.rb'
- 'spec/aruba/api_spec.rb'
- 'spec/aruba/matchers/command/have_output_size_spec.rb'
- 'spec/aruba/matchers/command_spec.rb'
- 'spec/aruba/matchers/directory_spec.rb'
- 'spec/aruba/matchers/file_spec.rb'
- 'spec/aruba/matchers/path_spec.rb'
- 'spec/aruba/processes/in_process_spec.rb'
- 'spec/event_bus_spec.rb'
- 'spec/support/shared_contexts/aruba.rb'

# Offense count: 32
RSpec/MultipleExpectations:
Max: 5

# Offense count: 187
RSpec/NestedGroups:
Max: 6

# Offense count: 1
RSpec/UnspecifiedException:
Exclude:
- 'spec/aruba/runtime_spec.rb'

# Offense count: 2
Security/Open:
Exclude:
- 'lib/aruba/processes/spawn_process.rb'

# Offense count: 3
# Configuration parameters: EnforcedStyle.
# Offense count: 1
# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols.
# SupportedStyles: inline, group
Style/AccessModifierDeclarations:
Exclude:
- 'lib/aruba/in_config_wrapper.rb'
- 'lib/aruba/matchers/base/base_matcher.rb'
- 'lib/aruba/matchers/collection/all.rb'

# Offense count: 3
# Configuration parameters: AllowOnConstant.
Style/CaseEquality:
Exclude:
- 'lib/aruba/matchers/base/object_formatter.rb'

# Offense count: 1
Style/CommentedKeyword:
Exclude:
- 'spec/aruba/api_spec.rb'

# Offense count: 12
Style/Documentation:
Exclude:
Expand All @@ -136,44 +204,13 @@ Style/Documentation:
- 'lib/aruba/setup.rb'
- 'lib/aruba/tasks/docker_helpers.rb'

# Offense count: 1
Style/EvalWithLocation:
Exclude:
- 'spec/support/helpers/reporting.rb'

# Offense count: 83
# Configuration parameters: EnforcedStyle.
# SupportedStyles: annotated, template, unannotated
Style/FormatStringToken:
Enabled: false

# Offense count: 2
Style/IdenticalConditionalBranches:
Exclude:
- 'lib/aruba/hooks.rb'

# Offense count: 5
Style/MethodMissingSuper:
Exclude:
- 'lib/aruba/config_wrapper.rb'
- 'lib/aruba/in_config_wrapper.rb'
- 'lib/aruba/platforms/command_monitor.rb'
- 'lib/aruba/tasks/docker_helpers.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
- 'lib/aruba/contracts/is_power_of_two.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
# SupportedStyles: slashes, percent_r, mixed
Style/RegexpLiteral:
Exclude:
- 'lib/aruba/cucumber/command.rb'
- 'lib/aruba/cucumber/file.rb'
3 changes: 2 additions & 1 deletion aruba.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'pry-doc', '~> 1.0'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3.6'
spec.add_development_dependency 'rubocop', '~> 0.82.0'
spec.add_development_dependency 'rubocop', '~> 0.84.0'
spec.add_development_dependency 'rubocop-performance', '~> 1.5'
spec.add_development_dependency 'rubocop-rspec', '~> 1.39'
spec.add_development_dependency 'simplecov', '~> 0.18.0'
spec.add_development_dependency 'yard-junk', '~> 0.0.7'

Expand Down
4 changes: 3 additions & 1 deletion lib/aruba/config_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def initialize(config, event_bus)
def method_missing(name, *args, &block)
notify(name, args) if name.to_s.end_with?('=')

config.send(name, *args, &block)
return config.send(name, *args, &block) if config.respond_to? name

super
end

# Pass on respond_to?-calls
Expand Down
2 changes: 1 addition & 1 deletion lib/aruba/contracts/is_power_of_two.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class IsPowerOfTwo
def self.valid?(value)
# explanation for algorithm can be found here:
# http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/
value != 0 && (value & (value - 1)) == 0 ? true : false
value.positive? && (value & (value - 1)).zero?
rescue StandardError
false
end
Expand Down
2 changes: 1 addition & 1 deletion lib/aruba/cucumber/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
# you don't need regex, use "the output should contain" instead since
# that way, you don't have to escape regex characters that
# appear naturally in the output
Then(/^the output should( not)? match \/([^\/]*)\/$/) do |negated, expected|
Then(%r{^the output should( not)? match /([^/]*)/$}) do |negated, expected|
if negated
expect(all_commands)
.not_to include_an_object have_output an_output_string_matching(expected)
Expand Down
2 changes: 1 addition & 1 deletion lib/aruba/cucumber/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
end
end

Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match \/([^\/]*)\/$/) \
Then(%r{^(?:a|the) file(?: named)? "([^"]*)" should (not )?match /([^/]*)/$}) \
do |file, negated, content|
if negated
expect(file).not_to have_file_content file_content_matching(content)
Expand Down
Loading