From 1a5e8549f0a8c6e62d229688a9ca98a622ac9335 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Fri, 28 Jun 2024 20:57:58 -0300 Subject: [PATCH] lint --- .ameba.yml | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/faaso.cr | 8 ++--- 2 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 .ameba.yml diff --git a/.ameba.yml b/.ameba.yml new file mode 100644 index 0000000..00b413c --- /dev/null +++ b/.ameba.yml @@ -0,0 +1,86 @@ +# This configuration file was generated by `ameba --gen-config` +# on 2024-06-28 23:57:47 UTC using Ameba version 1.6.1. +# The point is for the user to remove these configuration records +# one by one as the reported problems are removed from the code base. + +# Problems found: 2 +# Run `ameba --only Layout/TrailingBlankLines` for details +Layout/TrailingBlankLines: + Description: Disallows trailing blank lines + Excluded: + - tmp/d1808c39-8dff-4267-9bec-6961ec16c41f/function.cr + - tmp/26456ab0-43e4-44fb-8b6f-986880ff5a41/function.cr + Enabled: true + Severity: Convention + +# Problems found: 2 +# Run `ameba --only Lint/Formatting` for details +Lint/Formatting: + Description: Reports not formatted sources + FailOnError: false + Excluded: + - tmp/d1808c39-8dff-4267-9bec-6961ec16c41f/function.cr + - tmp/26456ab0-43e4-44fb-8b6f-986880ff5a41/function.cr + Enabled: true + Severity: Warning + +# Problems found: 13 +# Run `ameba --only Documentation/DocumentationAdmonition` for details +Documentation/DocumentationAdmonition: + Description: Reports documentation admonitions + Timezone: UTC + Excluded: + - src/faaso.cr + - spec/faaso_spec.cr + Admonitions: + - TODO + - FIXME + - BUG + Enabled: true + Severity: Warning + +# Problems found: 1 +# Run `ameba --only Lint/DebugCalls` for details +Lint/DebugCalls: + Description: Disallows debug-related calls + Excluded: + - src/faaso.cr + MethodNames: + - p + - p! + - pp + - pp! + Enabled: true + Severity: Warning + +# Problems found: 3 +# Run `ameba --only Naming/BlockParameterName` for details +Naming/BlockParameterName: + Description: Disallows non-descriptive block parameter names + MinNameLength: 3 + AllowNamesEndingInNumbers: true + Excluded: + - src/faaso.cr + AllowedNames: + - _ + - e + - i + - j + - k + - v + - x + - y + - ex + - io + - ws + - op + - tx + - id + - ip + - k1 + - k2 + - v1 + - v2 + ForbiddenNames: [] + Enabled: true + Severity: Convention diff --git a/src/faaso.cr b/src/faaso.cr index 13182ce..43bd27e 100644 --- a/src/faaso.cr +++ b/src/faaso.cr @@ -64,9 +64,9 @@ module Faaso containers = docker_api.containers.list(all: true) pp! containers # If it's running, do nothing - if (containers.any? { |c| + if containers.any? { |c| c.@image == tag && c.@state == "running" - }) + } puts "#{arg} is already running" return 0 end @@ -75,7 +75,7 @@ module Faaso paused = containers.select { |c| c.@image == tag && c.@state == "paused" } - if (paused.size > 0) + if paused.size > 0 puts "Resuming existing paused container" docker_api.containers.unpause(paused[0].@id) return 0 @@ -87,7 +87,7 @@ module Faaso } puts "Starting function #{arg}" - if (existing.size > 0) + if existing.size > 0 puts "Restarting existing exited container" docker_api.containers.start(existing[0].@id) return 0