Skip to content

Commit

Permalink
Issue vagrant-landrush#216 Apply Rubocop auto corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
hferentschik committed Oct 4, 2016
1 parent ea6c7ca commit 34c7dda
Show file tree
Hide file tree
Showing 26 changed files with 185 additions and 339 deletions.
183 changes: 14 additions & 169 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,40 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-01-18 12:44:48 +0100 using RuboCop version 0.36.0.
# on 2016-10-04 22:36:56 +0200 using RuboCop version 0.38.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: 3
# Cop supports --auto-correct.
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'lib/landrush/action/common.rb'
- 'lib/landrush/config.rb'
- 'test/support/fake_ui.rb'

# Offense count: 8
# Offense count: 12
Metrics/AbcSize:
Max: 36
Exclude:
- 'lib/landrush/command.rb'
- 'lib/landrush/cap/guest/all/read_host_visible_ip_address.rb'
Max: 47

# Offense count: 1
# Offense count: 3
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 250
Max: 218

# Offense count: 2
# Offense count: 3
Metrics/CyclomaticComplexity:
Max: 12

# Offense count: 57
# Offense count: 144
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# URISchemes: http, https
Metrics/LineLength:
Max: 157
Max: 154

# Offense count: 9
# Offense count: 14
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 30
Max: 29

# Offense count: 1
# Offense count: 3
Metrics/PerceivedComplexity:
Max: 14

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: prefer_alias, prefer_alias_method
Style/Alias:
EnforcedStyle: prefer_alias_method

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: percent_q, bare_percent
Style/BarePercentLiterals:
Exclude:
- 'lib/landrush/cap/linux/add_iptables_rule.rb'
- 'lib/landrush/cap/linux/read_host_visible_ip_address.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep, IndentationWidth.
# SupportedStyles: case, end
Style/CaseIndentation:
Enabled: false

Style/ConditionalAssignment:
Exclude:
- 'lib/landrush/server.rb'

# Offense count: 21
# Offense count: 32
Style/Documentation:
Enabled: false

Expand All @@ -84,129 +44,14 @@ Style/DoubleNegation:
- 'lib/landrush/config.rb'
- 'lib/landrush/server.rb'

# Offense count: 4
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/landrush/action/teardown.rb'
- 'lib/landrush/server.rb'
- 'test/support/test_server_daemon.rb'

# Offense count: 13
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
Style/HashSyntax:
Enabled: false

# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Exclude:
- 'lib/landrush/action/common.rb'
- 'lib/landrush/config.rb'
- 'lib/landrush/server.rb'
- 'test/support/test_server_daemon.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
Style/IndentArray:
EnforcedStyle: consistent

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
# SupportedStyles: skip_modifier_ifs, always
Style/Next:
Exclude:
- 'lib/landrush/action/setup.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'landrush.gemspec'
- 'lib/landrush/cap/guest/linux/redirect_dns.rb'
- 'test/landrush/action/setup_test.rb'
- 'test/landrush/store_test.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: lower_case_q, upper_case_q
Style/PercentQLiterals:
Exclude:
- 'lib/landrush/cap/guest/linux/read_host_visible_ip_address.rb'


# Offense count: 7
# Cop supports --auto-correct.
Style/RescueModifier:
Exclude:
- 'lib/landrush/server.rb'
- 'lib/landrush/store.rb'
- 'test/landrush/server_test.rb'

# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceAroundEqualsInParameterDefault:
Enabled: false

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
Style/SpaceInsideBlockBraces:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceInsideHashLiteralBraces:
Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: use_perl_names, use_english_names
Style/SpecialGlobalVars:
Enabled: false

# Offense count: 62
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
# IgnoredMethods: respond_to
Style/SymbolProc:
Exclude:
- 'lib/landrush/cap/guest/linux/read_host_visible_ip_address.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym
Style/TrivialAccessors:
Exclude:
- 'lib/landrush/config.rb'
- 'lib/landrush/server.rb'

# Offense count: 3
# Cop supports --auto-correct.
Style/UnneededPercentQ:
Style/ConditionalAssignment:
Exclude:
- 'landrush.gemspec'
- 'lib/landrush/cap/guest/linux/add_iptables_rule.rb'
- 'lib/landrush/cap/guest/linux/read_host_visible_ip_address.rb'
- 'lib/landrush/server.rb'
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ end

group :development do
gem 'vagrant',
:git => 'git://github.com/mitchellh/vagrant.git',
:ref => 'v1.8.4'
git: 'git://github.com/mitchellh/vagrant.git',
ref: 'v1.8.4'

gem 'rake', '~> 10'
gem 'rubocop', '~> 0.38.0'
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CLEAN.include('build')
task :init do
FileUtils.mkdir_p 'build'
end
task :features => :init
task features: :init

# Default test task
desc 'Run all unit tests'
Expand All @@ -23,7 +23,7 @@ end

# Cucumber acceptance test task
Cucumber::Rake::Task.new(:features)
task :features => :init
task features: :init

task default: [
:rubocop,
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/dns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Then(/^the hostname "([^"]+)" should resolve to "([^"]+)" on the internal DNS server$/) do |host, ip|
port = Landrush::Server.port
resolver = Resolv::DNS.new(:nameserver_port => [['localhost', port]], :search => ['local'], :ndots => 1)
resolver = Resolv::DNS.new(nameserver_port: [['localhost', port]], search: ['local'], ndots: 1)
ip_resolved = resolver.getaddress(host).to_s
expect(ip_resolved).to eq(ip)
end
Expand Down
4 changes: 2 additions & 2 deletions landrush.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ Gem::Specification.new do |spec|
and down, and you can configure static entries to be returned from the
server as well. See the README for more documentation.
DESCRIP
spec.summary = %q{a vagrant plugin providing consistent DNS visible on host and guests}
spec.summary = 'a vagrant plugin providing consistent DNS visible on host and guests'
spec.homepage = 'https://github.com/vagrant-landrush/landrush'
spec.license = 'MIT'

spec.files = `git ls-files`.split($/)
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']
Expand Down
8 changes: 3 additions & 5 deletions lib/landrush/action/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def self.included(base)
base.send :attr_reader, :app, :env
end

def initialize(app, env)
def initialize(app, _env)
@app = app
end

Expand Down Expand Up @@ -47,7 +47,7 @@ def provider
raise "The landrush plugin does not support the #{key} provider yet!"
end

if provider_name == :parallels && Gem::Version.new(VagrantPlugins::Parallels::VERSION) < Gem::Version.new("1.0.3")
if provider_name == :parallels && Gem::Version.new(VagrantPlugins::Parallels::VERSION) < Gem::Version.new('1.0.3')
raise "The landrush plugin supports the Parallels provider v1.0.3 and later. Please, update your 'vagrant-parallels' plugin."
end

Expand All @@ -73,9 +73,7 @@ def machine_hostname
end

def read_machine_hostname
if machine.config.vm.hostname
return machine.config.vm.hostname
end
return machine.config.vm.hostname if machine.config.vm.hostname

"#{Pathname.pwd.basename}.#{config.tld}"
end
Expand Down
16 changes: 7 additions & 9 deletions lib/landrush/action/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,13 @@ def start_server
def setup_static_dns
config.hosts.each do |hostname, dns_value|
dns_value ||= host_ip_address
unless Store.hosts.has?(hostname, dns_value)
info "adding static DNS entry: #{hostname} => #{dns_value}"
Store.hosts.set hostname, dns_value
if ip_address?(dns_value)
reverse_dns = IPAddr.new(dns_value).reverse
info "adding static reverse DNS entry: #{reverse_dns} => #{dns_value}"
Store.hosts.set(reverse_dns, hostname)
end
end
next if Store.hosts.has?(hostname, dns_value)
info "adding static DNS entry: #{hostname} => #{dns_value}"
Store.hosts.set hostname, dns_value
next unless ip_address?(dns_value)
reverse_dns = IPAddr.new(dns_value).reverse
info "adding static reverse DNS entry: #{reverse_dns} => #{dns_value}"
Store.hosts.set(reverse_dns, hostname)
end
end

Expand Down
14 changes: 6 additions & 8 deletions lib/landrush/action/teardown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ def teardown
teardown_machine_dns
DependentVMs.remove(machine_hostname)

if DependentVMs.none?
teardown_static_dns
teardown_server
end
return unless DependentVMs.none?
teardown_static_dns
teardown_server
end

def teardown_machine_dns
if Store.hosts.has? machine_hostname
info "removing machine entry: #{machine_hostname}"
Store.hosts.delete(machine_hostname)
end
return unless Store.hosts.has? machine_hostname
info "removing machine entry: #{machine_hostname}"
Store.hosts.delete(machine_hostname)
end

def teardown_static_dns
Expand Down
2 changes: 1 addition & 1 deletion lib/landrush/cap/guest/linux/add_iptables_rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self._run(machine, command)
machine.communicate.sudo(command) do |data, type|
if [:stderr, :stdout].include?(type)
color = (type == :stdout) ? :green : :red
machine.env.ui.info(data.chomp, :color => color, :prefix => false)
machine.env.ui.info(data.chomp, color: color, prefix: false)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/landrush/cap/guest/linux/redirect_dns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ module Landrush
module Cap
module Linux
module RedirectDns
def self.redirect_dns(machine, target={})
def self.redirect_dns(machine, target = {})
dns_servers = machine.guest.capability(:configured_dns_servers)
%w[tcp udp].each do |proto|
%w(tcp udp).each do |proto|
dns_servers.each do |dns_server|
machine.guest.capability(
:add_iptables_rule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,6 @@ def which(cmd)

# Only run the following code when this file is the main file being run
# instead of having been required or loaded by another file
if __FILE__ == $0
if __FILE__ == $PROGRAM_NAME
Landrush::Cap::Windows::ConfigureVisibilityOnHost.configure_visibility_on_host(nil, ARGV[0], ARGV[1])
end
Loading

0 comments on commit 34c7dda

Please sign in to comment.