Skip to content

Commit

Permalink
Rubocop config and autocorrects (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
kke authored and jakolehm committed Mar 20, 2018
1 parent ca6a2cd commit 0af4fe9
Show file tree
Hide file tree
Showing 46 changed files with 501 additions and 217 deletions.
166 changes: 166 additions & 0 deletions .rubocop.relaxed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# Relaxed.Ruby.Style
## Version 2.2

Style/Alias:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylealias

Style/AsciiComments:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styleasciicomments

Style/BeginBlock:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylebeginblock

Style/BlockDelimiters:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters

Style/CommentAnnotation:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylecommentannotation

Style/Documentation:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styledocumentation

Layout/DotPosition:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#layoutdotposition

Style/DoubleNegation:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styledoublenegation

Style/EndBlock:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styleendblock

Style/FormatString:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styleformatstring

Style/IfUnlessModifier:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier

Style/Lambda:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylelambda

Style/ModuleFunction:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylemodulefunction

Style/MultilineBlockChain:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain

Style/NegatedIf:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylenegatedif

Style/NegatedWhile:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile

Style/ParallelAssignment:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styleparallelassignment

Style/PercentLiteralDelimiters:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters

Style/PerlBackrefs:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styleperlbackrefs

Style/Semicolon:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylesemicolon

Style/SignalException:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylesignalexception

Style/SingleLineBlockParams:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylesinglelineblockparams

Style/SingleLineMethods:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods

Layout/SpaceBeforeBlockBraces:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#layoutspacebeforeblockbraces

Layout/SpaceInsideParens:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#layoutspaceinsideparens

Style/SpecialGlobalVars:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylespecialglobalvars

Style/StringLiterals:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylestringliterals

# Style/TrailingCommaInArguments:
# Enabled: false
# StyleGuide: http://relaxed.ruby.style/#styletrailingcommainarguments
#
# Style/TrailingCommaInArrayLiteral:
# Enabled: false
# StyleGuide: http://relaxed.ruby.style/#styletrailingcommainarrayliteral
#
# Style/TrailingCommaInHashLiteral:
# Enabled: false
# StyleGuide: http://relaxed.ruby.style/#styletrailingcommainhashliteral

Style/WhileUntilModifier:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylewhileuntilmodifier

Style/WordArray:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylewordarray

Lint/AmbiguousRegexpLiteral:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral

Lint/AssignmentInCondition:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition

Metrics/AbcSize:
Enabled: false

Metrics/BlockNesting:
Enabled: false

Metrics/ClassLength:
Enabled: false

Metrics/ModuleLength:
Enabled: false

Metrics/CyclomaticComplexity:
Enabled: false

Metrics/LineLength:
Enabled: false

Metrics/MethodLength:
Enabled: false

Metrics/ParameterLists:
Enabled: false

Metrics/PerceivedComplexity:
Enabled: false

49 changes: 49 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
inherit_from: .rubocop.relaxed.yml

AllCops:
Exclude:
- spec/**/*
- Gemfile
- "*.gemspec"
TargetRubyVersion: 2.4

Style/PercentLiteralDelimiters:
PreferredDelimiters:
default: ()
'%i': '()'
'%I': '()'
'%r': '{}'
'%w': '()'
'%W': '()'

Style/FormatString:
EnforcedStyle: percent

Style/FrozenStringLiteralComment:
EnforcedStyle: always

Style/WordArray:
Enabled: true
MinSize: 3

Style/SymbolArray:
Enabled: true
MinSize: 3

Gemspec/OrderedDependencies:
Enabled: false

Style/PerlBackrefs:
Enabled: true

Layout/SpaceInsideParens:
Enabled: true

Style/SpecialGlobalVars:
Enabled: true

Style/Alias:
Enabled: true

Style/BeginBlock:
Enabled: true
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
task :default => :spec
task default: :spec
4 changes: 2 additions & 2 deletions bin/kupo
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

# add lib to libpath (only needed when running from the sources)
require 'pathname'
lib_path = File.expand_path('../../lib', Pathname.new(__FILE__).realpath)
$:.unshift lib_path unless $:.include?(lib_path)
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)

STDOUT.sync = true

Expand Down
4 changes: 3 additions & 1 deletion examples/vagrant/Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# -*- mode: ruby -*-
# vi: set ft=ruby :

Expand Down Expand Up @@ -31,7 +33,7 @@ Vagrant.configure("2") do |config|
vb.memory = "2048"
vb.cpus = 1
end
host.vm.network "private_network", ip: "192.168.100.#{i+100}"
host.vm.network "private_network", ip: "192.168.100.#{i + 100}"
end
end
end
1 change: 1 addition & 0 deletions kupo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
spec.bindir = "bin"
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.required_ruby_version = '~> 2.4'

spec.add_runtime_dependency "clamp", "1.2.1"
spec.add_runtime_dependency "pastel"
Expand Down
3 changes: 2 additions & 1 deletion lib/kupo.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "clamp"
require_relative "kupo/autoload"
require_relative "kupo/version"
Expand All @@ -6,5 +8,4 @@
require_relative "kupo/root_command"

module Kupo

end
23 changes: 15 additions & 8 deletions lib/kupo/addon.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'dry-validation'
require_relative 'addons/struct'
require_relative 'phases/logging'
Expand Down Expand Up @@ -92,18 +94,23 @@ def uninstall
end

def apply_stack(vars = {})
Kupo::Kube.apply_stack(host.address, self.class.name, vars.merge({
name: self.class.name, version: self.class.version, config: config,
arch: host.cpu_arch
}))
end

def apply_resource(resource)
Kupo::Kube.apply_stack(
host.address, self.class.name,
vars.merge(
name: self.class.name,
version: self.class.version,
config: config,
arch: host.cpu_arch
)
)
end

def apply_resource
Kupo::Kube.apply_resource(host.address)
end

def prune_stack
Kupo::Kube.prune_stack(host.address, self.class.name, '-')
end
end
end
end
6 changes: 4 additions & 2 deletions lib/kupo/addon_manager.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative 'addon'
require_relative 'phases/logging'

Expand Down Expand Up @@ -27,7 +29,7 @@ def validate(configs)
# @param configs [Hash]
def apply(host, configs)
with_enabled_addons(configs) do |addon_class, config|
self.logger.info { "Applying addon #{addon_class.name} ..." }
logger.info { "Applying addon #{addon_class.name} ..." }
schema = addon_class.validate(config)
addon = addon_class.new(host, schema)
addon.install
Expand Down Expand Up @@ -73,4 +75,4 @@ def load_addons(dirs)
end
end
end
end
end
5 changes: 3 additions & 2 deletions lib/kupo/addons/cert_manager.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

module Kupo
module Addons
class CertManager < Kupo::Addon

name 'cert-manager'
version '0.2.3'
license 'Apache License 2.0'
Expand All @@ -25,4 +26,4 @@ class Issuer < Kupo::Addons::Struct
}
end
end
end
end
9 changes: 5 additions & 4 deletions lib/kupo/addons/host_upgrades.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

module Kupo
module Addons
class HostUpgrades < Kupo::Addon

name 'host-upgrades'
version '0.1.0'
license 'Apache License 2.0'
Expand All @@ -15,10 +16,10 @@ class HostUpgrades < Kupo::Addon
}

def install
apply_stack({
apply_stack(
interval: duration.parse(config.interval).to_sec
})
)
end
end
end
end
end
7 changes: 4 additions & 3 deletions lib/kupo/addons/ingress_nginx.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

module Kupo
module Addons
class IngressNginx < Kupo::Addon

name 'ingress-nginx'
version '0.11.0'
license 'Apache License 2.0'
Expand All @@ -17,10 +18,10 @@ class IngressNginx < Kupo::Addon
}

def install
apply_stack({
apply_stack(
configmap: config.configmap || {},
node_selector: config.node_selector
})
)
end
end
end
Expand Down
Loading

0 comments on commit 0af4fe9

Please sign in to comment.