Skip to content

Commit

Permalink
Fix lint issues on master (#379)
Browse files Browse the repository at this point in the history
* bundle exec rubocop --auto-correct

* Lintfix: don't complain about the filename of the file named after the gem by convention

* Appease the linter by using the method-level syntax for rescuing exceptions from a block
  • Loading branch information
airhorns authored and dturn committed Nov 23, 2018
1 parent 75d564e commit 937e706
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ Style/TrailingCommaInArrayLiteral:

Style/TrailingCommaInHashLiteral:
Enabled: false

Naming/FileName:
Enabled: true
Exclude:
- lib/kubernetes-deploy.rb
4 changes: 2 additions & 2 deletions kubernetes-deploy.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ Gem::Specification.new do |spec|
spec.homepage = "https://github.com/Shopify/kubernetes-deploy"
spec.license = "MIT"

spec.files = `git ls-files -z`.split("\x0").reject do |f|
spec.files = %x(git ls-files -z).split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.require_paths = %w(lib)

spec.required_ruby_version = '>= 2.3.0'
spec.add_dependency "activesupport", ">= 5.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ def new_token
private

def json_error_message(body)
json_error_msg = begin
JSON.parse(body || '') || {}
rescue JSON::ParserError
{}
end
json_error_msg['message']
err = JSON.parse(body || '') || {}
err['message']
rescue JSON::ParserError
nil
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions test/integration/restart_task_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_restart_named_deployments_twice
refute fetch_restarted_at("web"), "no RESTARTED_AT env on fresh deployment"

restart = build_restart_task
assert_restart_success(restart.perform(["web"]))
assert_restart_success(restart.perform(%w(web)))

assert_logs_match_all([
"Configured to restart deployments by name: web",
Expand All @@ -61,7 +61,7 @@ def test_restart_named_deployments_twice
assert first_restarted_at, "RESTARTED_AT is present after first restart"

Timecop.freeze(1.second.from_now) do
assert_restart_success(restart.perform(["web"]))
assert_restart_success(restart.perform(%w(web)))
end

second_restarted_at = fetch_restarted_at("web")
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_restart_with_same_resource_twice

def test_restart_not_existing_deployment
restart = build_restart_task
assert_restart_failure(restart.perform(["web"]))
assert_restart_failure(restart.perform(%w(web)))
assert_logs_match_all([
"Configured to restart deployments by name: web",
"Result: FAILURE",
Expand Down Expand Up @@ -131,7 +131,7 @@ def test_restart_not_existing_context
namespace: @namespace,
logger: logger
)
assert_restart_failure(restart.perform(["web"]))
assert_restart_failure(restart.perform(%w(web)))
assert_logs_match_all([
"Result: FAILURE",
"`walrus` context must be configured in your kubeconfig file(s)"
Expand All @@ -145,7 +145,7 @@ def test_restart_not_existing_namespace
namespace: "walrus",
logger: logger
)
assert_restart_failure(restart.perform(["web"]))
assert_restart_failure(restart.perform(%w(web)))
assert_logs_match_all([
"Result: FAILURE",
"Namespace `walrus` not found in context `#{TEST_CONTEXT}`"
Expand Down Expand Up @@ -203,7 +203,7 @@ def test_restart_successful_with_partial_availability
assert_deploy_success(result)

restart = build_restart_task
assert_restart_success(restart.perform(["web"]))
assert_restart_success(restart.perform(%w(web)))

pods = kubeclient.get_pods(namespace: @namespace, label_selector: 'name=web,app=slow-cloud')
new_pods = pods.select do |pod|
Expand Down

0 comments on commit 937e706

Please sign in to comment.