Skip to content

Commit

Permalink
Merge pull request #21 from bastelfreak/rubocop
Browse files Browse the repository at this point in the history
switch to voxpupuli-rubocop
  • Loading branch information
bastelfreak authored Sep 22, 2023
2 parents 5ec9126 + b96338a commit 632dcbb
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 50 deletions.
23 changes: 3 additions & 20 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
---
require:
- rubocop-rake
- rubocop-rspec
AllCops:
TargetRubyVersion: 2.7
NewCops: enable
inherit_from: .rubocop_todo.yml

Gemspec/RequireMFA:
Enabled: false

Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: comma

Layout/LineLength:
Max: 150

Metrics/AbcSize:
Enabled: false

Metrics/MethodLength:
Enabled: false
inherit_gem:
voxpupuli-rubocop: rubocop.yml
20 changes: 20 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-09-22 08:48:45 UTC using RuboCop version 1.54.2.
# 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
# Configuration parameters: Max.
RSpec/IndexedLet:
Exclude:
- 'spec/beaker/hypervisor/hcloud_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 149
6 changes: 0 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org'

gemspec

gem 'rake'
gem 'rspec'
gem 'rubocop', '~> 1.25.0'
gem 'rubocop-rake', '~> 0.6'
gem 'rubocop-rspec', '~> 2.9'

group :coverage, optional: ENV['COVERAGE'] != 'yes' do
gem 'codecov', require: false
gem 'simplecov-console', require: false
Expand Down
14 changes: 4 additions & 10 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@

require 'rspec/core/rake_task'

require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop) do |task|
# These make the rubocop experience maybe slightly less terrible
task.options = ['-D', '-S', '-E']

# Use Rubocop's Github Actions formatter if possible
if ENV['GITHUB_ACTIONS'] == 'true'
rubocop_spec = Gem::Specification.find_by_name('rubocop')
task.formatters << 'github' if Gem::Version.new(rubocop_spec.version) >= Gem::Version.new('1.2')
end
begin
require 'voxpupuli/rubocop/rake'
rescue LoadError
# the voxpupuli-rubocop gem is optional
end

begin
Expand Down
5 changes: 5 additions & 0 deletions beaker-hcloud.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Gem::Specification.new do |s|

s.required_ruby_version = '>= 2.7'

# Testing dependencies
s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
s.add_development_dependency 'rspec', '~> 3.12'
s.add_development_dependency 'voxpupuli-rubocop', '~> 2.0.0'

s.add_runtime_dependency 'bcrypt_pbkdf', '~> 1.0'
s.add_runtime_dependency 'beaker', '~> 5.4'
s.add_runtime_dependency 'ed25519', '~> 1.2'
Expand Down
4 changes: 2 additions & 2 deletions lib/beaker-hcloud/ssh_data_patches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ module Ed25519PrivateKeyPatch
def openssh(comment: '')
encoded_key = ::SSHData::Encoding.encode_openssh_private_key(
self,
comment
comment,
)
::SSHData::Encoding.encode_pem(
encoded_key,
'OPENSSH PRIVATE KEY'
'OPENSSH PRIVATE KEY',
)
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/beaker/hypervisor/hcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def cleanup
private

def ssh_key_name
safe_hostname = Socket.gethostname.gsub('.', '-')
safe_hostname = Socket.gethostname.tr('.', '-')
[
'Beaker',
ENV.fetch('USER', nil),
Expand All @@ -63,7 +63,7 @@ def create_ssh_key
@logger.notify 'Creating hcloud SSH key'
hcloud_ssh_key = @client.ssh_keys.create(
name: ssh_key_name,
public_key: ssh_key.public_key.openssh(comment: ssh_key_name)
public_key: ssh_key.public_key.openssh(comment: ssh_key_name),
)
@options[:ssh][:hcloud_id] = hcloud_ssh_key.id
hcloud_ssh_key
Expand All @@ -78,7 +78,7 @@ def create_server(host)
location: location,
server_type: server_type,
image: host[:image],
ssh_keys: [ssh_key_name]
ssh_keys: [ssh_key_name],
)
while action.status == 'running'
sleep 5
Expand Down
18 changes: 9 additions & 9 deletions spec/beaker/hypervisor/hcloud_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
.merge(opts.env_vars)
.merge({
logger: logger_double,
timestamp: Time.now
timestamp: Time.now,
})
end
let(:host1_hash) do
{
hypervisor: 'hcloud',
image: 'ubuntu-20.04'
image: 'ubuntu-20.04',
}
end
let(:host2_hash) do
{
hypervisor: 'hcloud',
image: 'custom image',
location: 'custom location',
server_type: 'custom type'
server_type: 'custom type',
}
end
let(:hosts) do
Expand All @@ -42,8 +42,8 @@
public_net: {
'ipv4' => {
'ip' => '192.168.0.1',
'dns_ptr' => 'server1.example.com'
}
'dns_ptr' => 'server1.example.com',
},
},
destroy: true)
end
Expand All @@ -53,8 +53,8 @@
public_net: {
'ipv4' => {
'ip' => '192.168.0.2',
'dns_ptr' => 'server2.example.com'
}
'dns_ptr' => 'server2.example.com',
},
},
destroy: true)
end
Expand Down Expand Up @@ -111,14 +111,14 @@
name: 'Server 1',
location: 'nbg1',
server_type: 'cx11',
image: 'ubuntu-20.04'
image: 'ubuntu-20.04',
}))
expect(servers_double).to have_received(:create)
.with(hash_including({
name: 'Server 2',
location: 'custom location',
server_type: 'custom type',
image: 'custom image'
image: 'custom image',
}))
end
# rubocop:enable RSpec/ExampleLength
Expand Down

0 comments on commit 632dcbb

Please sign in to comment.