From 52546ab69b25080cb4926f14e5d7e5a95af16bc9 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Thu, 25 Jan 2024 16:56:32 +0100 Subject: [PATCH 01/44] Switch to theforeman-rubocop --- .rubocop.yml | 13 ++++++++----- Gemfile | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index fea17f5fa..0d1927acf 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,27 +1,30 @@ inherit_from: .rubocop_todo.yml +inherit_gem: + theforeman-rubocop: + - lenient.yml AllCops: - TargetRubyVersion: 2.3 + TargetRubyVersion: 2.7 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. -Style/ExtraSpacing: +Layout/ExtraSpacing: Enabled: true # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: with_first_parameter, with_fixed_indentation -Style/AlignParameters: +Layout/ParameterAlignment: Enabled: true # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. # SupportedStyles: aligned, indented -Style/MultilineOperationIndentation: +Layout/MultilineOperationIndentation: Enabled: true # Cop supports --auto-correct. -Style/EmptyLines: +Layout/EmptyLines: Enabled: true Metrics/ModuleLength: diff --git a/Gemfile b/Gemfile index 055f43e57..46ad0ad50 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,7 @@ group :mysql do end group :lint do - gem 'rubocop', '0.39.0' + gem 'theforeman-rubocop', '~> 0.0.4' end group :memory_watcher do From 37afd6767dd9cc0c4696e91d6f55ccd5b00c9438 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Thu, 25 Jan 2024 16:56:48 +0100 Subject: [PATCH 02/44] bundle exec rubocop --auto-gen-config --- .rubocop_todo.yml | 1457 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 1127 insertions(+), 330 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d16050395..ee604d933 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,418 +1,1152 @@ # This configuration was generated by -# `rubocop --auto-gen-config --exclude-limit 0` -# on 2016-08-24 10:37:35 -0400 using RuboCop version 0.39.0. +# `rubocop --auto-gen-config` +# on 2024-01-25 15:55:58 UTC using RuboCop version 0.89.1. # 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: 5 +# Cop supports --auto-correct. +# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. +# Include: **/*.gemfile, **/Gemfile, **/gems.rb +Bundler/OrderedGems: + Exclude: + - 'Gemfile' + - 'doc/pages/Gemfile' + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. +# Include: **/*.gemspec +Gemspec/OrderedDependencies: + Exclude: + - 'dynflow.gemspec' + +# Offense count: 1 +# Configuration parameters: Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: + Exclude: + - 'dynflow.gemspec' + +# Offense count: 226 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_argument, with_fixed_indentation +Layout/ArgumentAlignment: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: IndentationWidth. +Layout/AssignmentIndentation: + Exclude: + - 'lib/dynflow/director.rb' + - 'lib/dynflow/world.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith. +# SupportedStylesAlignWith: either, start_of_block, start_of_line +Layout/BlockAlignment: + Exclude: + - 'test/test_helper.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +Layout/ClosingHeredocIndentation: + Exclude: + - 'lib/dynflow/web/console_helpers.rb' + - 'test/executor_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/ClosingParenthesisIndentation: + Exclude: + - 'doc/pages/plugins/tags.rb' + +# Offense count: 16 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: leading, trailing +Layout/DotPosition: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/persistence.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' + - 'lib/dynflow/rails.rb' + - 'lib/dynflow/testing/assertions.rb' + - 'test/daemon_test.rb' + - 'test/dispatcher_test.rb' + - 'test/rescue_test.rb' + - 'test/web_console_test.rb' + +# Offense count: 222 +# Cop supports --auto-correct. +Layout/EmptyLineAfterMagicComment: + Enabled: false + # Offense count: 7 -Lint/AmbiguousOperator: +# Cop supports --auto-correct. +# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Exclude: + - 'lib/dynflow/utils/indifferent_hash.rb' + - 'test/executor_test.rb' + - 'test/support/dummy_example.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: around, only_before +Layout/EmptyLinesAroundAccessModifier: + Exclude: + - 'lib/dynflow/utils/indifferent_hash.rb' + +# Offense count: 77 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Enabled: false + +# Offense count: 137 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only +Layout/EmptyLinesAroundClassBody: Enabled: false +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundExceptionHandlingKeywords: + Exclude: + - 'test/test_helper.rb' + # Offense count: 2 -Lint/AmbiguousRegexpLiteral: +# Cop supports --auto-correct. +Layout/EmptyLinesAroundMethodBody: + Exclude: + - 'doc/pages/plugins/toc.rb' + - 'test/dispatcher_test.rb' + +# Offense count: 50 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundModuleBody: Enabled: false +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. +# SupportedStylesAlignWith: keyword, variable, start_of_line +Layout/EndAlignment: + Exclude: + - 'lib/dynflow/action/timeouts.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Exclude: + - 'lib/dynflow/web.rb' + - 'test/abnormal_states_recovery_test.rb' + # Offense count: 7 -# Configuration parameters: AllowSafeAssignment. -Lint/AssignmentInCondition: +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses +Layout/FirstArgumentIndentation: + Exclude: + - 'doc/pages/plugins/tags.rb' + - 'lib/dynflow/action.rb' + - 'lib/dynflow/testing/dummy_planned_action.rb' + - 'lib/dynflow/testing/factories.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/FirstHashElementIndentation: + Exclude: + - 'lib/dynflow/execution_plan/steps/finalize_step.rb' + - 'lib/dynflow/execution_plan/steps/run_step.rb' + - 'lib/dynflow/persistence_adapters/sequel_migrations/022_store_flows_as_msgpack.rb' + - 'lib/dynflow/persistence_adapters/sequel_migrations/024_store_execution_plan_data_as_msgpack.rb' + - 'test/persistence_test.rb' + +# Offense count: 201 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: Enabled: false # Offense count: 3 # Cop supports --auto-correct. -# Configuration parameters: AlignWith, SupportedStyles. -# SupportedStyles: either, start_of_block, start_of_line -Lint/BlockAlignment: - Enabled: false +Layout/HeredocIndentation: + Exclude: + - 'examples/memory_limit_watcher.rb' + - 'examples/remote_executor.rb' # Offense count: 1 -Lint/DuplicateMethods: +# Cop supports --auto-correct. +Layout/LeadingEmptyLines: + Exclude: + - 'lib/dynflow/web/console.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineMethodCallBraceLayout: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/testing/dummy_planned_action.rb' + - 'lib/dynflow/testing/factories.rb' + +# Offense count: 28 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented, indented_relative_to_receiver +Layout/MultilineMethodCallIndentation: + Exclude: + - 'doc/pages/plugins/graphviz.rb' + - 'lib/dynflow/action.rb' + - 'lib/dynflow/active_job/queue_adapter.rb' + - 'lib/dynflow/persistence.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' + - 'lib/dynflow/testing/assertions.rb' + - 'test/action_test.rb' + - 'test/dead_letter_silencer_test.rb' + - 'test/dispatcher_test.rb' + - 'test/execution_plan_test.rb' + - 'test/web_console_test.rb' + +# Offense count: 65 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. +# SupportedStylesForExponentOperator: space, no_space +Layout/SpaceAroundOperators: Enabled: false # Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect. -# SupportedStyles: keyword, variable, start_of_line -Lint/EndAlignment: - Enabled: false +Layout/SpaceBeforeComma: + Exclude: + - 'test/testing_test.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: require_no_space, require_space +Layout/SpaceInLambdaLiteral: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/clock.rb' + - 'lib/dynflow/testing/mimic.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Exclude: + - 'lib/dynflow/actor.rb' + - 'lib/dynflow/dispatcher/executor_dispatcher.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/middleware/resolver.rb' + - 'lib/dynflow/telemetry_adapters/statsd.rb' + - 'lib/dynflow/web.rb' + +# Offense count: 63 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Exclude: + - 'lib/dynflow/config.rb' + - 'lib/dynflow/executors/parallel.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' + - 'lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb' + - 'test/flows_test.rb' + - 'test/persistence_test.rb' + - 'test/testing_test.rb' + - 'test/world_test.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceInsideParens: + Exclude: + - 'lib/dynflow/persistence_adapters/sequel.rb' + - 'lib/dynflow/serializer.rb' + - 'lib/dynflow/utils/indifferent_hash.rb' + - 'test/abnormal_states_recovery_test.rb' + - 'test/executor_test.rb' + +# Offense count: 16 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceInsideStringInterpolation: + Exclude: + - 'lib/dynflow/config.rb' + - 'lib/dynflow/connectors/database.rb' + - 'lib/dynflow/connectors/direct.rb' + - 'lib/dynflow/execution_history.rb' + - 'lib/dynflow/web/console_helpers.rb' + - 'test/test_helper.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingEmptyLines: + Exclude: + - 'lib/dynflow/action/format.rb' + - 'lib/dynflow/action/progress.rb' + - 'lib/dynflow/action/rescue.rb' + - 'lib/dynflow/persistence_adapters/sequel_migrations/004_coordinator_records.rb' + - 'lib/dynflow/persistence_adapters/sequel_migrations/009_fix_mysql_data_length.rb' + - 'lib/dynflow/round_robin.rb' + - 'test/abnormal_states_recovery_test.rb' + - 'test/activejob_adapter_test.rb' + +# Offense count: 2 +Lint/AmbiguousBlockAssociation: + Exclude: + - 'lib/dynflow/director/running_steps_manager.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +Lint/AmbiguousOperator: + Exclude: + - 'lib/dynflow/debug/telemetry/persistence.rb' + - 'lib/dynflow/telemetry.rb' + - 'lib/dynflow/testing/factories.rb' + - 'lib/dynflow/testing/mimic.rb' + - 'test/action_test.rb' + - 'test/clock_test.rb' + - 'test/concurrency_control_test.rb' + - 'test/support/middleware_example.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Lint/AmbiguousRegexpLiteral: + Exclude: + - 'doc/pages/plugins/graphviz.rb' + - 'test/dispatcher_test.rb' + - 'test/future_execution_test.rb' + +# Offense count: 8 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'doc/pages/plugins/tags.rb' + - 'lib/dynflow/action/v2/with_sub_plans.rb' + - 'lib/dynflow/connectors/direct.rb' + - 'lib/dynflow/director/running_steps_manager.rb' + - 'lib/dynflow/testing/dummy_execution_plan.rb' + - 'lib/dynflow/testing/managed_clock.rb' + - 'lib/dynflow/web/console_helpers.rb' + - 'test/test_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/DisjunctiveAssignmentInConstructor: + Exclude: + - 'lib/dynflow/coordinator.rb' + +# Offense count: 4 +Lint/DuplicateMethods: + Exclude: + - 'lib/dynflow/coordinator.rb' + - 'lib/dynflow/executors/parallel/pool.rb' + - 'lib/dynflow/rails/configuration.rb' + - 'lib/dynflow/rails/daemon.rb' + +# Offense count: 1 +# Configuration parameters: AllowComments. +Lint/EmptyWhen: + Exclude: + - 'lib/dynflow/action.rb' # Offense count: 6 Lint/IneffectiveAccessModifier: - Enabled: false + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/execution_plan/output_reference.rb' + - 'lib/dynflow/execution_plan/steps/abstract.rb' + - 'lib/dynflow/flows/atom.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' -# Offense count: 5 +# Offense count: 1 +# Configuration parameters: MaximumRangeSize. +Lint/MissingCopEnableDirective: + Exclude: + - 'test/persistence_test.rb' + +# Offense count: 4 +# Cop supports --auto-correct. Lint/ParenthesesAsGroupedExpression: - Enabled: false + Exclude: + - 'test/concurrency_control_test.rb' # Offense count: 1 Lint/RandOne: - Enabled: false + Exclude: + - 'examples/orchestrate_evented.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/RedundantCopDisableDirective: + Exclude: + - 'lib/dynflow/config.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/RedundantRequireStatement: + Exclude: + - 'lib/dynflow.rb' # Offense count: 3 Lint/RescueException: - Enabled: false + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/delayed_executors/abstract_core.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' -# Offense count: 1 +# Offense count: 3 +# Cop supports --auto-correct. +Lint/ScriptPermission: + Exclude: + - 'examples/chunked_output_benchmark.rb' + - 'examples/memory_limit_watcher.rb' + - 'examples/sub_plan_concurrency_control.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Lint/SendWithMixinArgument: + Exclude: + - 'lib/dynflow.rb' + - 'lib/dynflow/debug/telemetry/persistence.rb' + - 'test/activejob_adapter_test.rb' + - 'test/executor_test.rb' + +# Offense count: 3 Lint/ShadowingOuterLocalVariable: - Enabled: false + Exclude: + - 'lib/dynflow/logger_adapters/abstract.rb' + - 'lib/dynflow/rails/daemon.rb' # Offense count: 1 +# Configuration parameters: AllowKeywordBlockArguments. Lint/UnderscorePrefixedVariableName: - Enabled: false + Exclude: + - 'lib/dynflow/utils/indifferent_hash.rb' -# Offense count: 17 +# Offense count: 30 # Cop supports --auto-correct. -# Configuration parameters: IgnoreEmptyBlocks. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: Enabled: false -# Offense count: 78 +# Offense count: 43 # Cop supports --auto-correct. -# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. Lint/UnusedMethodArgument: Enabled: false -# Offense count: 3 +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. Lint/UselessAccessModifier: - Enabled: false + Exclude: + - 'lib/dynflow/dead_letter_silencer.rb' + - 'lib/dynflow/delayed_executors/abstract_core.rb' + - 'lib/dynflow/execution_plan/output_reference.rb' + - 'lib/dynflow/execution_plan/steps/abstract.rb' + - 'lib/dynflow/flows/atom.rb' + - 'lib/dynflow/rails/daemon.rb' -# Offense count: 5 +# Offense count: 9 Lint/UselessAssignment: - Enabled: false + Exclude: + - 'doc/pages/plugins/plantuml.rb' + - 'examples/memory_limit_watcher.rb' + - 'examples/singletons.rb' + - 'lib/dynflow/executors/parallel.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' + - 'lib/dynflow/rails/configuration.rb' + - 'lib/dynflow/world.rb' + - 'test/concurrency_control_test.rb' -# Offense count: 73 +# Offense count: 1 +# Configuration parameters: CheckForMethodsWithNoSideEffects. +Lint/Void: + Exclude: + - 'test/executor_test.rb' + +# Offense count: 86 +# Configuration parameters: IgnoredMethods. Metrics/AbcSize: - Max: 207 + Max: 66 -# Offense count: 9 -# Configuration parameters: CountComments. -Metrics/ClassLength: - Max: 402 +# Offense count: 101 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods. +# ExcludedMethods: refine +Metrics/BlockLength: + Max: 738 # Offense count: 11 -Metrics/CyclomaticComplexity: - Max: 11 +# Configuration parameters: CountComments, CountAsOne. +Metrics/ClassLength: + Max: 292 -# Offense count: 521 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes. -# URISchemes: http, https -Metrics/LineLength: - Max: 166 +# Offense count: 18 +# Configuration parameters: IgnoredMethods. +Metrics/CyclomaticComplexity: + Max: 18 -# Offense count: 99 -# Configuration parameters: CountComments. +# Offense count: 135 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods. Metrics/MethodLength: - Max: 104 + Max: 47 -# Offense count: 14 -# Configuration parameters: CountComments. +# Offense count: 4 +# Configuration parameters: CountComments, CountAsOne. Metrics/ModuleLength: - Max: 548 + Max: 188 -# Offense count: 3 +# Offense count: 8 # Configuration parameters: CountKeywordArgs. Metrics/ParameterLists: Max: 13 -# Offense count: 9 +# Offense count: 14 +# Configuration parameters: IgnoredMethods. Metrics/PerceivedComplexity: - Max: 11 + Max: 18 + +# Offense count: 10 +Naming/AccessorMethodName: + Exclude: + - 'examples/example_helper.rb' + - 'lib/dynflow/action.rb' + - 'lib/dynflow/director.rb' + - 'lib/dynflow/semaphores/abstract.rb' + - 'lib/dynflow/semaphores/aggregating.rb' + - 'lib/dynflow/semaphores/dummy.rb' + - 'lib/dynflow/semaphores/stateful.rb' + - 'lib/dynflow/telemetry.rb' + - 'lib/dynflow/testing.rb' + - 'lib/dynflow/watchers/memory_consumption_watcher.rb' -# Offense count: 16 +# Offense count: 1 +Naming/BinaryOperatorParameterName: + Exclude: + - 'lib/dynflow/coordinator.rb' + +# Offense count: 3 +Naming/ConstantName: + Exclude: + - 'examples/sub_plan_concurrency_control.rb' + +# Offense count: 5 +# Configuration parameters: EnforcedStyleForLeadingUnderscores. +# SupportedStylesForLeadingUnderscores: disallowed, required, optional +Naming/MemoizedInstanceVariableName: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/execution_plan/steps/abstract_flow_step.rb' + - 'lib/dynflow/persistence_adapters/abstract.rb' + - 'lib/dynflow/testing/in_thread_world.rb' + - 'test/test_helper.rb' + +# Offense count: 15 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to +Naming/MethodParameterName: + Exclude: + - 'lib/dynflow/flows/abstract_composed.rb' + - 'lib/dynflow/logger_adapters/abstract.rb' + - 'lib/dynflow/logger_adapters/formatters/abstract.rb' + - 'lib/dynflow/logger_adapters/simple.rb' + - 'lib/dynflow/semaphores/abstract.rb' + - 'lib/dynflow/semaphores/aggregating.rb' + - 'lib/dynflow/semaphores/dummy.rb' + - 'lib/dynflow/semaphores/stateful.rb' + - 'lib/dynflow/testing/mimic.rb' + - 'test/semaphores_test.rb' + +# Offense count: 4 +# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. +# NamePrefix: is_, has_, have_ +# ForbiddenPrefixes: is_, has_, have_ +# AllowedMethods: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicateName: + Exclude: + - 'spec/**/*' + - 'lib/dynflow/semaphores/abstract.rb' + - 'lib/dynflow/semaphores/aggregating.rb' + - 'lib/dynflow/semaphores/dummy.rb' + - 'lib/dynflow/semaphores/stateful.rb' + +# Offense count: 7 # Cop supports --auto-correct. -Performance/RedundantBlockCall: - Enabled: false +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/action/polling.rb' + - 'lib/dynflow/action/progress.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/executors/parallel.rb' + - 'lib/dynflow/serializable.rb' + +# Offense count: 6 +# Configuration parameters: . +# SupportedStyles: snake_case, camelCase +Naming/VariableName: + EnforcedStyle: snake_case + +# Offense count: 3 +# Configuration parameters: MinSize. +Performance/CollectionLiteralInLoop: + Exclude: + - 'lib/dynflow/coordinator.rb' + - 'lib/dynflow/director/sequential_manager.rb' + - 'lib/dynflow/execution_plan.rb' # Offense count: 4 # Cop supports --auto-correct. +Performance/Count: + Exclude: + - 'lib/dynflow/world/invalidation.rb' + - 'test/concurrency_control_test.rb' + +# Offense count: 17 +# Cop supports --auto-correct. +Performance/RedundantBlockCall: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/coordinator.rb' + - 'lib/dynflow/delayed_executors/abstract_core.rb' + - 'lib/dynflow/director/sequential_manager.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/execution_plan/steps/abstract.rb' + - 'lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb' + - 'lib/dynflow/testing/assertions.rb' + - 'lib/dynflow/testing/dummy_execution_plan.rb' + - 'lib/dynflow/testing/factories.rb' + - 'lib/dynflow/transaction_adapters/none.rb' + - 'lib/dynflow/world.rb' + - 'test/test_helper.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Performance/RegexpMatch: + Exclude: + - 'test/support/code_workflow_example.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect. Performance/TimesMap: - Enabled: false + Exclude: + - 'examples/sub_plan_concurrency_control.rb' + - 'test/action_test.rb' + - 'test/concurrency_control_test.rb' -# Offense count: 8 -Style/AccessorMethodName: - Enabled: false +# Offense count: 7 +Performance/UnfreezeString: + Exclude: + - 'lib/dynflow/execution_plan/output_reference.rb' + - 'lib/dynflow/extensions/msgpack.rb' + - 'test/support/middleware_example.rb' + - 'test/test_helper.rb' -# Offense count: 13 +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: prefer_alias, prefer_alias_method -Style/Alias: - Enabled: false +# Configuration parameters: Include. +# Include: **/test/**/* +Rails/AssertNot: + Exclude: + - 'test/executor_test.rb' # Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Style/AlignHash: - Enabled: false +# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent. +Rails/Blank: + Exclude: + - 'lib/dynflow/telemetry_adapters/statsd.rb' -# Offense count: 11 +# Offense count: 3 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, flexible +Rails/Date: + Exclude: + - 'lib/dynflow/extensions/msgpack.rb' + - 'lib/dynflow/persistence.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: EnforceForPrefixed. +Rails/Delegate: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/execution_plan/steps/abstract.rb' + - 'lib/dynflow/persistence.rb' + - 'lib/dynflow/rails/configuration.rb' + - 'lib/dynflow/web/world_helpers.rb' + - 'lib/dynflow/world.rb' + +# Offense count: 2 +# Configuration parameters: Include. +# Include: app/**/*.rb, config/**/*.rb, lib/**/*.rb +Rails/Exit: + Exclude: + - 'lib/**/*.rake' + - 'lib/dynflow/rails/daemon.rb' + - 'lib/dynflow/world.rb' + +# Offense count: 1 +# Configuration parameters: Include. +# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb +Rails/Output: + Exclude: + - 'lib/dynflow/testing/in_thread_world.rb' + +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: always, conditionals -Style/AndOr: +Rails/PluralizationGrammar: + Exclude: + - 'test/activejob_adapter_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: **/Rakefile, **/*.rake +Rails/RakeEnvironment: + Exclude: + - 'lib/capistrano/tasks/**/*.rake' + - 'doc/pages/Rakefile' + +# Offense count: 24 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, Include. +# SupportedStyles: assert_not, refute +# Include: **/test/**/* +Rails/RefuteMethods: + Exclude: + - 'test/abnormal_states_recovery_test.rb' + - 'test/action_test.rb' + - 'test/dispatcher_test.rb' + - 'test/execution_plan_hooks_test.rb' + - 'test/execution_plan_test.rb' + - 'test/executor_test.rb' + - 'test/test_helper.rb' + +# Offense count: 14 +# Configuration parameters: ForbiddenMethods, AllowedMethods. +# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all +Rails/SkipsModelValidations: + Exclude: + - 'db/migrate/*.rb' + - 'lib/dynflow/connectors/abstract.rb' + - 'lib/dynflow/connectors/database.rb' + - 'lib/dynflow/connectors/direct.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/executors/parallel/worker.rb' + - 'lib/dynflow/executors/sidekiq/worker_jobs.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' + - 'test/persistence_test.rb' + +# Offense count: 37 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, flexible +Rails/TimeZone: Enabled: false # Offense count: 2 +Security/MarshalLoad: + Exclude: + - 'lib/dynflow/dispatcher.rb' + - 'lib/dynflow/serializer.rb' + +# Offense count: 4 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: prefer_alias, prefer_alias_method +Style/Alias: + Exclude: + - 'lib/dynflow/rails/configuration.rb' + - 'lib/dynflow/testing/assertions.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. # SupportedStyles: percent_q, bare_percent Style/BarePercentLiterals: - Enabled: false + Exclude: + - 'doc/pages/plugins/tags.rb' # Offense count: 3 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. -# SupportedStyles: line_count_based, semantic, braces_for_chaining +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object # FunctionalMethods: let, let!, subject, watch # IgnoredMethods: lambda, proc, it Style/BlockDelimiters: - Enabled: false + Exclude: + - 'doc/pages/plugins/tags.rb' -# Offense count: 18 +# Offense count: 10 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: braces, no_braces, context_dependent -Style/BracesAroundHashParameters: - Enabled: false - -# Offense count: 13 +# Configuration parameters: AllowOnConstant. Style/CaseEquality: - Enabled: false - -# Offense count: 24 -# Configuration parameters: EnforcedStyle, SupportedStyles. + Exclude: + - 'lib/dynflow/action/with_bulk_sub_plans.rb' + - 'lib/dynflow/clock.rb' + - 'lib/dynflow/connectors/database.rb' + - 'lib/dynflow/connectors/direct.rb' + - 'lib/dynflow/director/running_steps_manager.rb' + - 'lib/dynflow/dispatcher/client_dispatcher.rb' + - 'lib/dynflow/logger_adapters/formatters/exception.rb' + - 'lib/dynflow/serializer.rb' + - 'test/abnormal_states_recovery_test.rb' + - 'test/support/rescue_example.rb' + +# Offense count: 29 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle. # SupportedStyles: nested, compact Style/ClassAndModuleChildren: Enabled: false -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: is_a?, kind_of? -Style/ClassCheck: - Enabled: false - -# Offense count: 4 +# Offense count: 5 # Cop supports --auto-correct. Style/ColonMethodCall: - Enabled: false + Exclude: + - 'doc/pages/plugins/graphviz.rb' + - 'doc/pages/plugins/plantuml.rb' + - 'test/executor_test.rb' # Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: Keywords. # Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW Style/CommentAnnotation: - Enabled: false - -# Offense count: 4 -Style/ConstantName: - Enabled: false + Exclude: + - 'doc/pages/plugins/tags.rb' + - 'examples/remote_executor.rb' + - 'lib/dynflow.rb' + - 'lib/dynflow/world.rb' + - 'test/support/code_workflow_example.rb' -# Offense count: 3 -# Cop supports --auto-correct. -Style/DeprecatedHashMethods: - Enabled: false - -# Offense count: 172 -Style/Documentation: - Enabled: false +# Offense count: 1 +Style/CommentedKeyword: + Exclude: + - 'doc/pages/plugins/plantuml.rb' -# Offense count: 20 +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: leading, trailing -Style/DotPosition: - Enabled: false - -# Offense count: 3 -Style/DoubleNegation: - Enabled: false +Style/Dir: + Exclude: + - 'test/test_helper.rb' # Offense count: 1 -Style/EachWithObject: - Enabled: false +# Configuration parameters: EnforcedStyle. +# SupportedStyles: allowed_in_returns, forbidden +Style/DoubleNegation: + Exclude: + - 'lib/dynflow/config.rb' # Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty, nil, both -Style/EmptyElse: - Enabled: false - -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: AllowAdjacentOneLineDefs. -Style/EmptyLineBetweenDefs: - Enabled: false +Style/EachWithObject: + Exclude: + - 'lib/dynflow/execution_plan.rb' # Offense count: 1 # Cop supports --auto-correct. -Style/EmptyLinesAroundAccessModifier: - Enabled: false +Style/EmptyCaseCondition: + Exclude: + - 'lib/dynflow/serializer.rb' -# Offense count: 91 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty_lines, no_empty_lines -Style/EmptyLinesAroundBlockBody: - Enabled: false - -# Offense count: 143 +# Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty_lines, no_empty_lines -Style/EmptyLinesAroundClassBody: - Enabled: false +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty, nil, both +Style/EmptyElse: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/execution_plan.rb' -# Offense count: 2 +# Offense count: 9 # Cop supports --auto-correct. -Style/EmptyLinesAroundMethodBody: - Enabled: false +# Configuration parameters: EnforcedStyle. +# SupportedStyles: compact, expanded +Style/EmptyMethod: + Exclude: + - 'test/action_test.rb' + - 'test/execution_plan_cleaner_test.rb' + - 'test/executor_test.rb' + - 'test/support/dummy_example.rb' -# Offense count: 52 +# Offense count: 7 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty_lines, no_empty_lines -Style/EmptyLinesAroundModuleBody: - Enabled: false +Style/Encoding: + Exclude: + - 'dynflow.gemspec' + - 'examples/remote_executor.rb' + - 'lib/dynflow/rails.rb' + - 'lib/dynflow/world.rb' + - 'test/abnormal_states_recovery_test.rb' + - 'test/executor_test.rb' + - 'test/round_robin_test.rb' -# Offense count: 9 +# Offense count: 8 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Style/FirstParameterIndentation: - Enabled: false +Style/ExpandPathArguments: + Exclude: + - 'dynflow.gemspec' + - 'examples/example_helper.rb' + - 'examples/remote_executor.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' + - 'lib/dynflow/rails.rb' + - 'lib/dynflow/web.rb' + - 'test/daemon_test.rb' # Offense count: 4 -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. # SupportedStyles: format, sprintf, percent Style/FormatString: - Enabled: false + Exclude: + - 'lib/dynflow/coordinator.rb' + - 'lib/dynflow/web/console_helpers.rb' + +# Offense count: 31 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: annotated, template, unannotated +Style/FormatStringToken: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/actor.rb' + - 'lib/dynflow/coordinator.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/execution_plan/steps/error.rb' + - 'lib/dynflow/logger_adapters/simple.rb' + - 'lib/dynflow/web/console_helpers.rb' # Offense count: 7 # Configuration parameters: AllowedVariables. Style/GlobalVars: - Enabled: false + Exclude: + - 'test/executor_test.rb' + - 'test/support/dummy_example.rb' + - 'test/testing_test.rb' -# Offense count: 13 +# Offense count: 60 # Configuration parameters: MinBodyLength. Style/GuardClause: Enabled: false -# Offense count: 106 +# Offense count: 10 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues. -# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets +# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys Style/HashSyntax: - Enabled: false + Exclude: + - 'lib/dynflow/persistence_adapters/sequel.rb' + - 'test/persistence_test.rb' -# Offense count: 4 +# Offense count: 8 +# Configuration parameters: AllowIfModifier. Style/IfInsideElse: - Enabled: false + Exclude: + - 'lib/dynflow/action/rescue.rb' + - 'lib/dynflow/action/with_polling_sub_plans.rb' + - 'lib/dynflow/clock.rb' + - 'lib/dynflow/dispatcher/client_dispatcher.rb' + - 'lib/dynflow/rails/configuration.rb' + - 'lib/dynflow/utils.rb' + - 'lib/dynflow/world/invalidation.rb' -# Offense count: 22 +# Offense count: 69 # Cop supports --auto-correct. -# Configuration parameters: MaxLineLength. Style/IfUnlessModifier: Enabled: false -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: IndentationWidth. -Style/IndentAssignment: - Enabled: false - -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Style/IndentHash: - Enabled: false +# Configuration parameters: InverseMethods, InverseBlocks. +Style/InverseMethods: + Exclude: + - 'lib/dynflow/middleware/resolver.rb' # Offense count: 8 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: line_count_dependent, lambda, literal Style/Lambda: - Enabled: false + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/extensions/msgpack.rb' + - 'lib/dynflow/rails/daemon.rb' + - 'lib/dynflow/testing/mimic.rb' + - 'test/concurrency_control_test.rb' + - 'test/test_helper.rb' -# Offense count: 13 +# Offense count: 5 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: EnforcedStyle. # SupportedStyles: call, braces Style/LambdaCall: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -Style/LineEndConcatenation: - Enabled: false + Exclude: + - 'lib/dynflow/action.rb' -# Offense count: 3 +# Offense count: 12 # Cop supports --auto-correct. -Style/MethodCallParentheses: - Enabled: false +# Configuration parameters: IgnoredMethods. +Style/MethodCallWithoutArgsParentheses: + Exclude: + - 'doc/pages/plugins/plantuml.rb' + - 'lib/dynflow/delayed_executors/abstract_core.rb' + - 'lib/dynflow/director.rb' + - 'test/action_test.rb' + - 'test/dispatcher_test.rb' + - 'test/v2_sub_plans_test.rb' -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: EnforcedStyle. # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline Style/MethodDefParentheses: - Enabled: false + Exclude: + - 'doc/pages/plugins/graphviz.rb' -# Offense count: 6 +# Offense count: 1 +Style/MissingRespondToMissing: + Exclude: + - 'lib/dynflow/config.rb' + +# Offense count: 5 Style/MultilineBlockChain: - Enabled: false + Exclude: + - 'lib/dynflow/dispatcher/executor_dispatcher.rb' + - 'lib/dynflow/world.rb' + - 'test/executor_test.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/MultilineIfModifier: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/execution_plan.rb' # Offense count: 1 # Cop supports --auto-correct. Style/MultilineIfThen: - Enabled: false + Exclude: + - 'doc/pages/plugins/graphviz.rb' -# Offense count: 23 +# Offense count: 3 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: aligned, indented -Style/MultilineMethodCallIndentation: - Enabled: false +Style/MultilineWhenThen: + Exclude: + - 'doc/pages/plugins/graphviz.rb' -# Offense count: 9 +# Offense count: 1 +Style/MultipleComparison: + Exclude: + - 'test/action_test.rb' + +# Offense count: 4 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict Style/MutableConstant: - Enabled: false + Exclude: + - 'doc/pages/plugins/alert_block.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' # Offense count: 5 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: both, prefix, postfix Style/NegatedIf: - Enabled: false + Exclude: + - 'doc/pages/plugins/graphviz.rb' + - 'doc/pages/plugins/plantuml.rb' + - 'doc/pages/plugins/tags.rb' + - 'lib/dynflow/actor.rb' -# Offense count: 9 +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: AllowedMethods. +# AllowedMethods: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with Style/NestedParenthesizedCalls: - Enabled: false + Exclude: + - 'lib/dynflow/persistence_adapters/sequel.rb' + - 'lib/dynflow/web/console.rb' -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. +# Configuration parameters: EnforcedStyle, MinBodyLength. # SupportedStyles: skip_modifier_ifs, always Style/Next: - Enabled: false + Exclude: + - 'doc/pages/plugins/tags.rb' # Offense count: 2 # Cop supports --auto-correct. Style/Not: - Enabled: false - -# Offense count: 2 -Style/OpMethod: - Enabled: false + Exclude: + - 'doc/pages/plugins/graphviz.rb' + - 'doc/pages/plugins/tags.rb' + +# Offense count: 15 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'lib/dynflow/action/v2/with_sub_plans.rb' + - 'lib/dynflow/action/with_bulk_sub_plans.rb' + - 'lib/dynflow/action/with_sub_plans.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/flows/abstract.rb' + - 'lib/dynflow/rails.rb' + - 'lib/dynflow/rails/daemon.rb' + - 'lib/dynflow/semaphores/aggregating.rb' + - 'lib/dynflow/semaphores/stateful.rb' + - 'test/execution_plan_hooks_test.rb' # Offense count: 5 # Cop supports --auto-correct. Style/ParallelAssignment: - Enabled: false + Exclude: + - 'doc/pages/plugins/tags.rb' + - 'test/executor_test.rb' + - 'test/support/test_execution_log.rb' + - 'test/test_helper.rb' -# Offense count: 24 +# Offense count: 45 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: @@ -421,44 +1155,67 @@ Style/PercentLiteralDelimiters: # Offense count: 1 # Cop supports --auto-correct. Style/PerlBackrefs: - Enabled: false + Exclude: + - 'test/support/dummy_example.rb' -# Offense count: 4 -# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist. -# NamePrefix: is_, has_, have_ -# NamePrefixBlacklist: is_, has_, have_ -# NameWhitelist: is_a? -Style/PredicateName: - Enabled: false +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: short, verbose +Style/PreferredHashMethods: + Exclude: + - 'lib/dynflow/middleware/resolver.rb' + - 'lib/dynflow/world.rb' # Offense count: 6 # Cop supports --auto-correct. Style/Proc: - Enabled: false + Exclude: + - 'examples/remote_executor.rb' + - 'test/abnormal_states_recovery_test.rb' + - 'test/dispatcher_test.rb' -# Offense count: 4 -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. # SupportedStyles: compact, exploded Style/RaiseArgs: - Enabled: false + Exclude: + - 'lib/dynflow/action/v2/with_sub_plans.rb' + - 'lib/dynflow/action/with_sub_plans.rb' + - 'lib/dynflow/coordinator.rb' + - 'lib/dynflow/coordinator_adapters/sequel.rb' + - 'lib/dynflow/dispatcher/client_dispatcher.rb' -# Offense count: 1 +# Offense count: 7 # Cop supports --auto-correct. Style/RedundantBegin: - Enabled: false + Exclude: + - 'examples/remote_executor.rb' + - 'lib/dynflow/execution_plan/hooks.rb' + - 'lib/dynflow/rails/daemon.rb' + - 'lib/dynflow/world.rb' + - 'test/test_helper.rb' -# Offense count: 2 +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantCapitalW: + Exclude: + - 'test/future_execution_test.rb' + +# Offense count: 1 # Cop supports --auto-correct. Style/RedundantParentheses: - Enabled: false + Exclude: + - 'test/coordinator_test.rb' -# Offense count: 43 +# Offense count: 72 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: Enabled: false -# Offense count: 87 +# Offense count: 107 # Cop supports --auto-correct. Style/RedundantSelf: Enabled: false @@ -466,145 +1223,185 @@ Style/RedundantSelf: # Offense count: 1 # Cop supports --auto-correct. Style/RescueModifier: + Exclude: + - 'lib/dynflow/serializer.rb' + +# Offense count: 22 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, explicit +Style/RescueStandardError: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/action/polling.rb' + - 'lib/dynflow/action/progress.rb' + - 'lib/dynflow/clock.rb' + - 'lib/dynflow/connectors/database.rb' + - 'lib/dynflow/director.rb' + - 'lib/dynflow/dispatcher/client_dispatcher.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/execution_plan/hooks.rb' + - 'lib/dynflow/executors/parallel.rb' + - 'lib/dynflow/rails/daemon.rb' + - 'lib/dynflow/testing/in_thread_executor.rb' + - 'lib/dynflow/testing/in_thread_world.rb' + - 'lib/dynflow/world.rb' + - 'lib/dynflow/world/invalidation.rb' + +# Offense count: 21 +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: Enabled: false # Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: AllowAsExpressionSeparator. Style/Semicolon: - Enabled: false + Exclude: + - 'test/abnormal_states_recovery_test.rb' + - 'test/concurrency_control_test.rb' + - 'test/dispatcher_test.rb' + - 'test/executor_test.rb' # Offense count: 3 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: EnforcedStyle. # SupportedStyles: only_raise, only_fail, semantic Style/SignalException: - Enabled: false - -# Offense count: 6 -# Configuration parameters: Methods. -# Methods: {"reduce"=>["a", "e"]}, {"inject"=>["a", "e"]} -Style/SingleLineBlockParams: - Enabled: false + Exclude: + - 'lib/dynflow/action/singleton.rb' + - 'lib/dynflow/action/timeouts.rb' + - 'lib/dynflow/action/with_sub_plans.rb' # Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: AllowIfMethodIsEmpty. Style/SingleLineMethods: - Enabled: false + Exclude: + - 'lib/dynflow/utils/indifferent_hash.rb' + - 'test/support/dummy_example.rb' -# Offense count: 42 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Style/SpaceAroundOperators: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -Style/SpaceBeforeComma: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -Style/SpaceInsideBlockBraces: - Enabled: false - -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. -# SupportedStyles: space, no_space -Style/SpaceInsideHashLiteralBraces: - Enabled: false - -# Offense count: 7 -# Cop supports --auto-correct. -Style/SpaceInsideParens: - Enabled: false - -# Offense count: 8 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: space, no_space -Style/SpaceInsideStringInterpolation: - Enabled: false - -# Offense count: 9 +# Offense count: 14 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: EnforcedStyle. # SupportedStyles: use_perl_names, use_english_names Style/SpecialGlobalVars: - Enabled: false + Exclude: + - 'dynflow.gemspec' + - 'examples/chunked_output_benchmark.rb' + - 'examples/example_helper.rb' + - 'examples/future_execution.rb' + - 'examples/memory_limit_watcher.rb' + - 'examples/orchestrate.rb' + - 'examples/orchestrate_evented.rb' + - 'examples/remote_executor.rb' + - 'examples/singletons.rb' + - 'examples/sub_plan_concurrency_control.rb' + - 'examples/sub_plans.rb' + - 'examples/sub_plans_v2.rb' + - 'examples/termination.rb' -# Offense count: 5 +# Offense count: 4 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: EnforcedStyle. # SupportedStyles: require_parentheses, require_no_parentheses Style/StabbyLambdaParentheses: - Enabled: false + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/clock.rb' + - 'lib/dynflow/testing/mimic.rb' -# Offense count: 230 +# Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiterals: - Enabled: false +Style/StderrPuts: + Exclude: + - 'lib/dynflow/rails/daemon.rb' # Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: EnforcedStyle. # SupportedStyles: single_quotes, double_quotes Style/StringLiteralsInInterpolation: - Enabled: false + Exclude: + - 'lib/dynflow/web/console.rb' + - 'lib/dynflow/web/console_helpers.rb' -# Offense count: 9 +# Offense count: 10 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. -# IgnoredMethods: respond_to +# IgnoredMethods: respond_to, define_method Style/SymbolProc: - Enabled: false - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: final_newline, final_blank_line -Style/TrailingBlankLines: - Enabled: false + Exclude: + - 'doc/pages/plugins/tags.rb' + - 'lib/dynflow/action.rb' + - 'lib/dynflow/action/v2/with_sub_plans.rb' + - 'lib/dynflow/action/with_polling_sub_plans.rb' + - 'lib/dynflow/action/with_sub_plans.rb' + - 'lib/dynflow/director.rb' + - 'lib/dynflow/director/sequence_cursor.rb' + - 'lib/dynflow/world.rb' + - 'test/concurrency_control_test.rb' + - 'test/test_helper.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: - Enabled: false +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArrayLiteral: + Exclude: + - 'lib/dynflow/config.rb' + - 'lib/dynflow/debug/telemetry/persistence.rb' -# Offense count: 1 +# Offense count: 9 # Cop supports --auto-correct. -Style/UnneededCapitalW: - Enabled: false +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Exclude: + - 'lib/dynflow/execution_plan/steps/finalize_step.rb' + - 'lib/dynflow/execution_plan/steps/run_step.rb' + - 'lib/dynflow/persistence_adapters/sequel_migrations/022_store_flows_as_msgpack.rb' + - 'lib/dynflow/persistence_adapters/sequel_migrations/024_store_execution_plan_data_as_msgpack.rb' + - 'lib/dynflow/rails/daemon.rb' + - 'lib/dynflow/semaphores/stateful.rb' + - 'test/persistence_test.rb' + - 'test/semaphores_test.rb' -# Offense count: 2 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: snake_case, camelCase -Style/VariableName: - Enabled: false +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods. +# AllowedMethods: 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/dynflow/director.rb' + - 'test/support/middleware_example.rb' + - 'test/support/test_execution_log.rb' # Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: MaxLineLength. -Style/WhileUntilModifier: - Enabled: false +Style/UnpackFirst: + Exclude: + - 'lib/dynflow/persistence_adapters/sequel.rb' -# Offense count: 7 +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: SupportedStyles, WordRegex. -# SupportedStyles: percent, brackets -Style/WordArray: - EnforcedStyle: percent - MinSize: 4 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: forbid_for_all_comparison_operators, forbid_for_equality_operators_only, require_for_all_comparison_operators, require_for_equality_operators_only +Style/YodaCondition: + Exclude: + - 'lib/dynflow/actor.rb' # Offense count: 1 # Cop supports --auto-correct. Style/ZeroLengthPredicate: - Enabled: false + Exclude: + - 'lib/dynflow/flows/abstract.rb' + +# Offense count: 87 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 165 From 21246cc267a62523844a4d235f9aa030ee4023e5 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Thu, 25 Jan 2024 16:58:25 +0100 Subject: [PATCH 03/44] Fix Lint/RedundantCop{Disable,Enable}Directive cops --- lib/dynflow/action.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/dynflow/action.rb b/lib/dynflow/action.rb index 3774db6fd..0eeda4478 100644 --- a/lib/dynflow/action.rb +++ b/lib/dynflow/action.rb @@ -551,7 +551,6 @@ def execute_plan(*args) end # TODO: This is getting out of hand, refactoring needed - # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity def execute_run(event) phase! Run @world.logger.debug format('%13s %s:%2d got event %s', @@ -599,7 +598,6 @@ def execute_run(event) raise "wrong state #{state} when event:#{event}" end end - # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity def execute_finalize phase! Finalize From 7ed192732bea217059dc2e059fc599264dfb4390 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Thu, 25 Jan 2024 16:58:57 +0100 Subject: [PATCH 04/44] Fix Style/MethodDefParentheses cop --- lib/dynflow/testing/factories.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynflow/testing/factories.rb b/lib/dynflow/testing/factories.rb index 72314c593..d6d856224 100644 --- a/lib/dynflow/testing/factories.rb +++ b/lib/dynflow/testing/factories.rb @@ -100,7 +100,7 @@ def finalize_action(run_action, &stubbing) finalize_action end - def progress_action_time action + def progress_action_time(action) Match! action.phase, Action::Run if action.world.clock.progress return action.world.executor.progress From 25b62c5b91926b6439e609ace5533a48c2feb268 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Thu, 25 Jan 2024 16:59:39 +0100 Subject: [PATCH 05/44] Fix Naming/VariableName cop --- test/semaphores_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/semaphores_test.rb b/test/semaphores_test.rb index 777cb9f48..498e0bb0d 100644 --- a/test/semaphores_test.rb +++ b/test/semaphores_test.rb @@ -71,10 +71,10 @@ module SemaphoresTest } end - def assert_semaphore_state(semaphore, state_A, state_B) - _(semaphore.children[:child_A].free).must_equal state_A - _(semaphore.children[:child_B].free).must_equal state_B - _(semaphore.free).must_equal [state_A, state_B].min + def assert_semaphore_state(semaphore, state_a, state_b) + _(semaphore.children[:child_A].free).must_equal state_a + _(semaphore.children[:child_B].free).must_equal state_b + _(semaphore.free).must_equal [state_a, state_b].min end it 'can be used as counter' do From f5ff4d240a40c3776cac9a16f415c78f2dabf9eb Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Thu, 25 Jan 2024 17:00:27 +0100 Subject: [PATCH 06/44] Disable Style/LambdaCall cop It would make certain algebrick constructs feel clunky. --- .rubocop.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 0d1927acf..be83e32c8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -30,3 +30,6 @@ Layout/EmptyLines: Metrics/ModuleLength: Exclude: - test/**/* + +Style/LambdaCall: + Enabled: false From 4882fbbf765b324a449bff54ccd014a094c13941 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Thu, 25 Jan 2024 17:08:33 +0100 Subject: [PATCH 07/44] Pin bundler to 2.4.22 --- .github/workflows/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index edf0b5d7b..f09099842 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -23,7 +23,7 @@ jobs: ruby-version: 2.7 - name: Setup run: | - gem install bundler -v 2.4.22 + gem install bundler --version=2.4.22 bundle install --jobs=3 --retry=3 - name: Run rubocop run: bundle exec rubocop From 77622c1622f7179c953a5baa5372b171d39e108a Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Fri, 26 Jan 2024 14:59:02 +0100 Subject: [PATCH 08/44] Fix Layout/ArgumentAlignment cop --- .rubocop_todo.yml | 49 ++--------- doc/pages/plugins/tags.rb | 2 +- examples/orchestrate.rb | 18 ++-- examples/orchestrate_evented.rb | 36 ++++---- lib/dynflow/action.rb | 50 +++++------ lib/dynflow/action/missing.rb | 6 +- lib/dynflow/action/with_sub_plans.rb | 38 ++++----- lib/dynflow/connectors/abstract.rb | 20 ++--- lib/dynflow/delayed_plan.rb | 10 +-- lib/dynflow/director.rb | 20 ++--- lib/dynflow/dispatcher.rb | 14 ++-- lib/dynflow/dispatcher/client_dispatcher.rb | 64 +++++++-------- lib/dynflow/dispatcher/executor_dispatcher.rb | 12 +-- lib/dynflow/execution_plan.rb | 82 +++++++++---------- .../execution_plan/output_reference.rb | 6 +- lib/dynflow/execution_plan/steps/abstract.rb | 36 ++++---- lib/dynflow/execution_plan/steps/error.rb | 18 ++-- lib/dynflow/execution_plan/steps/plan_step.rb | 22 ++--- lib/dynflow/executors/abstract/core.rb | 6 +- lib/dynflow/executors/parallel/core.rb | 4 +- lib/dynflow/extensions/msgpack.rb | 8 +- lib/dynflow/logger_adapters/simple.rb | 10 +-- lib/dynflow/persistence_adapters/sequel.rb | 10 +-- .../sequel_migrations/001_initial.rb | 2 +- .../sequel_migrations/018_add_uuid_column.rb | 4 +- .../021_create_output_chunks.rb | 2 +- lib/dynflow/telemetry.rb | 18 ++-- lib/dynflow/testing/assertions.rb | 4 +- lib/dynflow/testing/dummy_planned_action.rb | 2 +- lib/dynflow/testing/factories.rb | 70 ++++++++-------- lib/dynflow/world.rb | 18 ++-- test/action_test.rb | 2 +- test/execution_plan_test.rb | 12 +-- test/executor_test.rb | 22 ++--- test/middleware_test.rb | 6 +- test/persistence_test.rb | 12 +-- test/support/code_workflow_example.rb | 20 ++--- test/support/dummy_example.rb | 34 ++++---- test/test_helper.rb | 2 +- 39 files changed, 366 insertions(+), 405 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ee604d933..804c6cfd4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-01-25 15:55:58 UTC using RuboCop version 0.89.1. +# on 2024-01-26 13:57:59 UTC using RuboCop version 0.89.1. # 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 @@ -30,13 +30,6 @@ Gemspec/RequiredRubyVersion: Exclude: - 'dynflow.gemspec' -# Offense count: 226 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_argument, with_fixed_indentation -Layout/ArgumentAlignment: - Enabled: false - # Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: IndentationWidth. @@ -60,12 +53,6 @@ Layout/ClosingHeredocIndentation: - 'lib/dynflow/web/console_helpers.rb' - 'test/executor_test.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Layout/ClosingParenthesisIndentation: - Exclude: - - 'doc/pages/plugins/tags.rb' - # Offense count: 16 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. @@ -154,17 +141,6 @@ Layout/ExtraSpacing: - 'lib/dynflow/web.rb' - 'test/abnormal_states_recovery_test.rb' -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstArgumentIndentation: - Exclude: - - 'doc/pages/plugins/tags.rb' - - 'lib/dynflow/action.rb' - - 'lib/dynflow/testing/dummy_planned_action.rb' - - 'lib/dynflow/testing/factories.rb' - # Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. @@ -511,7 +487,7 @@ Metrics/BlockLength: Metrics/ClassLength: Max: 292 -# Offense count: 18 +# Offense count: 19 # Configuration parameters: IgnoredMethods. Metrics/CyclomaticComplexity: Max: 18 @@ -531,7 +507,7 @@ Metrics/ModuleLength: Metrics/ParameterLists: Max: 13 -# Offense count: 14 +# Offense count: 15 # Configuration parameters: IgnoredMethods. Metrics/PerceivedComplexity: Max: 18 @@ -571,7 +547,7 @@ Naming/MemoizedInstanceVariableName: - 'lib/dynflow/testing/in_thread_world.rb' - 'test/test_helper.rb' -# Offense count: 15 +# Offense count: 13 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. # AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to Naming/MethodParameterName: @@ -585,7 +561,6 @@ Naming/MethodParameterName: - 'lib/dynflow/semaphores/dummy.rb' - 'lib/dynflow/semaphores/stateful.rb' - 'lib/dynflow/testing/mimic.rb' - - 'test/semaphores_test.rb' # Offense count: 4 # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. @@ -613,12 +588,6 @@ Naming/RescuedExceptionsVariableName: - 'lib/dynflow/executors/parallel.rb' - 'lib/dynflow/serializable.rb' -# Offense count: 6 -# Configuration parameters: . -# SupportedStyles: snake_case, camelCase -Naming/VariableName: - EnforcedStyle: snake_case - # Offense count: 3 # Configuration parameters: MinSize. Performance/CollectionLiteralInLoop: @@ -1011,14 +980,6 @@ Style/Lambda: - 'test/concurrency_control_test.rb' - 'test/test_helper.rb' -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: call, braces -Style/LambdaCall: - Exclude: - - 'lib/dynflow/action.rb' - # Offense count: 12 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. @@ -1399,7 +1360,7 @@ Style/ZeroLengthPredicate: Exclude: - 'lib/dynflow/flows/abstract.rb' -# Offense count: 87 +# Offense count: 86 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https diff --git a/doc/pages/plugins/tags.rb b/doc/pages/plugins/tags.rb index 77b87f0ce..5c625b42f 100644 --- a/doc/pages/plugins/tags.rb +++ b/doc/pages/plugins/tags.rb @@ -44,7 +44,7 @@ def new_tag(tag, posts) page_name = "#{pretty? ? 'index' : name}#{site.layouts[data['layout']].ext}" site.pages << TagPage.new( - site, site.source, tag_dir, page_name, data + site, site.source, tag_dir, page_name, data ) end } diff --git a/examples/orchestrate.rb b/examples/orchestrate.rb index fdb3a42c6..9e9442c32 100755 --- a/examples/orchestrate.rb +++ b/examples/orchestrate.rb @@ -34,10 +34,10 @@ def plan plan_action(CreateMachine, 'host2', 'storage') end plan_action(CreateMachine, - 'host3', - 'web_server', - :db_machine => 'host1', - :storage_machine => 'host2') + 'host3', + 'web_server', + :db_machine => 'host1', + :storage_machine => 'host2') end end end @@ -47,13 +47,13 @@ class CreateMachine < Dynflow::Action def plan(name, profile, config_options = {}) prepare_disk = plan_action(PrepareDisk, 'name' => name) create_vm = plan_action(CreateVM, - :name => name, - :disk => prepare_disk.output['path']) + :name => name, + :disk => prepare_disk.output['path']) plan_action(AddIPtoHosts, :name => name, :ip => create_vm.output[:ip]) plan_action(ConfigureMachine, - :ip => create_vm.output[:ip], - :profile => profile, - :config_options => config_options) + :ip => create_vm.output[:ip], + :profile => profile, + :config_options => config_options) plan_self(:name => name) end diff --git a/examples/orchestrate_evented.rb b/examples/orchestrate_evented.rb index 8df844dde..eaee901fc 100755 --- a/examples/orchestrate_evented.rb +++ b/examples/orchestrate_evented.rb @@ -34,10 +34,10 @@ def plan(get_stuck = false) plan_action(CreateMachine, 'host2', 'storage') end plan_action(CreateMachine, - 'host3', - 'web_server', - :db_machine => 'host1', - :storage_machine => 'host2') + 'host3', + 'web_server', + :db_machine => 'host1', + :storage_machine => 'host2') end end end @@ -47,13 +47,13 @@ class CreateMachine < Dynflow::Action def plan(name, profile, config_options = {}) prepare_disk = plan_action(PrepareDisk, 'name' => name) create_vm = plan_action(CreateVM, - :name => name, - :disk => prepare_disk.output['path']) + :name => name, + :disk => prepare_disk.output['path']) plan_action(AddIPtoHosts, :name => name, :ip => create_vm.output[:ip]) plan_action(ConfigureMachine, - :ip => create_vm.output[:ip], - :profile => profile, - :config_options => config_options) + :ip => create_vm.output[:ip], + :profile => profile, + :config_options => config_options) plan_self(:name => name) end @@ -68,15 +68,15 @@ class Base < Dynflow::Action def run(event = nil) match(event, - (on Finished do - on_finish - end), - (on Dynflow::Action::Skip do - # do nothing - end), - (on nil do - suspend { |suspended_action| world.clock.ping suspended_action, rand(1), Finished } - end)) + (on Finished do + on_finish + end), + (on Dynflow::Action::Skip do + # do nothing + end), + (on nil do + suspend { |suspended_action| world.clock.ping suspended_action, rand(1), Finished } + end)) end def on_finish diff --git a/lib/dynflow/action.rb b/lib/dynflow/action.rb index 0eeda4478..55ccf1352 100644 --- a/lib/dynflow/action.rb +++ b/lib/dynflow/action.rb @@ -68,9 +68,9 @@ def self.subscribe Skip = Algebrick.atom Phase = Algebrick.type do Executable = type do - variants Plan = atom, - Run = atom, - Finalize = atom + variants Plan = atom, + Run = atom, + Finalize = atom end variants Executable, Present = atom end @@ -78,9 +78,9 @@ def self.subscribe module Executable def execute_method_name match self, - (on Plan, :execute_plan), - (on Run, :execute_run), - (on Finalize, :execute_finalize) + (on Plan, :execute_plan), + (on Run, :execute_run), + (on Finalize, :execute_finalize) end end @@ -105,9 +105,9 @@ def self.constantize(action_name) end attr_reader :world, :phase, :execution_plan_id, :id, :input, - :plan_step_id, :run_step_id, :finalize_step_id, - :caller_execution_plan_id, :caller_action_id, - :pending_output_chunks + :plan_step_id, :run_step_id, :finalize_step_id, + :caller_execution_plan_id, :caller_action_id, + :pending_output_chunks middleware.use Action::Progress::Calculate @@ -268,18 +268,18 @@ def steps def to_hash recursive_to_hash( - { class: self.class.name, - execution_plan_id: execution_plan_id, - id: id, - plan_step_id: plan_step_id, - run_step_id: run_step_id, - finalize_step_id: finalize_step_id, - caller_execution_plan_id: caller_execution_plan_id, - caller_action_id: caller_action_id, - input: input }, - if phase? Run, Finalize, Present - { output: output } - end) + { class: self.class.name, + execution_plan_id: execution_plan_id, + id: id, + plan_step_id: plan_step_id, + run_step_id: run_step_id, + finalize_step_id: finalize_step_id, + caller_execution_plan_id: caller_execution_plan_id, + caller_action_id: caller_action_id, + input: input }, + if phase? Run, Finalize, Present + { output: output } + end) end def state @@ -364,9 +364,9 @@ def delayed_events def state=(state) phase! Executable @world.logger.debug format('%13s %s:%2d %9s >> %9s in phase %8s %s', - 'Step', execution_plan_id, @step.id, - self.state, state, - phase.to_s_humanized, self.class) + 'Step', execution_plan_id, @step.id, + self.state, state, + phase.to_s_humanized, self.class) @step.state = state end @@ -554,7 +554,7 @@ def execute_plan(*args) def execute_run(event) phase! Run @world.logger.debug format('%13s %s:%2d got event %s', - 'Step', execution_plan_id, @step.id, event) if event + 'Step', execution_plan_id, @step.id, event) if event case when state == :running diff --git a/lib/dynflow/action/missing.rb b/lib/dynflow/action/missing.rb index 14c3f89bf..bada6cdcb 100644 --- a/lib/dynflow/action/missing.rb +++ b/lib/dynflow/action/missing.rb @@ -14,17 +14,17 @@ def self.generate(action_name) def plan(*args) raise StandardError, - "The action class was not found and therefore plan phase failed, this can happen if the action was added/renamed but the executor was not restarted." + "The action class was not found and therefore plan phase failed, this can happen if the action was added/renamed but the executor was not restarted." end def run raise StandardError, - "The action class was not found and therefore run phase failed, this can happen if the action was added/renamed but the executor was not restarted." + "The action class was not found and therefore run phase failed, this can happen if the action was added/renamed but the executor was not restarted." end def finalize raise StandardError, - "The action class was not found and therefore finalize phase failed, this can happen if the action was added/renamed but the executor was not restarted." + "The action class was not found and therefore finalize phase failed, this can happen if the action was added/renamed but the executor was not restarted." end end end diff --git a/lib/dynflow/action/with_sub_plans.rb b/lib/dynflow/action/with_sub_plans.rb index 259a32743..e36c82d3b 100644 --- a/lib/dynflow/action/with_sub_plans.rb +++ b/lib/dynflow/action/with_sub_plans.rb @@ -16,23 +16,23 @@ def backtrace def run(event = nil) match event, - (on nil do - if output[:total_count] - resume - else - initiate - end - end), - (on SubPlanFinished do - mark_as_done(event.execution_plan_id, event.success) - try_to_finish or suspend - end), - (on Action::Cancellable::Cancel do - cancel! - end), - (on Action::Cancellable::Abort do - abort! - end) + (on nil do + if output[:total_count] + resume + else + initiate + end + end), + (on SubPlanFinished do + mark_as_done(event.execution_plan_id, event.success) + try_to_finish or suspend + end), + (on Action::Cancellable::Cancel do + cancel! + end), + (on Action::Cancellable::Abort do + abort! + end) end def initiate @@ -109,8 +109,8 @@ def calculate_time_distribution # Assume concurrency level 1 unless stated otherwise level = input[:concurrency_control].fetch(:level, {}).fetch(:free, 1) semaphore = ::Dynflow::Semaphores::Stateful.new(nil, level, - :interval => time.to_f / (count * level), - :time_span => time) + :interval => time.to_f / (count * level), + :time_span => time) input[:concurrency_control][:time] = semaphore.to_hash end end diff --git a/lib/dynflow/connectors/abstract.rb b/lib/dynflow/connectors/abstract.rb index 7ce9604a3..f9f8581a2 100644 --- a/lib/dynflow/connectors/abstract.rb +++ b/lib/dynflow/connectors/abstract.rb @@ -35,16 +35,16 @@ def receive(world, envelope) Type! envelope, Dispatcher::Envelope Telemetry.with_instance { |t| t.increment_counter(:dynflow_connector_envelopes, 1, :world => world.id, :direction => 'incoming') } match(envelope.message, - (on Dispatcher::Ping do - response_envelope = envelope.build_response_envelope(Dispatcher::Pong, world) - send(response_envelope) - end), - (on Dispatcher::Request do - world.executor_dispatcher.tell([:handle_request, envelope]) - end), - (on Dispatcher::Response do - world.client_dispatcher.tell([:dispatch_response, envelope]) - end)) + (on Dispatcher::Ping do + response_envelope = envelope.build_response_envelope(Dispatcher::Pong, world) + send(response_envelope) + end), + (on Dispatcher::Request do + world.executor_dispatcher.tell([:handle_request, envelope]) + end), + (on Dispatcher::Response do + world.client_dispatcher.tell([:dispatch_response, envelope]) + end)) end end end diff --git a/lib/dynflow/delayed_plan.rb b/lib/dynflow/delayed_plan.rb index ee0b974c4..bf3649e3e 100644 --- a/lib/dynflow/delayed_plan.rb +++ b/lib/dynflow/delayed_plan.rb @@ -72,11 +72,11 @@ def args def self.new_from_hash(world, hash, *args) serializer = Utils.constantize(hash[:args_serializer]).new(nil, hash[:serialized_args]) self.new(world, - hash[:execution_plan_uuid], - string_to_time(hash[:start_at]), - string_to_time(hash[:start_before]), - serializer, - hash[:frozen] || false) + hash[:execution_plan_uuid], + string_to_time(hash[:start_at]), + string_to_time(hash[:start_before]), + serializer, + hash[:frozen] || false) rescue NameError => e error(e.message) end diff --git a/lib/dynflow/director.rb b/lib/dynflow/director.rb index 87aad97b4..4b92ff0e9 100644 --- a/lib/dynflow/director.rb +++ b/lib/dynflow/director.rb @@ -75,9 +75,9 @@ def to_hash def self.new_from_hash(hash, *_args) self.new(hash[:execution_plan_id], - Serializable.from_hash(hash[:step], hash[:execution_plan_id], Dynflow.process_world), - hash[:queue], - hash[:sender_orchestrator_id]) + Serializable.from_hash(hash[:step], hash[:execution_plan_id], Dynflow.process_world), + hash[:queue], + hash[:sender_orchestrator_id]) end end @@ -100,11 +100,11 @@ def to_hash def self.new_from_hash(hash, *_args) self.new(hash[:request_id], - hash[:execution_plan_id], - Serializable.from_hash(hash[:step], hash[:execution_plan_id], Dynflow.process_world), - Dynflow.serializer.load(hash[:event]), - hash[:queue], - hash[:sender_orchestrator_id]) + hash[:execution_plan_id], + Serializable.from_hash(hash[:step], hash[:execution_plan_id], Dynflow.process_world), + Dynflow.serializer.load(hash[:event]), + hash[:queue], + hash[:sender_orchestrator_id]) end end @@ -301,12 +301,12 @@ def track_execution_plan(execution_plan_id, finished) if @execution_plan_managers[execution_plan_id] raise Dynflow::Error, - "cannot execute execution_plan_id:#{execution_plan_id} it's already running" + "cannot execute execution_plan_id:#{execution_plan_id} it's already running" end if execution_plan.state == :stopped raise Dynflow::Error, - "cannot execute execution_plan_id:#{execution_plan_id} it's stopped" + "cannot execute execution_plan_id:#{execution_plan_id} it's stopped" end @execution_plan_managers[execution_plan_id] = diff --git a/lib/dynflow/dispatcher.rb b/lib/dynflow/dispatcher.rb index dfea6e504..c9629c5ef 100644 --- a/lib/dynflow/dispatcher.rb +++ b/lib/dynflow/dispatcher.rb @@ -33,10 +33,10 @@ module Dispatcher Response = Algebrick.type do variants Accepted = atom, - Failed = type { fields! error: String }, - Done = atom, - Pong = atom, - ExecutionStatus = type { fields! execution_status: Hash } + Failed = type { fields! error: String }, + Done = atom, + Pong = atom, + ExecutionStatus = type { fields! execution_status: Hash } end Envelope = Algebrick.type do @@ -49,9 +49,9 @@ module Dispatcher module Envelope def build_response_envelope(response_message, sender) Envelope[self.request_id, - sender.id, - self.sender_id, - response_message] + sender.id, + self.sender_id, + response_message] end end diff --git a/lib/dynflow/dispatcher/client_dispatcher.rb b/lib/dynflow/dispatcher/client_dispatcher.rb index fc436660f..023928fce 100644 --- a/lib/dynflow/dispatcher/client_dispatcher.rb +++ b/lib/dynflow/dispatcher/client_dispatcher.rb @@ -134,16 +134,16 @@ def start_termination(*args) def dispatch_request(request, client_world_id, request_id) ignore_unknown = false executor_id = match request, - (on ~Execution | ~Planning do |execution| - AnyExecutor - end), - (on ~Event do |event| - ignore_unknown = event.optional - find_executor(event.execution_plan_id) - end), - (on Ping.(~any, ~any) | Status.(~any, ~any) do |receiver_id, _| - receiver_id - end) + (on ~Execution | ~Planning do |execution| + AnyExecutor + end), + (on ~Event do |event| + ignore_unknown = event.optional + find_executor(event.execution_plan_id) + end), + (on Ping.(~any, ~any) | Status.(~any, ~any) do |receiver_id, _| + receiver_id + end) envelope = Envelope[request_id, client_world_id, executor_id, request] if Dispatcher::UnknownWorld === envelope.receiver_id raise Dynflow::Error, "Could not find an executor for #{envelope}" unless ignore_unknown @@ -161,22 +161,22 @@ def dispatch_request(request, client_world_id, request_id) def dispatch_response(envelope) return unless @tracked_requests.key?(envelope.request_id) match envelope.message, - (on ~Accepted do - @tracked_requests[envelope.request_id].accept! - end), - (on ~Failed do |msg| - resolve_tracked_request(envelope.request_id, Dynflow::Error.new(msg.error)) - end), - (on Done do - resolve_tracked_request(envelope.request_id) - end), - (on Pong do - add_ping_cache_record(envelope.sender_id) - resolve_tracked_request(envelope.request_id) - end), - (on ExecutionStatus.(~any) do |steps| - @tracked_requests.delete(envelope.request_id).success! steps - end) + (on ~Accepted do + @tracked_requests[envelope.request_id].accept! + end), + (on ~Failed do |msg| + resolve_tracked_request(envelope.request_id, Dynflow::Error.new(msg.error)) + end), + (on Done do + resolve_tracked_request(envelope.request_id) + end), + (on Pong do + add_ping_cache_record(envelope.sender_id) + resolve_tracked_request(envelope.request_id) + end), + (on ExecutionStatus.(~any) do |steps| + @tracked_requests.delete(envelope.request_id).success! steps + end) end # Records when was the world with provided id last seen using a PingCache @@ -233,12 +233,12 @@ def resolve_tracked_request(id, error = nil) else tracked_request = @tracked_requests[id] resolve_to = match tracked_request.request, - (on Execution.(execution_plan_id: ~any) do |uuid| - @world.persistence.load_execution_plan(uuid) - end), - (on Event | Ping do - true - end) + (on Execution.(execution_plan_id: ~any) do |uuid| + @world.persistence.load_execution_plan(uuid) + end), + (on Event | Ping do + true + end) @tracked_requests.delete(id).success! resolve_to end end diff --git a/lib/dynflow/dispatcher/executor_dispatcher.rb b/lib/dynflow/dispatcher/executor_dispatcher.rb index d8ae0d12c..a7f3e7a54 100644 --- a/lib/dynflow/dispatcher/executor_dispatcher.rb +++ b/lib/dynflow/dispatcher/executor_dispatcher.rb @@ -9,10 +9,10 @@ def initialize(world, semaphore) def handle_request(envelope) match(envelope.message, - on(Planning) { perform_planning(envelope, envelope.message)}, - on(Execution) { perform_execution(envelope, envelope.message) }, - on(Event) { perform_event(envelope, envelope.message) }, - on(Status) { get_execution_status(envelope, envelope.message) }) + on(Planning) { perform_planning(envelope, envelope.message)}, + on(Execution) { perform_execution(envelope, envelope.message) }, + on(Event) { perform_event(envelope, envelope.message) }, + on(Status) { get_execution_status(envelope, envelope.message) }) end protected @@ -61,13 +61,13 @@ def perform_event(envelope, event_request) end if event_request.time.nil? || event_request.time < Time.now @world.executor.event(envelope.request_id, event_request.execution_plan_id, event_request.step_id, event_request.event, future, - optional: event_request.optional) + optional: event_request.optional) else @world.clock.ping( @world.executor, event_request.time, Director::Event[envelope.request_id, event_request.execution_plan_id, event_request.step_id, event_request.event, Concurrent::Promises.resolvable_future, - event_request.optional], + event_request.optional], :delayed_event ) # resolves the future right away - currently we do not wait for the clock ping diff --git a/lib/dynflow/execution_plan.rb b/lib/dynflow/execution_plan.rb index 787dfeb8c..1aa01f612 100644 --- a/lib/dynflow/execution_plan.rb +++ b/lib/dynflow/execution_plan.rb @@ -11,8 +11,8 @@ class ExecutionPlan < Serializable # at least some data and not running into internal server errors class InvalidPlan attr_reader :exception, :id, :label, :state, - :started_at, :ended_at, - :execution_time, :real_time, :execution_history + :started_at, :ended_at, + :execution_time, :real_time, :execution_history def initialize(exception, id, label, state, started_at = nil, ended_at = nil, @@ -45,8 +45,8 @@ def result require 'dynflow/execution_plan/dependency_graph' attr_reader :id, :world, :label, - :root_plan_step, :steps, :run_flow, :finalize_flow, - :started_at, :ended_at, :execution_time, :real_time, :execution_history + :root_plan_step, :steps, :run_flow, :finalize_flow, + :started_at, :ended_at, :execution_time, :real_time, :execution_history def self.states @states ||= [:pending, :scheduled, :planning, :planned, :running, :paused, :stopped] @@ -130,7 +130,7 @@ def update_state(state, history_notice: :auto) key = failure? ? :failure : :success Dynflow::Telemetry.with_instance do |t| t.increment_counter(:dynflow_finished_execution_plans, 1, - telemetry_common_options.merge(:result => key.to_s)) + telemetry_common_options.merge(:result => key.to_s)) end hooks_to_run << key unlock_all_singleton_locks! @@ -140,11 +140,11 @@ def update_state(state, history_notice: :auto) # ignore end logger.debug format('%13s %s %9s >> %9s', - 'ExecutionPlan', id, original, state) + 'ExecutionPlan', id, original, state) add_history_notice(history_notice) self.save toggle_telemetry_state original == :pending ? nil : original.to_s, - self.state == :stopped ? nil : self.state.to_s + self.state == :stopped ? nil : self.state.to_s hooks_to_run.each { |kind| run_hooks kind } end @@ -257,11 +257,11 @@ def delay(caller_action, action_class, delay_options, *args) run_hooks(:pending) serializer = root_plan_step.delay(delay_options, args) delayed_plan = DelayedPlan.new(@world, - id, - delay_options[:start_at], - delay_options.fetch(:start_before, nil), - serializer, - delay_options[:frozen] || false) + id, + delay_options[:start_at], + delay_options.fetch(:start_before, nil), + serializer, + delay_options[:frozen] || false) persistence.save_delayed_plan(delayed_plan) ensure update_state(error? ? :stopped : :scheduled) @@ -455,36 +455,36 @@ def self.new_from_hash(hash, world) execution_plan_id = hash[:id] steps = steps_from_hash(hash[:step_ids], execution_plan_id, world) self.new(world, - execution_plan_id, - hash[:label], - hash[:state], - steps[hash[:root_plan_step_id]], - load_flow(hash[:run_flow]), - load_flow(hash[:finalize_flow]), - steps, - string_to_time(hash[:started_at]), - string_to_time(hash[:ended_at]), - hash[:execution_time].to_f, - hash[:real_time].to_f, - ExecutionHistory.new_from_hash(hash[:execution_history])) + execution_plan_id, + hash[:label], + hash[:state], + steps[hash[:root_plan_step_id]], + load_flow(hash[:run_flow]), + load_flow(hash[:finalize_flow]), + steps, + string_to_time(hash[:started_at]), + string_to_time(hash[:ended_at]), + hash[:execution_time].to_f, + hash[:real_time].to_f, + ExecutionHistory.new_from_hash(hash[:execution_history])) rescue => plan_exception begin world.logger.error("Could not load execution plan #{execution_plan_id}") world.logger.error(plan_exception) InvalidPlan.new(plan_exception, execution_plan_id, - hash[:label], - hash[:state], - string_to_time(hash[:started_at]), - string_to_time(hash[:ended_at]), - hash[:execution_time].to_f, - hash[:real_time].to_f, - ExecutionHistory.new_from_hash(hash[:execution_history])) + hash[:label], + hash[:state], + string_to_time(hash[:started_at]), + string_to_time(hash[:ended_at]), + hash[:execution_time].to_f, + hash[:real_time].to_f, + ExecutionHistory.new_from_hash(hash[:execution_history])) rescue => invalid_plan_exception world.logger.error("Could not even load a fallback execution plan for #{execution_plan_id}") world.logger.error(invalid_plan_exception) InvalidPlan.new(invalid_plan_exception, execution_plan_id, - hash[:label], - hash[:state]) + hash[:label], + hash[:state]) end end @@ -530,12 +530,12 @@ def persistence def add_step(step_class, action_class, action_id, state = :pending) step_class.new(self.id, - self.generate_step_id, - state, - action_class, - action_id, - nil, - world).tap do |new_step| + self.generate_step_id, + state, + action_class, + action_id, + nil, + world).tap do |new_step| @steps[new_step.id] = new_step end end @@ -571,9 +571,9 @@ def toggle_telemetry_state(original, new) @label = root_plan_step.action_class if @label.nil? Dynflow::Telemetry.with_instance do |t| t.set_gauge(:dynflow_active_execution_plans, '-1', - telemetry_common_options.merge(:state => original)) unless original.nil? + telemetry_common_options.merge(:state => original)) unless original.nil? t.set_gauge(:dynflow_active_execution_plans, '+1', - telemetry_common_options.merge(:state => new)) unless new.nil? + telemetry_common_options.merge(:state => new)) unless new.nil? end end diff --git a/lib/dynflow/execution_plan/output_reference.rb b/lib/dynflow/execution_plan/output_reference.rb index af7242838..462303773 100644 --- a/lib/dynflow/execution_plan/output_reference.rb +++ b/lib/dynflow/execution_plan/output_reference.rb @@ -77,9 +77,9 @@ def dereference(persistence) def self.new_from_hash(hash) check_class_matching hash new(hash.fetch(:execution_plan_id), - hash.fetch(:step_id), - hash.fetch(:action_id), - hash.fetch(:subkeys)) + hash.fetch(:step_id), + hash.fetch(:action_id), + hash.fetch(:subkeys)) end end diff --git a/lib/dynflow/execution_plan/steps/abstract.rb b/lib/dynflow/execution_plan/steps/abstract.rb index 38fedd428..2b9579a3b 100644 --- a/lib/dynflow/execution_plan/steps/abstract.rb +++ b/lib/dynflow/execution_plan/steps/abstract.rb @@ -6,7 +6,7 @@ class Abstract < Serializable include Stateful attr_reader :execution_plan_id, :id, :state, :action_class, :action_id, :world, :started_at, - :ended_at, :execution_time, :real_time, :queue, :delayed_events + :ended_at, :execution_time, :real_time, :queue, :delayed_events attr_accessor :error # rubocop:disable Metrics/ParameterLists @@ -144,19 +144,19 @@ def with_sub_plans? def self.new_from_hash(hash, execution_plan_id, world) check_class_matching hash new(execution_plan_id, - hash[:id], - hash[:state], - Action.constantize(hash[:action_class]), - hash[:action_id], - hash_to_error(hash[:error]), - world, - string_to_time(hash[:started_at]), - string_to_time(hash[:ended_at]), - hash[:execution_time].to_f, - hash[:real_time].to_f, - hash[:progress_done].to_f, - hash[:progress_weight].to_f, - (hash[:queue] && hash[:queue].to_sym)) + hash[:id], + hash[:state], + Action.constantize(hash[:action_class]), + hash[:action_id], + hash_to_error(hash[:error]), + world, + string_to_time(hash[:started_at]), + string_to_time(hash[:ended_at]), + hash[:execution_time].to_f, + hash[:real_time].to_f, + hash[:progress_done].to_f, + hash[:progress_weight].to_f, + (hash[:queue] && hash[:queue].to_sym)) end private @@ -186,12 +186,12 @@ def update_step_telemetry(current_execution_time) Dynflow::Telemetry.with_instance do |t| if [:success, :skipped].include?(state) t.observe_histogram(:dynflow_step_real_time, - real_time * 1000, - :action => action_class.to_s, :phase => phase.to_s_humanized) + real_time * 1000, + :action => action_class.to_s, :phase => phase.to_s_humanized) end t.observe_histogram(:dynflow_step_execution_time, - current_execution_time * 1000, - :action => action_class.to_s, :phase => phase.to_s_humanized) + current_execution_time * 1000, + :action => action_class.to_s, :phase => phase.to_s_humanized) end end end diff --git a/lib/dynflow/execution_plan/steps/error.rb b/lib/dynflow/execution_plan/steps/error.rb index c6ea2d400..674c7294d 100644 --- a/lib/dynflow/execution_plan/steps/error.rb +++ b/lib/dynflow/execution_plan/steps/error.rb @@ -11,12 +11,12 @@ def self.new(*args) case args.size when 1 match obj = args.first, - (on String do - super(StandardError, obj, caller, nil) - end), - (on Exception do - super(obj.class, obj.message, obj.backtrace, obj) - end) + (on String do + super(StandardError, obj, caller, nil) + end), + (on Exception do + super(obj.class, obj.message, obj.backtrace, obj) + end) when 3, 4 super(*args.values_at(0..3)) else @@ -49,9 +49,9 @@ def to_hash def to_s format '%s (%s)\n%s', - (@exception || self).message, - (@exception ? @exception.class : exception_class), - (@exception || self).backtrace + (@exception || self).message, + (@exception ? @exception.class : exception_class), + (@exception || self).backtrace end def exception diff --git a/lib/dynflow/execution_plan/steps/plan_step.rb b/lib/dynflow/execution_plan/steps/plan_step.rb index ebe694bab..969f5a363 100644 --- a/lib/dynflow/execution_plan/steps/plan_step.rb +++ b/lib/dynflow/execution_plan/steps/plan_step.rb @@ -73,17 +73,17 @@ def self.state_transitions def self.new_from_hash(hash, execution_plan_id, world) check_class_matching hash new execution_plan_id, - hash[:id], - hash[:state], - Action.constantize(hash[:action_class]), - hash[:action_id], - hash_to_error(hash[:error]), - world, - string_to_time(hash[:started_at]), - string_to_time(hash[:ended_at]), - hash[:execution_time], - hash[:real_time], - hash[:children] + hash[:id], + hash[:state], + Action.constantize(hash[:action_class]), + hash[:action_id], + hash_to_error(hash[:error]), + world, + string_to_time(hash[:started_at]), + string_to_time(hash[:ended_at]), + hash[:execution_time], + hash[:real_time], + hash[:children] end def load_action diff --git a/lib/dynflow/executors/abstract/core.rb b/lib/dynflow/executors/abstract/core.rb index cbac0568d..62919e3d3 100644 --- a/lib/dynflow/executors/abstract/core.rb +++ b/lib/dynflow/executors/abstract/core.rb @@ -20,7 +20,7 @@ def initialize(world, heartbeat_interval, queues_options) def handle_execution(execution_plan_id, finished) if terminating? raise Dynflow::Error, - "cannot accept execution_plan_id:#{execution_plan_id} core is terminating" + "cannot accept execution_plan_id:#{execution_plan_id} core is terminating" end handle_work(@director.start_execution(execution_plan_id, finished)) @@ -30,7 +30,7 @@ def handle_event(event) Type! event, Director::Event if terminating? raise Dynflow::Error, - "cannot accept event: #{event} core is terminating" + "cannot accept event: #{event} core is terminating" end handle_work(@director.handle_event(event)) end @@ -38,7 +38,7 @@ def handle_event(event) def handle_planning(execution_plan_id) if terminating? raise Dynflow::Error, - "cannot accept event: #{event} core is terminating" + "cannot accept event: #{event} core is terminating" end handle_work(@director.handle_planning(execution_plan_id)) diff --git a/lib/dynflow/executors/parallel/core.rb b/lib/dynflow/executors/parallel/core.rb index 33aa9c147..aa10ae3e1 100644 --- a/lib/dynflow/executors/parallel/core.rb +++ b/lib/dynflow/executors/parallel/core.rb @@ -19,8 +19,8 @@ def initialize_queues @queues_options.each do |(queue_name, queue_options)| queue_pool_size = queue_options.fetch(:pool_size, default_pool_size) @pools[queue_name] = Pool.spawn("pool #{queue_name}", @world, - reference, queue_name, queue_pool_size, - @world.transaction_adapter) + reference, queue_name, queue_pool_size, + @world.transaction_adapter) end end diff --git a/lib/dynflow/extensions/msgpack.rb b/lib/dynflow/extensions/msgpack.rb index c4b542c5c..22ff27cdb 100644 --- a/lib/dynflow/extensions/msgpack.rb +++ b/lib/dynflow/extensions/msgpack.rb @@ -25,13 +25,13 @@ def to_msgpack(out = ''.dup) ::DateTime.include ::Dynflow::Extensions::MsgPack::Time ::MessagePack::DefaultFactory.register_type(0x02, DateTime, - packer: ->(datetime) { MessagePack::Time::Packer.(datetime.to_time) }, - unpacker: ->(payload) { unpacker.(payload).to_datetime }) + packer: ->(datetime) { MessagePack::Time::Packer.(datetime.to_time) }, + unpacker: ->(payload) { unpacker.(payload).to_datetime }) ::Date.include ::Dynflow::Extensions::MsgPack::Time ::MessagePack::DefaultFactory.register_type(0x03, Date, - packer: ->(date) { MessagePack::Time::Packer.(date.to_time) }, - unpacker: ->(payload) { unpacker.(payload).to_date }) + packer: ->(date) { MessagePack::Time::Packer.(date.to_time) }, + unpacker: ->(payload) { unpacker.(payload).to_date }) rescue LoadError # This is fine nil diff --git a/lib/dynflow/logger_adapters/simple.rb b/lib/dynflow/logger_adapters/simple.rb index b0979f4d6..4e128dd83 100644 --- a/lib/dynflow/logger_adapters/simple.rb +++ b/lib/dynflow/logger_adapters/simple.rb @@ -28,11 +28,11 @@ def level=(v) def formatter(severity, datetime, prog_name, msg) format "[%s #%d] %5s -- %s%s\n", - datetime.strftime('%Y-%m-%d %H:%M:%S.%L'), - $PID, - severity, - (prog_name ? prog_name + ': ' : ''), - msg.to_s + datetime.strftime('%Y-%m-%d %H:%M:%S.%L'), + $PID, + severity, + (prog_name ? prog_name + ': ' : ''), + msg.to_s end class ProgNameWrapper diff --git a/lib/dynflow/persistence_adapters/sequel.rb b/lib/dynflow/persistence_adapters/sequel.rb index 5b1e1785c..093d46b4f 100644 --- a/lib/dynflow/persistence_adapters/sequel.rb +++ b/lib/dynflow/persistence_adapters/sequel.rb @@ -67,10 +67,10 @@ def find_execution_plans(options = {}) table_name = :execution_plan options[:order_by] ||= :started_at data_set = filter(table_name, - order(table_name, - paginate(table(table_name), options), - options), - options[:filters]) + order(table_name, + paginate(table(table_name), options), + options), + options[:filters]) data_set.all.map { |record| execution_plan_column_map(load_data(record, table_name)) } end @@ -169,7 +169,7 @@ def load_steps(execution_plan_id) def save_step(execution_plan_id, step_id, value, update_conditions = {}) save :step, { execution_plan_uuid: execution_plan_id, id: step_id }, value, - with_data: false, update_conditions: update_conditions + with_data: false, update_conditions: update_conditions end def load_action(execution_plan_id, action_id) diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/001_initial.rb b/lib/dynflow/persistence_adapters/sequel_migrations/001_initial.rb index 1263c40ba..854a06090 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/001_initial.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/001_initial.rb @@ -33,7 +33,7 @@ index [:execution_plan_uuid, :id], :unique => true column :action_id, Integer foreign_key [:execution_plan_uuid, :action_id], :dynflow_actions, - name: :dynflow_steps_execution_plan_uuid_fkey1 + name: :dynflow_steps_execution_plan_uuid_fkey1 index [:execution_plan_uuid, :action_id] column :data, String, text: true diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb b/lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb index 5b648d801..69d23e1b8 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb @@ -30,11 +30,11 @@ def with_foreign_key_recreation(&block) alter_table :dynflow_steps do add_foreign_key [:execution_plan_uuid], :dynflow_execution_plans add_foreign_key [:execution_plan_uuid, :action_id], :dynflow_actions, - :name => :dynflow_steps_execution_plan_uuid_fkey1 + :name => :dynflow_steps_execution_plan_uuid_fkey1 end alter_table :dynflow_delayed_plans do add_foreign_key [:execution_plan_uuid], :dynflow_execution_plans, - :name => :dynflow_scheduled_plans_execution_plan_uuid_fkey + :name => :dynflow_scheduled_plans_execution_plan_uuid_fkey end end end diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb b/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb index 72fe0fa0d..9a004efac 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb @@ -15,7 +15,7 @@ column :action_id, Integer, null: false foreign_key [:execution_plan_uuid, :action_id], :dynflow_actions, - name: :dynflow_output_chunks_execution_plan_uuid_fkey1 + name: :dynflow_output_chunks_execution_plan_uuid_fkey1 index [:execution_plan_uuid, :action_id] column :chunk, String, text: true diff --git a/lib/dynflow/telemetry.rb b/lib/dynflow/telemetry.rb index cb5eed537..d8c848bd4 100644 --- a/lib/dynflow/telemetry.rb +++ b/lib/dynflow/telemetry.rb @@ -33,32 +33,32 @@ def register_metrics! with_instance do |t| # Worker related t.add_gauge :dynflow_active_workers, 'The number of currently busy workers', - [:queue, :world] + [:queue, :world] t.add_counter :dynflow_worker_events, 'The number of processed events', - [:queue, :world, :worker] + [:queue, :world, :worker] # Execution plan related t.add_gauge :dynflow_active_execution_plans, 'The number of active execution plans', - [:action, :world, :state] + [:action, :world, :state] t.add_gauge :dynflow_queue_size, 'Number of items in queue', - [:queue, :world] + [:queue, :world] t.add_counter :dynflow_finished_execution_plans, 'The number of execution plans', - [:action, :world, :result] + [:action, :world, :result] # Step related # TODO: Configure buckets in a sane manner t.add_histogram :dynflow_step_real_time, 'The time between the start end end of the step', - [:action, :phase] + [:action, :phase] t.add_histogram :dynflow_step_execution_time, 'The time spent executing a step', - [:action, :phase] + [:action, :phase] # Connector related t.add_counter :dynflow_connector_envelopes, 'The number of envelopes handled by a connector', - [:world, :direction] + [:world, :direction] # Persistence related t.add_histogram :dynflow_persistence, 'The time spent communicating with the database', - [:world, :method] + [:world, :method] end end end diff --git a/lib/dynflow/testing/assertions.rb b/lib/dynflow/testing/assertions.rb index a3faecacc..3c048e795 100644 --- a/lib/dynflow/testing/assertions.rb +++ b/lib/dynflow/testing/assertions.rb @@ -15,8 +15,8 @@ def assert_action_planned_with(action, planned_action_class, *plan_input, &block end assert(!found.empty?, - "Action #{planned_action_class} with plan_input #{plan_input} was not planned, " + - "there were only #{found_classes.map(&:plan_input)}") + "Action #{planned_action_class} with plan_input #{plan_input} was not planned, " + + "there were only #{found_classes.map(&:plan_input)}") found end diff --git a/lib/dynflow/testing/dummy_planned_action.rb b/lib/dynflow/testing/dummy_planned_action.rb index c9b552a67..431518f3c 100644 --- a/lib/dynflow/testing/dummy_planned_action.rb +++ b/lib/dynflow/testing/dummy_planned_action.rb @@ -8,7 +8,7 @@ class DummyPlannedAction def initialize(klass) mimic! klass @output = ExecutionPlan::OutputReference.new( - Testing.get_id.to_s, Testing.get_id, Testing.get_id) + Testing.get_id.to_s, Testing.get_id, Testing.get_id) end def execute(execution_plan, event, from_subscription, *args) diff --git a/lib/dynflow/testing/factories.rb b/lib/dynflow/testing/factories.rb index d6d856224..59ea3aad6 100644 --- a/lib/dynflow/testing/factories.rb +++ b/lib/dynflow/testing/factories.rb @@ -9,14 +9,14 @@ def create_action(action_class, trigger = nil) execution_plan = DummyExecutionPlan.new step = DummyStep.new action_class.new( - { step: DummyStep.new, - execution_plan_id: execution_plan.id, - id: Testing.get_id, - phase: Action::Plan, - plan_step_id: step.id, - run_step_id: nil, - finalize_step_id: nil }, - execution_plan.world).tap do |action| + { step: DummyStep.new, + execution_plan_id: execution_plan.id, + id: Testing.get_id, + phase: Action::Plan, + plan_step_id: step.id, + run_step_id: nil, + finalize_step_id: nil }, + execution_plan.world).tap do |action| action.set_plan_context(execution_plan, trigger, false) end end @@ -24,15 +24,15 @@ def create_action(action_class, trigger = nil) def create_action_presentation(action_class) execution_plan = DummyExecutionPlan.new action_class.new( - { execution_plan: execution_plan, - execution_plan_id: execution_plan.id, - id: Testing.get_id, - phase: Action::Present, - plan_step_id: 1, - run_step_id: nil, - finalize_step_id: nil, - input: nil }, - execution_plan.world) + { execution_plan: execution_plan, + execution_plan_id: execution_plan.id, + id: Testing.get_id, + phase: Action::Present, + plan_step_id: 1, + run_step_id: nil, + finalize_step_id: nil, + input: nil }, + execution_plan.world) end # @return [Action::PlanPhase] @@ -58,15 +58,15 @@ def run_action(plan_action, event = nil, &stubbing) step = DummyStep.new run_action = if plan_action.phase == Action::Plan plan_action.class.new( - { step: step, - execution_plan_id: plan_action.execution_plan_id, - id: plan_action.id, - plan_step_id: plan_action.plan_step_id, - run_step_id: step.id, - finalize_step_id: nil, - phase: Action::Run, - input: plan_action.input }, - plan_action.world) + { step: step, + execution_plan_id: plan_action.execution_plan_id, + id: plan_action.id, + plan_step_id: plan_action.plan_step_id, + run_step_id: step.id, + finalize_step_id: nil, + phase: Action::Run, + input: plan_action.input }, + plan_action.world) else plan_action @@ -85,15 +85,15 @@ def finalize_action(run_action, &stubbing) Match! run_action.phase, Action::Plan, Action::Run step = DummyStep.new finalize_action = run_action.class.new( - { step: step, - execution_plan_id: run_action.execution_plan_id, - id: run_action.id, - plan_step_id: run_action.plan_step_id, - run_step_id: run_action.run_step_id, - finalize_step_id: step.id, - phase: Action::Finalize, - input: run_action.input }, - run_action.world) + { step: step, + execution_plan_id: run_action.execution_plan_id, + id: run_action.id, + plan_step_id: run_action.plan_step_id, + run_step_id: run_action.run_step_id, + finalize_step_id: step.id, + phase: Action::Finalize, + input: run_action.input }, + run_action.world) stubbing.call finalize_action if stubbing finalize_action.execute diff --git a/lib/dynflow/world.rb b/lib/dynflow/world.rb index bf0a1ba31..ac1f2c7ee 100644 --- a/lib/dynflow/world.rb +++ b/lib/dynflow/world.rb @@ -9,10 +9,10 @@ class World include Invalidation attr_reader :id, :config, :client_dispatcher, :executor_dispatcher, :executor, :connector, - :transaction_adapter, :logger_adapter, :coordinator, - :persistence, :action_classes, :subscription_index, - :middleware, :auto_rescue, :clock, :meta, :delayed_executor, :auto_validity_check, :validity_check_timeout, :throttle_limiter, - :termination_timeout, :terminated, :dead_letter_handler, :execution_plan_cleaner + :transaction_adapter, :logger_adapter, :coordinator, + :persistence, :action_classes, :subscription_index, + :middleware, :auto_rescue, :clock, :meta, :delayed_executor, :auto_validity_check, :validity_check_timeout, :throttle_limiter, + :termination_timeout, :terminated, :dead_letter_handler, :execution_plan_cleaner def initialize(config) @config = Config::ForWorld.new(config, self) @@ -27,14 +27,14 @@ def initialize(config) @config.validate @transaction_adapter = @config.transaction_adapter @persistence = Persistence.new(self, @config.persistence_adapter, - :backup_deleted_plans => @config.backup_deleted_plans, - :backup_dir => @config.backup_dir) + :backup_deleted_plans => @config.backup_deleted_plans, + :backup_dir => @config.backup_dir) @coordinator = Coordinator.new(@config.coordinator_adapter) if @config.executor @executor = Executors::Parallel.new(self, - executor_class: @config.executor, - heartbeat_interval: @config.executor_heartbeat_interval, - queues_options: @config.queues) + executor_class: @config.executor, + heartbeat_interval: @config.executor_heartbeat_interval, + queues_options: @config.queues) end @action_classes = @config.action_classes @auto_rescue = @config.auto_rescue diff --git a/test/action_test.rb b/test/action_test.rb index e24504d0f..908129635 100644 --- a/test/action_test.rb +++ b/test/action_test.rb @@ -199,7 +199,7 @@ class TestPollingAction < Dynflow::Action class Config attr_accessor :external_service, :poll_max_retries, - :poll_intervals, :attempts_before_next_interval + :poll_intervals, :attempts_before_next_interval def initialize @external_service = ExternalService.new diff --git a/test/execution_plan_test.rb b/test/execution_plan_test.rb index 8ef43e9f8..eae66fce8 100644 --- a/test/execution_plan_test.rb +++ b/test/execution_plan_test.rb @@ -51,17 +51,17 @@ module ExecutionPlanTest assert_equal Dynflow::Errors::DataConsistencyError, deserialized_execution_plan.exception.class [:label, :state, :started_at, :ended_at].each do |attr| assert_equal execution_plan.send(attr).to_s, - deserialized_execution_plan.send(attr).to_s, - "invalid plan is supposed to still store #{attr}" + deserialized_execution_plan.send(attr).to_s, + "invalid plan is supposed to still store #{attr}" end [:execution_time, :real_time].each do |attr| assert_equal execution_plan.send(attr).to_f, - deserialized_execution_plan.send(attr).to_f, - "invalid plan is supposed to still store #{attr}" + deserialized_execution_plan.send(attr).to_f, + "invalid plan is supposed to still store #{attr}" end assert_equal execution_plan.execution_history.events, - deserialized_execution_plan.execution_history.events, - "invalid plan is supposed to still store execution history" + deserialized_execution_plan.execution_history.events, + "invalid plan is supposed to still store execution history" end end diff --git a/test/executor_test.rb b/test/executor_test.rb index 1e4840abe..4b3d09348 100644 --- a/test/executor_test.rb +++ b/test/executor_test.rb @@ -230,8 +230,8 @@ def persisted_plan describe 'handling errors in setup' do let :execution_plan do world.plan(Support::DummyExample::Polling, - external_task_id: '123', - text: 'troll setup') + external_task_id: '123', + text: 'troll setup') end it 'fails' do @@ -310,8 +310,8 @@ def persisted_plan describe 'plan with one action' do let :execution_plan do world.plan(Support::DummyExample::Polling, - { external_task_id: '123', - text: 'pause in progress 20%' }) + { external_task_id: '123', + text: 'pause in progress 20%' }) end it 'determines the progress of the execution plan in percents' do @@ -325,8 +325,8 @@ def persisted_plan describe 'plan with more action' do let :execution_plan do world.plan(Support::DummyExample::WeightedPolling, - { external_task_id: '123', - text: 'pause in progress 20%' }) + { external_task_id: '123', + text: 'pause in progress 20%' }) end it 'takes the steps weight in account' do @@ -341,8 +341,8 @@ def persisted_plan describe 'works when resumed after error' do let :execution_plan do world.plan(Support::DummyExample::Polling, - { external_task_id: '123', - text: 'troll progress' }) + { external_task_id: '123', + text: 'troll progress' }) end specify do @@ -438,10 +438,10 @@ def persisted_plan it "runs all the steps in the finalize flow" do assert_finalized(Support::CodeWorkflowExample::IncomingIssues, - { "issues" => [{ "author" => "Peter Smith", "text" => "Failing test" }, - { "author" => "John Doe", "text" => "Internal server error" }] }) + { "issues" => [{ "author" => "Peter Smith", "text" => "Failing test" }, + { "author" => "John Doe", "text" => "Internal server error" }] }) assert_finalized(Support::CodeWorkflowExample::Triage, - { "author" => "Peter Smith", "text" => "Failing test" }) + { "author" => "Peter Smith", "text" => "Failing test" }) end end diff --git a/test/middleware_test.rb b/test/middleware_test.rb index a1bf614ab..05459baaf 100644 --- a/test/middleware_test.rb +++ b/test/middleware_test.rb @@ -77,7 +77,7 @@ module MiddlewareTest let(:world_with_middleware) do WorldFactory.create_world.tap do |world| world.middleware.use(Support::MiddlewareExample::AnotherLogRunMiddleware, - after: Support::MiddlewareExample::LogRunMiddleware) + after: Support::MiddlewareExample::LogRunMiddleware) end end @@ -112,7 +112,7 @@ module MiddlewareTest it "allows access the running action" do world = WorldFactory.create_world world.middleware.use(Support::MiddlewareExample::ObservingMiddleware, - replace: Support::MiddlewareExample::LogRunMiddleware) + replace: Support::MiddlewareExample::LogRunMiddleware) world.trigger(Support::MiddlewareExample::Action, message: 'hello').finished.wait _(log).must_equal %w[input#message:hello run @@ -122,7 +122,7 @@ module MiddlewareTest it "allows modification of the running action when delaying execution" do world = WorldFactory.create_world world.middleware.use(Support::MiddlewareExample::AnotherObservingMiddleware, - replace: Support::MiddlewareExample::LogRunMiddleware) + replace: Support::MiddlewareExample::LogRunMiddleware) delay = world.delay(Support::MiddlewareExample::Action, { :start_at => Time.now - 60 }) plan = world.persistence.load_delayed_plan delay.execution_plan_id plan.plan diff --git a/test/persistence_test.rb b/test/persistence_test.rb index 16f7f3f5d..6229cf823 100644 --- a/test/persistence_test.rb +++ b/test/persistence_test.rb @@ -150,9 +150,9 @@ def self.it_acts_as_persistence_adapter _(loaded_plans).must_be_empty adapter.save_delayed_plan('plan1', - :execution_plan_uuid => 'plan1', - :start_at => format_time(Time.now + 60), - :start_before => format_time(Time.now - 60)) + :execution_plan_uuid => 'plan1', + :start_at => format_time(Time.now + 60), + :start_before => format_time(Time.now - 60)) loaded_plans = adapter.find_execution_plans(filters: { label: ['test1'], :delayed => true }) _(loaded_plans.map { |h| h[:id] }).must_equal ['plan1'] end @@ -229,9 +229,9 @@ def self.it_acts_as_persistence_adapter _(loaded_plans).must_equal 0 adapter.save_delayed_plan('plan1', - :execution_plan_uuid => 'plan1', - :start_at => format_time(Time.now + 60), - :start_before => format_time(Time.now - 60)) + :execution_plan_uuid => 'plan1', + :start_at => format_time(Time.now + 60), + :start_before => format_time(Time.now - 60)) loaded_plans = adapter.find_execution_plan_counts(filters: { label: ['test1'], :delayed => true }) _(loaded_plans).must_equal 1 end diff --git a/test/support/code_workflow_example.rb b/test/support/code_workflow_example.rb index c181bdc49..a6ae18f6d 100644 --- a/test/support/code_workflow_example.rb +++ b/test/support/code_workflow_example.rb @@ -55,10 +55,10 @@ class Triage < Dynflow::Action def plan(issue) triage = plan_self(issue) plan_action(UpdateIssue, - author: triage.input[:author], - text: triage.input[:text], - assignee: triage.output[:classification][:assignee], - severity: triage.output[:classification][:severity]) + author: triage.input[:author], + text: triage.input[:text], + assignee: triage.output[:classification][:assignee], + severity: triage.output[:classification][:severity]) end input_format do @@ -137,9 +137,9 @@ def plan(commit, reviews = { 'Morfeus' => true, 'Neo' => true }) end plan_action(Merge, - commit: commit, - ci_result: ci.output[:passed], - review_results: review_actions.map { |ra| ra.output[:passed] }) + commit: commit, + ci_result: ci.output[:passed], + review_results: review_actions.map { |ra| ra.output[:passed] }) end end end @@ -154,9 +154,9 @@ def plan(commit) end plan_action(Merge, - commit: commit, - ci_result: ci.output[:passed], - review_results: [review.output[:passed]]) + commit: commit, + ci_result: ci.output[:passed], + review_results: [review.output[:passed]]) end end diff --git a/test/support/dummy_example.rb b/test/support/dummy_example.rb index a278ea416..d1ed07349 100644 --- a/test/support/dummy_example.rb +++ b/test/support/dummy_example.rb @@ -148,23 +148,23 @@ def run(event = nil) class ComposedAction < Dynflow::Action def run(event = nil) match event, - (on nil do - sub_plan = world.trigger(Dummy) - output[:sub_plan_id] = sub_plan.id - suspend do |suspended_action| - if input[:timeout] - world.clock.ping suspended_action, input[:timeout], "timeout" - end - - sub_plan.finished.on_fulfillment! { suspended_action << 'finish' } - end - end), - (on 'finish' do - output[:event] = 'finish' - end), - (on 'timeout' do - output[:event] = 'timeout' - end) + (on nil do + sub_plan = world.trigger(Dummy) + output[:sub_plan_id] = sub_plan.id + suspend do |suspended_action| + if input[:timeout] + world.clock.ping suspended_action, input[:timeout], "timeout" + end + + sub_plan.finished.on_fulfillment! { suspended_action << 'finish' } + end + end), + (on 'finish' do + output[:event] = 'finish' + end), + (on 'timeout' do + output[:event] = 'timeout' + end) end end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 3f683cd33..f6f705028 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -230,7 +230,7 @@ def assert_plan_reexecuted(plan) 'terminate execution', 'start execution', 'finish execution'], - plan.execution_history.map(&:name) + plan.execution_history.map(&:name) refute_equal plan.execution_history.first.world_id, plan.execution_history.to_a.last.world_id end end From 993ba8cf036d907067de288380e9bee21b0dc7cb Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Fri, 26 Jan 2024 15:00:15 +0100 Subject: [PATCH 09/44] Fix Layout/EmptyLineAfterMagicComment cop --- .rubocop_todo.yml | 7 +------ Gemfile | 1 + Rakefile | 1 + doc/pages/Gemfile | 1 + doc/pages/Rakefile | 1 + doc/pages/plugins/alert_block.rb | 1 + doc/pages/plugins/div_tag.rb | 1 + doc/pages/plugins/graphviz.rb | 1 + doc/pages/plugins/plantuml.rb | 1 + doc/pages/plugins/play.rb | 1 + doc/pages/plugins/tags.rb | 1 + doc/pages/plugins/toc.rb | 1 + dynflow.gemspec | 1 + examples/clock_benchmark.rb | 1 + examples/example_helper.rb | 1 + examples/singletons.rb | 1 + examples/sub_plans.rb | 1 + examples/sub_plans_v2.rb | 1 + lib/dynflow.rb | 1 + lib/dynflow/action.rb | 1 + lib/dynflow/action/cancellable.rb | 1 + lib/dynflow/action/format.rb | 1 + lib/dynflow/action/missing.rb | 1 + lib/dynflow/action/polling.rb | 1 + lib/dynflow/action/progress.rb | 1 + lib/dynflow/action/rescue.rb | 1 + lib/dynflow/action/singleton.rb | 1 + lib/dynflow/action/suspended.rb | 1 + lib/dynflow/action/timeouts.rb | 1 + lib/dynflow/action/with_bulk_sub_plans.rb | 1 + lib/dynflow/action/with_polling_sub_plans.rb | 1 + lib/dynflow/action/with_sub_plans.rb | 1 + lib/dynflow/active_job/queue_adapter.rb | 1 + lib/dynflow/actor.rb | 1 + lib/dynflow/actors.rb | 1 + lib/dynflow/actors/execution_plan_cleaner.rb | 1 + lib/dynflow/clock.rb | 1 + lib/dynflow/config.rb | 1 + lib/dynflow/connectors.rb | 1 + lib/dynflow/connectors/abstract.rb | 1 + lib/dynflow/connectors/database.rb | 1 + lib/dynflow/connectors/direct.rb | 1 + lib/dynflow/coordinator.rb | 1 + lib/dynflow/coordinator_adapters.rb | 1 + lib/dynflow/coordinator_adapters/abstract.rb | 1 + lib/dynflow/coordinator_adapters/sequel.rb | 1 + lib/dynflow/dead_letter_silencer.rb | 1 + lib/dynflow/debug/telemetry/persistence.rb | 1 + lib/dynflow/delayed_executors.rb | 1 + lib/dynflow/delayed_executors/abstract.rb | 1 + lib/dynflow/delayed_executors/abstract_core.rb | 1 + lib/dynflow/delayed_executors/polling.rb | 1 + lib/dynflow/delayed_plan.rb | 1 + lib/dynflow/director.rb | 1 + lib/dynflow/director/execution_plan_manager.rb | 1 + lib/dynflow/director/flow_manager.rb | 1 + lib/dynflow/director/queue_hash.rb | 1 + lib/dynflow/director/running_steps_manager.rb | 1 + lib/dynflow/director/sequence_cursor.rb | 1 + lib/dynflow/director/sequential_manager.rb | 1 + lib/dynflow/dispatcher.rb | 1 + lib/dynflow/dispatcher/abstract.rb | 1 + lib/dynflow/dispatcher/client_dispatcher.rb | 1 + lib/dynflow/dispatcher/executor_dispatcher.rb | 1 + lib/dynflow/errors.rb | 1 + lib/dynflow/execution_history.rb | 1 + lib/dynflow/execution_plan.rb | 1 + lib/dynflow/execution_plan/dependency_graph.rb | 1 + lib/dynflow/execution_plan/hooks.rb | 1 + lib/dynflow/execution_plan/output_reference.rb | 1 + lib/dynflow/execution_plan/steps.rb | 1 + lib/dynflow/execution_plan/steps/abstract.rb | 1 + lib/dynflow/execution_plan/steps/abstract_flow_step.rb | 1 + lib/dynflow/execution_plan/steps/error.rb | 1 + lib/dynflow/execution_plan/steps/finalize_step.rb | 1 + lib/dynflow/execution_plan/steps/plan_step.rb | 1 + lib/dynflow/execution_plan/steps/run_step.rb | 1 + lib/dynflow/executors.rb | 1 + lib/dynflow/executors/abstract/core.rb | 1 + lib/dynflow/executors/parallel.rb | 1 + lib/dynflow/executors/parallel/core.rb | 1 + lib/dynflow/executors/parallel/pool.rb | 1 + lib/dynflow/executors/parallel/worker.rb | 1 + lib/dynflow/executors/sidekiq/core.rb | 1 + lib/dynflow/executors/sidekiq/internal_job_base.rb | 1 + lib/dynflow/executors/sidekiq/orchestrator_jobs.rb | 1 + lib/dynflow/executors/sidekiq/redis_locking.rb | 1 + lib/dynflow/executors/sidekiq/serialization.rb | 1 + lib/dynflow/executors/sidekiq/worker_jobs.rb | 1 + lib/dynflow/extensions.rb | 1 + lib/dynflow/extensions/msgpack.rb | 1 + lib/dynflow/flows.rb | 1 + lib/dynflow/flows/abstract.rb | 1 + lib/dynflow/flows/abstract_composed.rb | 1 + lib/dynflow/flows/atom.rb | 1 + lib/dynflow/flows/concurrence.rb | 1 + lib/dynflow/flows/registry.rb | 1 + lib/dynflow/flows/sequence.rb | 1 + lib/dynflow/logger_adapters.rb | 1 + lib/dynflow/logger_adapters/abstract.rb | 1 + lib/dynflow/logger_adapters/delegator.rb | 1 + lib/dynflow/logger_adapters/formatters.rb | 1 + lib/dynflow/logger_adapters/formatters/abstract.rb | 1 + lib/dynflow/logger_adapters/formatters/exception.rb | 1 + lib/dynflow/logger_adapters/simple.rb | 1 + lib/dynflow/middleware.rb | 1 + lib/dynflow/middleware/common/singleton.rb | 1 + lib/dynflow/middleware/common/transaction.rb | 1 + lib/dynflow/middleware/register.rb | 1 + lib/dynflow/middleware/resolver.rb | 1 + lib/dynflow/middleware/stack.rb | 1 + lib/dynflow/middleware/world.rb | 1 + lib/dynflow/persistence.rb | 1 + lib/dynflow/persistence_adapters.rb | 1 + lib/dynflow/persistence_adapters/abstract.rb | 1 + lib/dynflow/persistence_adapters/sequel.rb | 1 + .../persistence_adapters/sequel_migrations/001_initial.rb | 1 + .../sequel_migrations/002_incremental_progress.rb | 1 + .../sequel_migrations/003_parent_action.rb | 1 + .../sequel_migrations/004_coordinator_records.rb | 1 + .../sequel_migrations/005_envelopes.rb | 1 + .../sequel_migrations/006_fix_data_length.rb | 1 + .../sequel_migrations/007_future_execution.rb | 1 + .../008_rename_scheduled_plans_to_delayed_plans.rb | 1 + .../sequel_migrations/009_fix_mysql_data_length.rb | 1 + .../sequel_migrations/010_add_execution_plans_label.rb | 1 + .../sequel_migrations/011_placeholder.rb | 1 + .../012_add_delayed_plans_serialized_args.rb | 1 + .../sequel_migrations/013_add_action_columns.rb | 1 + .../sequel_migrations/014_add_step_columns.rb | 1 + .../sequel_migrations/015_add_execution_plan_columns.rb | 1 + .../sequel_migrations/016_add_step_queue.rb | 1 + .../sequel_migrations/017_add_delayed_plan_frozen.rb | 1 + .../sequel_migrations/018_add_uuid_column.rb | 1 + .../sequel_migrations/019_update_mysql_time_precision.rb | 1 + .../sequel_migrations/020_drop_duplicate_indices.rb | 1 + .../sequel_migrations/021_create_output_chunks.rb | 1 + .../sequel_migrations/023_sqlite_workarounds.rb | 1 + lib/dynflow/rails.rb | 1 + lib/dynflow/rails/configuration.rb | 1 + lib/dynflow/rails/daemon.rb | 1 + lib/dynflow/round_robin.rb | 1 + lib/dynflow/semaphores.rb | 1 + lib/dynflow/semaphores/abstract.rb | 1 + lib/dynflow/semaphores/aggregating.rb | 1 + lib/dynflow/semaphores/dummy.rb | 1 + lib/dynflow/semaphores/stateful.rb | 1 + lib/dynflow/serializable.rb | 1 + lib/dynflow/serializer.rb | 1 + lib/dynflow/serializers.rb | 1 + lib/dynflow/serializers/abstract.rb | 1 + lib/dynflow/serializers/noop.rb | 1 + lib/dynflow/stateful.rb | 1 + lib/dynflow/telemetry.rb | 1 + lib/dynflow/telemetry_adapters/abstract.rb | 1 + lib/dynflow/telemetry_adapters/dummy.rb | 1 + lib/dynflow/telemetry_adapters/statsd.rb | 1 + lib/dynflow/testing.rb | 1 + lib/dynflow/testing/assertions.rb | 1 + lib/dynflow/testing/dummy_coordinator.rb | 1 + lib/dynflow/testing/dummy_execution_plan.rb | 1 + lib/dynflow/testing/dummy_executor.rb | 1 + lib/dynflow/testing/dummy_planned_action.rb | 1 + lib/dynflow/testing/dummy_step.rb | 1 + lib/dynflow/testing/dummy_world.rb | 1 + lib/dynflow/testing/factories.rb | 1 + lib/dynflow/testing/in_thread_executor.rb | 1 + lib/dynflow/testing/in_thread_world.rb | 1 + lib/dynflow/testing/managed_clock.rb | 1 + lib/dynflow/testing/mimic.rb | 1 + lib/dynflow/throttle_limiter.rb | 1 + lib/dynflow/transaction_adapters.rb | 1 + lib/dynflow/transaction_adapters/abstract.rb | 1 + lib/dynflow/transaction_adapters/active_record.rb | 1 + lib/dynflow/transaction_adapters/none.rb | 1 + lib/dynflow/utils.rb | 1 + lib/dynflow/utils/indifferent_hash.rb | 1 + lib/dynflow/utils/priority_queue.rb | 1 + lib/dynflow/version.rb | 1 + lib/dynflow/watchers/memory_consumption_watcher.rb | 1 + lib/dynflow/web.rb | 1 + lib/dynflow/web/console.rb | 1 + lib/dynflow/web/console_helpers.rb | 1 + lib/dynflow/web/filtering_helpers.rb | 1 + lib/dynflow/web/world_helpers.rb | 1 + lib/dynflow/web_console.rb | 1 + lib/dynflow/world.rb | 1 + lib/dynflow/world/invalidation.rb | 1 + test/abnormal_states_recovery_test.rb | 1 + test/action_test.rb | 1 + test/activejob_adapter_test.rb | 1 + test/batch_sub_tasks_test.rb | 1 + test/clock_test.rb | 1 + test/concurrency_control_test.rb | 1 + test/coordinator_test.rb | 1 + test/daemon_test.rb | 1 + test/dead_letter_silencer_test.rb | 1 + test/dispatcher_test.rb | 1 + test/execution_plan_cleaner_test.rb | 1 + test/execution_plan_hooks_test.rb | 1 + test/execution_plan_test.rb | 1 + test/executor_test.rb | 1 + test/extensions_test.rb | 1 + test/flows_test.rb | 1 + test/future_execution_test.rb | 1 + test/memory_cosumption_watcher_test.rb | 1 + test/middleware_test.rb | 1 + test/persistence_test.rb | 1 + test/redis_locking_test.rb | 1 + test/rescue_test.rb | 1 + test/round_robin_test.rb | 1 + test/semaphores_test.rb | 1 + test/support/code_workflow_example.rb | 1 + test/support/dummy_example.rb | 1 + test/support/middleware_example.rb | 1 + test/support/rescue_example.rb | 1 + test/support/test_execution_log.rb | 1 + test/test_helper.rb | 1 + test/testing_test.rb | 1 + test/utils_test.rb | 1 + test/v2_sub_plans_test.rb | 1 + test/web_console_test.rb | 1 + test/world_test.rb | 1 + 223 files changed, 223 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 804c6cfd4..c4548d6ce 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-01-26 13:57:59 UTC using RuboCop version 0.89.1. +# on 2024-01-26 13:59:46 UTC using RuboCop version 0.89.1. # 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 @@ -69,11 +69,6 @@ Layout/DotPosition: - 'test/rescue_test.rb' - 'test/web_console_test.rb' -# Offense count: 222 -# Cop supports --auto-correct. -Layout/EmptyLineAfterMagicComment: - Enabled: false - # Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. diff --git a/Gemfile b/Gemfile index 46ad0ad50..7e1573c47 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,5 @@ # frozen_string_literal: true + source 'https://rubygems.org' gemspec diff --git a/Rakefile b/Rakefile index 7a3757155..ad437eb58 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'rake/testtask' require 'fileutils' diff --git a/doc/pages/Gemfile b/doc/pages/Gemfile index 964644014..e2051b269 100644 --- a/doc/pages/Gemfile +++ b/doc/pages/Gemfile @@ -1,4 +1,5 @@ # frozen_string_literal: true + source 'https://rubygems.org' gem 'rake' diff --git a/doc/pages/Rakefile b/doc/pages/Rakefile index 410160ef7..784b92a19 100644 --- a/doc/pages/Rakefile +++ b/doc/pages/Rakefile @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'rubygems' require 'rake' diff --git a/doc/pages/plugins/alert_block.rb b/doc/pages/plugins/alert_block.rb index e1f299c32..da6e2038e 100644 --- a/doc/pages/plugins/alert_block.rb +++ b/doc/pages/plugins/alert_block.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'div_tag' module Jekyll diff --git a/doc/pages/plugins/div_tag.rb b/doc/pages/plugins/div_tag.rb index 301276dee..c726a536d 100644 --- a/doc/pages/plugins/div_tag.rb +++ b/doc/pages/plugins/div_tag.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Jekyll class DivTag < Liquid::Block def render(context) diff --git a/doc/pages/plugins/graphviz.rb b/doc/pages/plugins/graphviz.rb index 784c57be8..2e7c48eda 100644 --- a/doc/pages/plugins/graphviz.rb +++ b/doc/pages/plugins/graphviz.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # taken from https://raw.githubusercontent.com/kui/octopress-graphviz/master/graphviz_block.rb require 'open3' diff --git a/doc/pages/plugins/plantuml.rb b/doc/pages/plugins/plantuml.rb index 5baad2dd7..9540db44c 100644 --- a/doc/pages/plugins/plantuml.rb +++ b/doc/pages/plugins/plantuml.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Title: PlantUML Code Blocks for Jekyll # Author: YJ Park (yjpark@gmail.com) # https://github.com/yjpark/jekyll-plantuml diff --git a/doc/pages/plugins/play.rb b/doc/pages/plugins/play.rb index 615117daa..e43fca55d 100644 --- a/doc/pages/plugins/play.rb +++ b/doc/pages/plugins/play.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'pp' require 'pry' diff --git a/doc/pages/plugins/tags.rb b/doc/pages/plugins/tags.rb index 5c625b42f..2bf5e173a 100644 --- a/doc/pages/plugins/tags.rb +++ b/doc/pages/plugins/tags.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'nuggets/range/quantile' require 'erb' diff --git a/doc/pages/plugins/toc.rb b/doc/pages/plugins/toc.rb index 216efdde3..bbf9df718 100644 --- a/doc/pages/plugins/toc.rb +++ b/doc/pages/plugins/toc.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Jekyll module FancyToCFilter def fancytoc(input) diff --git a/dynflow.gemspec b/dynflow.gemspec index 009a40fb8..ab95c09fc 100644 --- a/dynflow.gemspec +++ b/dynflow.gemspec @@ -1,5 +1,6 @@ # -*- encoding: utf-8 -*- # frozen_string_literal: true + $:.push File.expand_path("../lib", __FILE__) require "dynflow/version" diff --git a/examples/clock_benchmark.rb b/examples/clock_benchmark.rb index bd8d7ea03..37ffb0bd4 100644 --- a/examples/clock_benchmark.rb +++ b/examples/clock_benchmark.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'dynflow' require 'benchmark' diff --git a/examples/example_helper.rb b/examples/example_helper.rb index b6df2cd8b..58b350dcd 100644 --- a/examples/example_helper.rb +++ b/examples/example_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + $:.unshift(File.expand_path('../../lib', __FILE__)) require 'dynflow' diff --git a/examples/singletons.rb b/examples/singletons.rb index caf9dd837..22f967f38 100755 --- a/examples/singletons.rb +++ b/examples/singletons.rb @@ -1,5 +1,6 @@ #!/usr/bin/env ruby # frozen_string_literal: true + example_description = < "#{column_name}::uuid") diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/019_update_mysql_time_precision.rb b/lib/dynflow/persistence_adapters/sequel_migrations/019_update_mysql_time_precision.rb index 20ef54b85..25308a39e 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/019_update_mysql_time_precision.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/019_update_mysql_time_precision.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do up do alter_table(:dynflow_execution_plans) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/020_drop_duplicate_indices.rb b/lib/dynflow/persistence_adapters/sequel_migrations/020_drop_duplicate_indices.rb index 99b55a4f3..8b8b87be2 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/020_drop_duplicate_indices.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/020_drop_duplicate_indices.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do up do alter_table(:dynflow_actions) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb b/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb index 9a004efac..8c93722c5 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do up do type = database_type diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/023_sqlite_workarounds.rb b/lib/dynflow/persistence_adapters/sequel_migrations/023_sqlite_workarounds.rb index 51c84e4b0..f85be570b 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/023_sqlite_workarounds.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/023_sqlite_workarounds.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + tables = [:dynflow_actions, :dynflow_delayed_plans, :dynflow_steps, :dynflow_output_chunks] Sequel.migration do up do diff --git a/lib/dynflow/rails.rb b/lib/dynflow/rails.rb index d644d3d5f..c6e9b8e17 100644 --- a/lib/dynflow/rails.rb +++ b/lib/dynflow/rails.rb @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # frozen_string_literal: true + module Dynflow # Class for configuring and preparing the Dynflow runtime environment. class Rails diff --git a/lib/dynflow/rails/configuration.rb b/lib/dynflow/rails/configuration.rb index 46005d5d2..f3c778813 100644 --- a/lib/dynflow/rails/configuration.rb +++ b/lib/dynflow/rails/configuration.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'rails' require 'active_record' diff --git a/lib/dynflow/rails/daemon.rb b/lib/dynflow/rails/daemon.rb index 25f968eba..0b99bd417 100644 --- a/lib/dynflow/rails/daemon.rb +++ b/lib/dynflow/rails/daemon.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'fileutils' require 'get_process_mem' require 'dynflow/watchers/memory_consumption_watcher' diff --git a/lib/dynflow/round_robin.rb b/lib/dynflow/round_robin.rb index 12625e47d..97008129b 100644 --- a/lib/dynflow/round_robin.rb +++ b/lib/dynflow/round_robin.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow # A simple round-robin scheduling implementation used at various # places in Dynflow diff --git a/lib/dynflow/semaphores.rb b/lib/dynflow/semaphores.rb index b427b86fa..c69d76e40 100644 --- a/lib/dynflow/semaphores.rb +++ b/lib/dynflow/semaphores.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Semaphores require 'dynflow/semaphores/abstract' diff --git a/lib/dynflow/semaphores/abstract.rb b/lib/dynflow/semaphores/abstract.rb index 431339246..3754fd2cf 100644 --- a/lib/dynflow/semaphores/abstract.rb +++ b/lib/dynflow/semaphores/abstract.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Semaphores class Abstract diff --git a/lib/dynflow/semaphores/aggregating.rb b/lib/dynflow/semaphores/aggregating.rb index f964ab5b5..c0ed28dc4 100644 --- a/lib/dynflow/semaphores/aggregating.rb +++ b/lib/dynflow/semaphores/aggregating.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Semaphores class Aggregating < Abstract diff --git a/lib/dynflow/semaphores/dummy.rb b/lib/dynflow/semaphores/dummy.rb index d07151033..b1802d44f 100644 --- a/lib/dynflow/semaphores/dummy.rb +++ b/lib/dynflow/semaphores/dummy.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Semaphores class Dummy < Abstract diff --git a/lib/dynflow/semaphores/stateful.rb b/lib/dynflow/semaphores/stateful.rb index da98d3c0c..84b450546 100644 --- a/lib/dynflow/semaphores/stateful.rb +++ b/lib/dynflow/semaphores/stateful.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Semaphores class Stateful < Abstract diff --git a/lib/dynflow/serializable.rb b/lib/dynflow/serializable.rb index 16777077f..5b0c78659 100644 --- a/lib/dynflow/serializable.rb +++ b/lib/dynflow/serializable.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'date' module Dynflow class Serializable diff --git a/lib/dynflow/serializer.rb b/lib/dynflow/serializer.rb index 84a7d8bfc..6a5903724 100644 --- a/lib/dynflow/serializer.rb +++ b/lib/dynflow/serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'algebrick/serializer' module Dynflow diff --git a/lib/dynflow/serializers.rb b/lib/dynflow/serializers.rb index 341a51e0e..ff19721b9 100644 --- a/lib/dynflow/serializers.rb +++ b/lib/dynflow/serializers.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Serializers diff --git a/lib/dynflow/serializers/abstract.rb b/lib/dynflow/serializers/abstract.rb index afb77532d..1883a3d60 100644 --- a/lib/dynflow/serializers/abstract.rb +++ b/lib/dynflow/serializers/abstract.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Serializers # @abstract diff --git a/lib/dynflow/serializers/noop.rb b/lib/dynflow/serializers/noop.rb index 2871121c6..64cd43224 100644 --- a/lib/dynflow/serializers/noop.rb +++ b/lib/dynflow/serializers/noop.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Serializers class Noop < Abstract diff --git a/lib/dynflow/stateful.rb b/lib/dynflow/stateful.rb index 9fb83c275..c7329909a 100644 --- a/lib/dynflow/stateful.rb +++ b/lib/dynflow/stateful.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Stateful def self.included(base) diff --git a/lib/dynflow/telemetry.rb b/lib/dynflow/telemetry.rb index d8c848bd4..2d84bb70b 100644 --- a/lib/dynflow/telemetry.rb +++ b/lib/dynflow/telemetry.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'dynflow/telemetry_adapters/abstract' require 'dynflow/telemetry_adapters/dummy' require 'dynflow/telemetry_adapters/statsd' diff --git a/lib/dynflow/telemetry_adapters/abstract.rb b/lib/dynflow/telemetry_adapters/abstract.rb index 5c37a22aa..cd42f32b5 100644 --- a/lib/dynflow/telemetry_adapters/abstract.rb +++ b/lib/dynflow/telemetry_adapters/abstract.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module TelemetryAdapters class Abstract diff --git a/lib/dynflow/telemetry_adapters/dummy.rb b/lib/dynflow/telemetry_adapters/dummy.rb index 10a9f951c..3d84e294c 100644 --- a/lib/dynflow/telemetry_adapters/dummy.rb +++ b/lib/dynflow/telemetry_adapters/dummy.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module TelemetryAdapters # Telemetry adapter which does not evaluate blocks passed to {#with_instance}. diff --git a/lib/dynflow/telemetry_adapters/statsd.rb b/lib/dynflow/telemetry_adapters/statsd.rb index 1c8372153..a779d3c19 100644 --- a/lib/dynflow/telemetry_adapters/statsd.rb +++ b/lib/dynflow/telemetry_adapters/statsd.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module TelemetryAdapters class StatsD < Abstract diff --git a/lib/dynflow/testing.rb b/lib/dynflow/testing.rb index 2cdf906f5..581469a5c 100644 --- a/lib/dynflow/testing.rb +++ b/lib/dynflow/testing.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing extend Algebrick::TypeCheck diff --git a/lib/dynflow/testing/assertions.rb b/lib/dynflow/testing/assertions.rb index 3c048e795..8b0e9bf8c 100644 --- a/lib/dynflow/testing/assertions.rb +++ b/lib/dynflow/testing/assertions.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing module Assertions diff --git a/lib/dynflow/testing/dummy_coordinator.rb b/lib/dynflow/testing/dummy_coordinator.rb index d42b772cf..77c201a44 100644 --- a/lib/dynflow/testing/dummy_coordinator.rb +++ b/lib/dynflow/testing/dummy_coordinator.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class DummyCoordinator diff --git a/lib/dynflow/testing/dummy_execution_plan.rb b/lib/dynflow/testing/dummy_execution_plan.rb index eea91dbd3..6bb48fc3f 100644 --- a/lib/dynflow/testing/dummy_execution_plan.rb +++ b/lib/dynflow/testing/dummy_execution_plan.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class DummyExecutionPlan diff --git a/lib/dynflow/testing/dummy_executor.rb b/lib/dynflow/testing/dummy_executor.rb index 416c90af3..ee1ca352f 100644 --- a/lib/dynflow/testing/dummy_executor.rb +++ b/lib/dynflow/testing/dummy_executor.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class DummyExecutor diff --git a/lib/dynflow/testing/dummy_planned_action.rb b/lib/dynflow/testing/dummy_planned_action.rb index 431518f3c..b9e65c5e4 100644 --- a/lib/dynflow/testing/dummy_planned_action.rb +++ b/lib/dynflow/testing/dummy_planned_action.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class DummyPlannedAction diff --git a/lib/dynflow/testing/dummy_step.rb b/lib/dynflow/testing/dummy_step.rb index e59638a9e..7cc0554e8 100644 --- a/lib/dynflow/testing/dummy_step.rb +++ b/lib/dynflow/testing/dummy_step.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class DummyStep diff --git a/lib/dynflow/testing/dummy_world.rb b/lib/dynflow/testing/dummy_world.rb index 1beb4b705..1a945d820 100644 --- a/lib/dynflow/testing/dummy_world.rb +++ b/lib/dynflow/testing/dummy_world.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class DummyWorld diff --git a/lib/dynflow/testing/factories.rb b/lib/dynflow/testing/factories.rb index 59ea3aad6..49b376d7d 100644 --- a/lib/dynflow/testing/factories.rb +++ b/lib/dynflow/testing/factories.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing module Factories diff --git a/lib/dynflow/testing/in_thread_executor.rb b/lib/dynflow/testing/in_thread_executor.rb index e73a7c4c1..7eef34afc 100644 --- a/lib/dynflow/testing/in_thread_executor.rb +++ b/lib/dynflow/testing/in_thread_executor.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class InThreadExecutor diff --git a/lib/dynflow/testing/in_thread_world.rb b/lib/dynflow/testing/in_thread_world.rb index b0190f118..e59e2cecb 100644 --- a/lib/dynflow/testing/in_thread_world.rb +++ b/lib/dynflow/testing/in_thread_world.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class InThreadWorld < Dynflow::World diff --git a/lib/dynflow/testing/managed_clock.rb b/lib/dynflow/testing/managed_clock.rb index 8b652f154..afec452a8 100644 --- a/lib/dynflow/testing/managed_clock.rb +++ b/lib/dynflow/testing/managed_clock.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class ManagedClock diff --git a/lib/dynflow/testing/mimic.rb b/lib/dynflow/testing/mimic.rb index 8d9ec3542..83d41fc4d 100644 --- a/lib/dynflow/testing/mimic.rb +++ b/lib/dynflow/testing/mimic.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing diff --git a/lib/dynflow/throttle_limiter.rb b/lib/dynflow/throttle_limiter.rb index e49ad0a35..65e5d0495 100644 --- a/lib/dynflow/throttle_limiter.rb +++ b/lib/dynflow/throttle_limiter.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class ThrottleLimiter diff --git a/lib/dynflow/transaction_adapters.rb b/lib/dynflow/transaction_adapters.rb index 4e81fa299..cb80ee4c1 100644 --- a/lib/dynflow/transaction_adapters.rb +++ b/lib/dynflow/transaction_adapters.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module TransactionAdapters diff --git a/lib/dynflow/transaction_adapters/abstract.rb b/lib/dynflow/transaction_adapters/abstract.rb index 23a03c2e1..75b7d0e4d 100644 --- a/lib/dynflow/transaction_adapters/abstract.rb +++ b/lib/dynflow/transaction_adapters/abstract.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module TransactionAdapters class Abstract diff --git a/lib/dynflow/transaction_adapters/active_record.rb b/lib/dynflow/transaction_adapters/active_record.rb index 554a80632..d4b295303 100644 --- a/lib/dynflow/transaction_adapters/active_record.rb +++ b/lib/dynflow/transaction_adapters/active_record.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module TransactionAdapters class ActiveRecord < Abstract diff --git a/lib/dynflow/transaction_adapters/none.rb b/lib/dynflow/transaction_adapters/none.rb index 7a116ea93..97c1c4134 100644 --- a/lib/dynflow/transaction_adapters/none.rb +++ b/lib/dynflow/transaction_adapters/none.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module TransactionAdapters class None < Abstract diff --git a/lib/dynflow/utils.rb b/lib/dynflow/utils.rb index 32132cb4d..e0144032f 100644 --- a/lib/dynflow/utils.rb +++ b/lib/dynflow/utils.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Utils diff --git a/lib/dynflow/utils/indifferent_hash.rb b/lib/dynflow/utils/indifferent_hash.rb index 9873c59a7..096c4ed67 100644 --- a/lib/dynflow/utils/indifferent_hash.rb +++ b/lib/dynflow/utils/indifferent_hash.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Utils # Heavily inpired by ActiveSupport::HashWithIndifferentAccess, diff --git a/lib/dynflow/utils/priority_queue.rb b/lib/dynflow/utils/priority_queue.rb index ae6952d31..d0bae70a6 100644 --- a/lib/dynflow/utils/priority_queue.rb +++ b/lib/dynflow/utils/priority_queue.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Utils # Heavily inspired by rubyworks/pqueue diff --git a/lib/dynflow/version.rb b/lib/dynflow/version.rb index 8021d72a1..19806c22c 100644 --- a/lib/dynflow/version.rb +++ b/lib/dynflow/version.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow VERSION = '1.8.2' end diff --git a/lib/dynflow/watchers/memory_consumption_watcher.rb b/lib/dynflow/watchers/memory_consumption_watcher.rb index 80c4da58c..e0b4e68a3 100644 --- a/lib/dynflow/watchers/memory_consumption_watcher.rb +++ b/lib/dynflow/watchers/memory_consumption_watcher.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'get_process_mem' module Dynflow diff --git a/lib/dynflow/web.rb b/lib/dynflow/web.rb index 5ec087cc5..1981970f6 100644 --- a/lib/dynflow/web.rb +++ b/lib/dynflow/web.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'dynflow' require 'pp' require 'sinatra/base' diff --git a/lib/dynflow/web/console.rb b/lib/dynflow/web/console.rb index 4fee958a7..7aa5bb1d6 100644 --- a/lib/dynflow/web/console.rb +++ b/lib/dynflow/web/console.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true + module Dynflow module Web class Console < Sinatra::Base diff --git a/lib/dynflow/web/console_helpers.rb b/lib/dynflow/web/console_helpers.rb index 4737bf746..804028f29 100644 --- a/lib/dynflow/web/console_helpers.rb +++ b/lib/dynflow/web/console_helpers.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Web module ConsoleHelpers diff --git a/lib/dynflow/web/filtering_helpers.rb b/lib/dynflow/web/filtering_helpers.rb index e586811c1..a5df0eb26 100644 --- a/lib/dynflow/web/filtering_helpers.rb +++ b/lib/dynflow/web/filtering_helpers.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Web module FilteringHelpers diff --git a/lib/dynflow/web/world_helpers.rb b/lib/dynflow/web/world_helpers.rb index 2b0146f7f..ef41ccb2b 100644 --- a/lib/dynflow/web/world_helpers.rb +++ b/lib/dynflow/web/world_helpers.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Web module WorldHelpers diff --git a/lib/dynflow/web_console.rb b/lib/dynflow/web_console.rb index 3965ad7a1..198d8e989 100644 --- a/lib/dynflow/web_console.rb +++ b/lib/dynflow/web_console.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'dynflow/web' warn %{"require 'dynflow/web_console'" is deprecated, use "require 'dynflow/web'" instead} diff --git a/lib/dynflow/world.rb b/lib/dynflow/world.rb index ac1f2c7ee..87b83655f 100644 --- a/lib/dynflow/world.rb +++ b/lib/dynflow/world.rb @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # frozen_string_literal: true + require 'dynflow/world/invalidation' module Dynflow diff --git a/lib/dynflow/world/invalidation.rb b/lib/dynflow/world/invalidation.rb index 7e1234b9a..f8ec7d872 100644 --- a/lib/dynflow/world/invalidation.rb +++ b/lib/dynflow/world/invalidation.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class World module Invalidation diff --git a/test/abnormal_states_recovery_test.rb b/test/abnormal_states_recovery_test.rb index 634069e44..c4796b3e4 100644 --- a/test/abnormal_states_recovery_test.rb +++ b/test/abnormal_states_recovery_test.rb @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # frozen_string_literal: true + require_relative 'test_helper' require 'ostruct' diff --git a/test/action_test.rb b/test/action_test.rb index 908129635..e4579e20e 100644 --- a/test/action_test.rb +++ b/test/action_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'mocha/minitest' diff --git a/test/activejob_adapter_test.rb b/test/activejob_adapter_test.rb index 1295a2d85..c469fb1e3 100644 --- a/test/activejob_adapter_test.rb +++ b/test/activejob_adapter_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'active_job' require 'dynflow/active_job/queue_adapter' diff --git a/test/batch_sub_tasks_test.rb b/test/batch_sub_tasks_test.rb index b3feffe47..1f25b35ea 100644 --- a/test/batch_sub_tasks_test.rb +++ b/test/batch_sub_tasks_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/clock_test.rb b/test/clock_test.rb index 38069b514..88e961acf 100644 --- a/test/clock_test.rb +++ b/test/clock_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'logger' diff --git a/test/concurrency_control_test.rb b/test/concurrency_control_test.rb index dc2d3dbd7..0aadbd478 100644 --- a/test/concurrency_control_test.rb +++ b/test/concurrency_control_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/coordinator_test.rb b/test/coordinator_test.rb index c28b38409..1088fd129 100644 --- a/test/coordinator_test.rb +++ b/test/coordinator_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'fileutils' diff --git a/test/daemon_test.rb b/test/daemon_test.rb index aefd91191..e265cdbef 100644 --- a/test/daemon_test.rb +++ b/test/daemon_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' require 'active_support' require 'mocha/minitest' diff --git a/test/dead_letter_silencer_test.rb b/test/dead_letter_silencer_test.rb index 73e7a1d71..af86d9a16 100644 --- a/test/dead_letter_silencer_test.rb +++ b/test/dead_letter_silencer_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'ostruct' diff --git a/test/dispatcher_test.rb b/test/dispatcher_test.rb index 986fd0481..780a99496 100644 --- a/test/dispatcher_test.rb +++ b/test/dispatcher_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/execution_plan_cleaner_test.rb b/test/execution_plan_cleaner_test.rb index 86233fd4d..cc7b19c98 100644 --- a/test/execution_plan_cleaner_test.rb +++ b/test/execution_plan_cleaner_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'mocha/minitest' diff --git a/test/execution_plan_hooks_test.rb b/test/execution_plan_hooks_test.rb index 6586545b6..c1edc3186 100644 --- a/test/execution_plan_hooks_test.rb +++ b/test/execution_plan_hooks_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/execution_plan_test.rb b/test/execution_plan_test.rb index eae66fce8..5a019ddca 100644 --- a/test/execution_plan_test.rb +++ b/test/execution_plan_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/executor_test.rb b/test/executor_test.rb index 4b3d09348..91b4106b2 100644 --- a/test/executor_test.rb +++ b/test/executor_test.rb @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # frozen_string_literal: true + require_relative 'test_helper' require 'mocha/minitest' diff --git a/test/extensions_test.rb b/test/extensions_test.rb index 70dd323c6..36a733de5 100644 --- a/test/extensions_test.rb +++ b/test/extensions_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'active_support/time' diff --git a/test/flows_test.rb b/test/flows_test.rb index e1768e374..6d1c1bd4a 100644 --- a/test/flows_test.rb +++ b/test/flows_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'mocha/minitest' diff --git a/test/future_execution_test.rb b/test/future_execution_test.rb index bea1c1b6b..8cc633c9d 100644 --- a/test/future_execution_test.rb +++ b/test/future_execution_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/memory_cosumption_watcher_test.rb b/test/memory_cosumption_watcher_test.rb index caa04c940..33a59607b 100644 --- a/test/memory_cosumption_watcher_test.rb +++ b/test/memory_cosumption_watcher_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'fileutils' require 'dynflow/watchers/memory_consumption_watcher' diff --git a/test/middleware_test.rb b/test/middleware_test.rb index 05459baaf..b5ea6df78 100644 --- a/test/middleware_test.rb +++ b/test/middleware_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/persistence_test.rb b/test/persistence_test.rb index 6229cf823..79f9c1762 100644 --- a/test/persistence_test.rb +++ b/test/persistence_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'tmpdir' require 'ostruct' diff --git a/test/redis_locking_test.rb b/test/redis_locking_test.rb index f0536c467..b92fbb87f 100644 --- a/test/redis_locking_test.rb +++ b/test/redis_locking_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'mocha/minitest' require 'minitest/stub_const' diff --git a/test/rescue_test.rb b/test/rescue_test.rb index 4022655da..7f2ca35d3 100644 --- a/test/rescue_test.rb +++ b/test/rescue_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/round_robin_test.rb b/test/round_robin_test.rb index 7faf84d5f..0fffed9b3 100644 --- a/test/round_robin_test.rb +++ b/test/round_robin_test.rb @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/semaphores_test.rb b/test/semaphores_test.rb index 498e0bb0d..1441552ee 100644 --- a/test/semaphores_test.rb +++ b/test/semaphores_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/support/code_workflow_example.rb b/test/support/code_workflow_example.rb index a6ae18f6d..fdbcf3bb7 100644 --- a/test/support/code_workflow_example.rb +++ b/test/support/code_workflow_example.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'logger' module Support diff --git a/test/support/dummy_example.rb b/test/support/dummy_example.rb index d1ed07349..66f84b332 100644 --- a/test/support/dummy_example.rb +++ b/test/support/dummy_example.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'logger' module Support diff --git a/test/support/middleware_example.rb b/test/support/middleware_example.rb index 9bcba667a..2913e64ac 100644 --- a/test/support/middleware_example.rb +++ b/test/support/middleware_example.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Support module MiddlewareExample class LogMiddleware < Dynflow::Middleware diff --git a/test/support/rescue_example.rb b/test/support/rescue_example.rb index 3705afd12..6d3b54986 100644 --- a/test/support/rescue_example.rb +++ b/test/support/rescue_example.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'logger' module Support diff --git a/test/support/test_execution_log.rb b/test/support/test_execution_log.rb index c4fc23914..63c599753 100644 --- a/test/support/test_execution_log.rb +++ b/test/support/test_execution_log.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class TestExecutionLog include Enumerable diff --git a/test/test_helper.rb b/test/test_helper.rb index f6f705028..adedc8758 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'bundler/setup' require 'minitest/reporters' require 'minitest/autorun' diff --git a/test/testing_test.rb b/test/testing_test.rb index 9ea830777..229c9c7cf 100644 --- a/test/testing_test.rb +++ b/test/testing_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/utils_test.rb b/test/utils_test.rb index 404ec0a32..599bd7cef 100644 --- a/test/utils_test.rb +++ b/test/utils_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/v2_sub_plans_test.rb b/test/v2_sub_plans_test.rb index b6c644e75..311b1c9df 100644 --- a/test/v2_sub_plans_test.rb +++ b/test/v2_sub_plans_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'mocha/minitest' diff --git a/test/web_console_test.rb b/test/web_console_test.rb index 965be0257..2598e2b98 100644 --- a/test/web_console_test.rb +++ b/test/web_console_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' ENV['RACK_ENV'] = 'test' diff --git a/test/world_test.rb b/test/world_test.rb index d96914b73..a64bcde9f 100644 --- a/test/world_test.rb +++ b/test/world_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'fileutils' From 7ccf987363d49e7585a1572e391bf154c6a2d23e Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Fri, 26 Jan 2024 15:01:20 +0100 Subject: [PATCH 10/44] Fix Layout/EmptyLinesAroundClassBody cop --- doc/pages/plugins/graphviz.rb | 1 - doc/pages/plugins/plantuml.rb | 1 - doc/pages/plugins/play.rb | 1 - doc/pages/plugins/tags.rb | 4 ---- examples/future_execution.rb | 2 -- examples/orchestrate.rb | 11 ----------- examples/orchestrate_evented.rb | 13 ------------- examples/remote_executor.rb | 2 -- examples/sub_plan_concurrency_control.rb | 1 - lib/dynflow/action.rb | 1 - lib/dynflow/action/missing.rb | 1 - lib/dynflow/action/progress.rb | 1 - lib/dynflow/clock.rb | 1 - lib/dynflow/connectors/database.rb | 1 - lib/dynflow/connectors/direct.rb | 2 -- lib/dynflow/coordinator.rb | 1 - lib/dynflow/delayed_executors/abstract.rb | 2 -- lib/dynflow/delayed_executors/abstract_core.rb | 1 - lib/dynflow/delayed_executors/polling.rb | 2 -- lib/dynflow/delayed_plan.rb | 1 - lib/dynflow/director/execution_plan_manager.rb | 1 - lib/dynflow/director/sequence_cursor.rb | 2 -- lib/dynflow/dispatcher/client_dispatcher.rb | 1 - lib/dynflow/execution_plan.rb | 1 - lib/dynflow/execution_plan/dependency_graph.rb | 2 -- lib/dynflow/execution_plan/output_reference.rb | 1 - .../execution_plan/steps/abstract_flow_step.rb | 1 - .../execution_plan/steps/finalize_step.rb | 2 -- lib/dynflow/execution_plan/steps/run_step.rb | 1 - lib/dynflow/flows/abstract_composed.rb | 2 -- lib/dynflow/flows/atom.rb | 2 -- lib/dynflow/flows/concurrence.rb | 1 - lib/dynflow/flows/sequence.rb | 1 - lib/dynflow/logger_adapters/abstract.rb | 1 - lib/dynflow/logger_adapters/delegator.rb | 1 - lib/dynflow/middleware/resolver.rb | 2 -- lib/dynflow/middleware/world.rb | 2 -- lib/dynflow/persistence.rb | 1 - lib/dynflow/persistence_adapters/abstract.rb | 1 - lib/dynflow/rails/daemon.rb | 1 - lib/dynflow/semaphores/abstract.rb | 1 - lib/dynflow/semaphores/aggregating.rb | 2 -- lib/dynflow/semaphores/dummy.rb | 1 - lib/dynflow/semaphores/stateful.rb | 1 - lib/dynflow/serializer.rb | 1 - lib/dynflow/serializers/abstract.rb | 2 -- lib/dynflow/serializers/noop.rb | 2 -- lib/dynflow/testing/managed_clock.rb | 1 - lib/dynflow/throttle_limiter.rb | 1 - .../watchers/memory_consumption_watcher.rb | 1 - lib/dynflow/web/console.rb | 2 -- lib/dynflow/world.rb | 1 - test/action_test.rb | 3 --- test/concurrency_control_test.rb | 2 -- test/support/code_workflow_example.rb | 16 ---------------- test/support/dummy_example.rb | 1 - test/support/middleware_example.rb | 7 ------- test/support/rescue_example.rb | 12 ------------ test/support/test_execution_log.rb | 2 -- test/test_helper.rb | 1 - 60 files changed, 137 deletions(-) diff --git a/doc/pages/plugins/graphviz.rb b/doc/pages/plugins/graphviz.rb index 2e7c48eda..6a1ec2df1 100644 --- a/doc/pages/plugins/graphviz.rb +++ b/doc/pages/plugins/graphviz.rb @@ -6,7 +6,6 @@ module Jekyll class GraphvizBlock < Liquid::Block - DIV_CLASS_ATTR = 'graphviz-wrapper' DEFAULT_GRAPH_NAME = 'Graphviz' DOT_OPTS = '-Tsvg' diff --git a/doc/pages/plugins/plantuml.rb b/doc/pages/plugins/plantuml.rb index 9540db44c..ff7989645 100644 --- a/doc/pages/plugins/plantuml.rb +++ b/doc/pages/plugins/plantuml.rb @@ -80,7 +80,6 @@ def create_tmp_folder(tmproot, folder) Jekyll.logger.info("Create PlantUML image folder: " + folderpath) end end - end # PlantUMLBlock end diff --git a/doc/pages/plugins/play.rb b/doc/pages/plugins/play.rb index e43fca55d..caf7fe03c 100644 --- a/doc/pages/plugins/play.rb +++ b/doc/pages/plugins/play.rb @@ -10,6 +10,5 @@ def generate(site) # pp site # binding.pry end - end end diff --git a/doc/pages/plugins/tags.rb b/doc/pages/plugins/tags.rb index 2bf5e173a..bfd616014 100644 --- a/doc/pages/plugins/tags.rb +++ b/doc/pages/plugins/tags.rb @@ -6,7 +6,6 @@ module Jekyll class Tagger < Generator - safe true attr_accessor :site @@ -80,11 +79,9 @@ def active_tags def pretty? @pretty ||= (site.permalink_style == :pretty || site.config['tag_permalink_style'] == 'pretty') end - end class TagPage < Page - def initialize(site, base, dir, name, data = {}) self.content = data.delete('content') || '' self.data = data @@ -95,7 +92,6 @@ def initialize(site, base, dir, name, data = {}) def read_yaml(*) # Do nothing end - end module Filters diff --git a/examples/future_execution.rb b/examples/future_execution.rb index 70e9f6b72..89abcc097 100755 --- a/examples/future_execution.rb +++ b/examples/future_execution.rb @@ -25,7 +25,6 @@ def deserialize(arg) end class DelayedAction < Dynflow::Action - def delay(delay_options, *args) CustomPassedObjectSerializer.new(args) end @@ -36,7 +35,6 @@ def plan(passed_object) def run end - end if $0 == __FILE__ diff --git a/examples/orchestrate.rb b/examples/orchestrate.rb index 9e9442c32..16ddb36e2 100755 --- a/examples/orchestrate.rb +++ b/examples/orchestrate.rb @@ -26,7 +26,6 @@ module Orchestrate class CreateInfrastructure < Dynflow::Action - def plan sequence do concurrence do @@ -43,7 +42,6 @@ def plan end class CreateMachine < Dynflow::Action - def plan(name, profile, config_options = {}) prepare_disk = plan_action(PrepareDisk, 'name' => name) create_vm = plan_action(CreateVM, @@ -61,7 +59,6 @@ def finalize # this is called after run methods of the actions in the # execution plan were finished end - end class Base < Dynflow::Action @@ -71,7 +68,6 @@ def sleep! end class PrepareDisk < Base - def queue :slow end @@ -88,11 +84,9 @@ def run sleep! output[:path] = "/var/images/#{input[:name]}.img" end - end class CreateVM < Base - input_format do param :name param :disk @@ -106,11 +100,9 @@ def run sleep! output[:ip] = "192.168.100.#{rand(256)}" end - end class AddIPtoHosts < Base - input_format do param :ip end @@ -118,11 +110,9 @@ class AddIPtoHosts < Base def run sleep! end - end class ConfigureMachine < Base - input_format do param :ip param :profile @@ -144,7 +134,6 @@ def run sleep! end - end end diff --git a/examples/orchestrate_evented.rb b/examples/orchestrate_evented.rb index eaee901fc..b1825c5da 100755 --- a/examples/orchestrate_evented.rb +++ b/examples/orchestrate_evented.rb @@ -26,7 +26,6 @@ module OrchestrateEvented class CreateInfrastructure < Dynflow::Action - def plan(get_stuck = false) sequence do concurrence do @@ -43,7 +42,6 @@ def plan(get_stuck = false) end class CreateMachine < Dynflow::Action - def plan(name, profile, config_options = {}) prepare_disk = plan_action(PrepareDisk, 'name' => name) create_vm = plan_action(CreateVM, @@ -59,11 +57,9 @@ def plan(name, profile, config_options = {}) def finalize end - end class Base < Dynflow::Action - Finished = Algebrick.atom def run(event = nil) @@ -82,11 +78,9 @@ def run(event = nil) def on_finish raise NotImplementedError end - end class PrepareDisk < Base - input_format do param :name end @@ -98,11 +92,9 @@ class PrepareDisk < Base def on_finish output[:path] = "/var/images/#{input[:name]}.img" end - end class CreateVM < Base - input_format do param :name param :disk @@ -115,22 +107,18 @@ class CreateVM < Base def on_finish output[:ip] = "192.168.100.#{rand(256)}" end - end class AddIPtoHosts < Base - input_format do param :ip end def on_finish end - end class ConfigureMachine < Base - # thanks to this Dynflow knows this action can be politely # asked to get canceled include ::Dynflow::Action::Cancellable @@ -163,7 +151,6 @@ def on_finish suspend end end - end end diff --git a/examples/remote_executor.rb b/examples/remote_executor.rb index c6ab59385..9227f98ba 100755 --- a/examples/remote_executor.rb +++ b/examples/remote_executor.rb @@ -45,7 +45,6 @@ def run class RemoteExecutorExample class << self - def run_observer world = ExampleHelper.create_world do |config| config.persistence_adapter = persistence_adapter @@ -136,7 +135,6 @@ def run_client sleep 0.5 end end - end end diff --git a/examples/sub_plan_concurrency_control.rb b/examples/sub_plan_concurrency_control.rb index 51b683ea4..157c23de5 100644 --- a/examples/sub_plan_concurrency_control.rb +++ b/examples/sub_plan_concurrency_control.rb @@ -16,7 +16,6 @@ require_relative 'example_helper' class CostyAction < Dynflow::Action - SleepTime = 10 def plan(number) diff --git a/lib/dynflow/action.rb b/lib/dynflow/action.rb index 32b9f5607..716568c74 100644 --- a/lib/dynflow/action.rb +++ b/lib/dynflow/action.rb @@ -3,7 +3,6 @@ module Dynflow # rubocop:disable Metrics/ClassLength class Action < Serializable - OutputReference = ExecutionPlan::OutputReference include Algebrick::TypeCheck diff --git a/lib/dynflow/action/missing.rb b/lib/dynflow/action/missing.rb index a4aab0ae1..852da1034 100644 --- a/lib/dynflow/action/missing.rb +++ b/lib/dynflow/action/missing.rb @@ -4,7 +4,6 @@ module Dynflow # for cases the serialized action was renamed and it's not available # in the code base anymore. class Action::Missing < Dynflow::Action - def self.generate(action_name) Class.new(self).tap do |klass| klass.singleton_class.send(:define_method, :name) do diff --git a/lib/dynflow/action/progress.rb b/lib/dynflow/action/progress.rb index 71292dfa2..b88739e02 100644 --- a/lib/dynflow/action/progress.rb +++ b/lib/dynflow/action/progress.rb @@ -13,7 +13,6 @@ module Dynflow module Action::Progress class Calculate < Middleware - def run(*args) with_progress_calculation(*args) do [action.run_progress, action.run_progress_weight] diff --git a/lib/dynflow/clock.rb b/lib/dynflow/clock.rb index 2de354571..c7df41e56 100644 --- a/lib/dynflow/clock.rb +++ b/lib/dynflow/clock.rb @@ -2,7 +2,6 @@ module Dynflow class Clock < Actor - include Algebrick::Types Timer = Algebrick.type do diff --git a/lib/dynflow/connectors/database.rb b/lib/dynflow/connectors/database.rb index e06fcfeae..128b0478a 100644 --- a/lib/dynflow/connectors/database.rb +++ b/lib/dynflow/connectors/database.rb @@ -3,7 +3,6 @@ module Dynflow module Connectors class Database < Abstract - class PostgresListerner def initialize(core, world_id, db) @core = core diff --git a/lib/dynflow/connectors/direct.rb b/lib/dynflow/connectors/direct.rb index eb67453d4..88268ec10 100644 --- a/lib/dynflow/connectors/direct.rb +++ b/lib/dynflow/connectors/direct.rb @@ -3,9 +3,7 @@ module Dynflow module Connectors class Direct < Abstract - class Core < Actor - def initialize(connector) @connector = connector @worlds = {} diff --git a/lib/dynflow/coordinator.rb b/lib/dynflow/coordinator.rb index 6ee802c91..c215f6f02 100644 --- a/lib/dynflow/coordinator.rb +++ b/lib/dynflow/coordinator.rb @@ -4,7 +4,6 @@ module Dynflow class Coordinator - include Algebrick::TypeCheck class DuplicateRecordError < Dynflow::Error diff --git a/lib/dynflow/delayed_executors/abstract.rb b/lib/dynflow/delayed_executors/abstract.rb index 8c1570a00..073efafaf 100644 --- a/lib/dynflow/delayed_executors/abstract.rb +++ b/lib/dynflow/delayed_executors/abstract.rb @@ -3,7 +3,6 @@ module Dynflow module DelayedExecutors class Abstract - attr_reader :core def initialize(world, options = {}) @@ -40,7 +39,6 @@ def spawn def core_class raise NotImplementedError end - end end end diff --git a/lib/dynflow/delayed_executors/abstract_core.rb b/lib/dynflow/delayed_executors/abstract_core.rb index 738a30b1d..ec1d08e68 100644 --- a/lib/dynflow/delayed_executors/abstract_core.rb +++ b/lib/dynflow/delayed_executors/abstract_core.rb @@ -3,7 +3,6 @@ module Dynflow module DelayedExecutors class AbstractCore < Actor - include Algebrick::TypeCheck attr_reader :world, :logger diff --git a/lib/dynflow/delayed_executors/polling.rb b/lib/dynflow/delayed_executors/polling.rb index 3e96829bd..6fa373928 100644 --- a/lib/dynflow/delayed_executors/polling.rb +++ b/lib/dynflow/delayed_executors/polling.rb @@ -3,11 +3,9 @@ module Dynflow module DelayedExecutors class Polling < Abstract - def core_class Dynflow::DelayedExecutors::PollingCore end - end class PollingCore < AbstractCore diff --git a/lib/dynflow/delayed_plan.rb b/lib/dynflow/delayed_plan.rb index 97b3c7fba..972ac8c52 100644 --- a/lib/dynflow/delayed_plan.rb +++ b/lib/dynflow/delayed_plan.rb @@ -2,7 +2,6 @@ module Dynflow class DelayedPlan < Serializable - include Algebrick::TypeCheck attr_reader :execution_plan_uuid, :start_before diff --git a/lib/dynflow/director/execution_plan_manager.rb b/lib/dynflow/director/execution_plan_manager.rb index cd1aeb2d3..e729dc62c 100644 --- a/lib/dynflow/director/execution_plan_manager.rb +++ b/lib/dynflow/director/execution_plan_manager.rb @@ -119,7 +119,6 @@ def start_finalize def finish return no_work end - end end end diff --git a/lib/dynflow/director/sequence_cursor.rb b/lib/dynflow/director/sequence_cursor.rb index 0c6fff60c..791a92a0e 100644 --- a/lib/dynflow/director/sequence_cursor.rb +++ b/lib/dynflow/director/sequence_cursor.rb @@ -3,7 +3,6 @@ module Dynflow class Director class SequenceCursor - def initialize(flow_manager, sequence, parent_cursor = nil) @flow_manager = flow_manager @sequence = sequence @@ -87,7 +86,6 @@ def add_todo(flow) @todo << @flow_manager.execution_plan.steps[flow.step_id] end end - end end end diff --git a/lib/dynflow/dispatcher/client_dispatcher.rb b/lib/dynflow/dispatcher/client_dispatcher.rb index b2cc49aa8..8e7d68300 100644 --- a/lib/dynflow/dispatcher/client_dispatcher.rb +++ b/lib/dynflow/dispatcher/client_dispatcher.rb @@ -3,7 +3,6 @@ module Dynflow module Dispatcher class ClientDispatcher < Abstract - TrackedRequest = Algebrick.type do fields! id: String, request: Request, accepted: Concurrent::Promises::ResolvableFuture, finished: Concurrent::Promises::ResolvableFuture diff --git a/lib/dynflow/execution_plan.rb b/lib/dynflow/execution_plan.rb index 55b8c09b9..662a1679b 100644 --- a/lib/dynflow/execution_plan.rb +++ b/lib/dynflow/execution_plan.rb @@ -6,7 +6,6 @@ module Dynflow # rubocop:disable Metrics/ClassLength # TODO extract planning logic to an extra class ExecutionPlanner class ExecutionPlan < Serializable - # a fallback object representing a plan with some corrupted data, # preventing to load the whole plan properly, this can be used for presenting # at least some data and not running into internal server errors diff --git a/lib/dynflow/execution_plan/dependency_graph.rb b/lib/dynflow/execution_plan/dependency_graph.rb index 539b7a74d..01c8379f2 100644 --- a/lib/dynflow/execution_plan/dependency_graph.rb +++ b/lib/dynflow/execution_plan/dependency_graph.rb @@ -2,7 +2,6 @@ module Dynflow class ExecutionPlan::DependencyGraph - def initialize @graph = Hash.new { |h, k| h[k] = Set.new } end @@ -26,6 +25,5 @@ def mark_satisfied(step_id, required_step_id) def unresolved? @graph.any? { |step_id, required_step_ids| required_step_ids.any? } end - end end diff --git a/lib/dynflow/execution_plan/output_reference.rb b/lib/dynflow/execution_plan/output_reference.rb index eeaf39df6..be167a0fe 100644 --- a/lib/dynflow/execution_plan/output_reference.rb +++ b/lib/dynflow/execution_plan/output_reference.rb @@ -82,6 +82,5 @@ def self.new_from_hash(hash) hash.fetch(:action_id), hash.fetch(:subkeys)) end - end end diff --git a/lib/dynflow/execution_plan/steps/abstract_flow_step.rb b/lib/dynflow/execution_plan/steps/abstract_flow_step.rb index e8e9ff09b..f922b578e 100644 --- a/lib/dynflow/execution_plan/steps/abstract_flow_step.rb +++ b/lib/dynflow/execution_plan/steps/abstract_flow_step.rb @@ -3,7 +3,6 @@ module Dynflow module ExecutionPlan::Steps class AbstractFlowStep < Abstract - # Method called when initializing the step to customize the behavior based on the # action definition during the planning phase def update_from_action(action) diff --git a/lib/dynflow/execution_plan/steps/finalize_step.rb b/lib/dynflow/execution_plan/steps/finalize_step.rb index 33abb124b..57532153c 100644 --- a/lib/dynflow/execution_plan/steps/finalize_step.rb +++ b/lib/dynflow/execution_plan/steps/finalize_step.rb @@ -3,7 +3,6 @@ module Dynflow module ExecutionPlan::Steps class FinalizeStep < AbstractFlowStep - def self.state_transitions @state_transitions ||= { pending: [:running, :skipped], # :skipped when its run_step is skipped @@ -28,7 +27,6 @@ def mark_to_skip self.state = :skipped self.save end - end end end diff --git a/lib/dynflow/execution_plan/steps/run_step.rb b/lib/dynflow/execution_plan/steps/run_step.rb index 5716bbcc4..9b76eceaa 100644 --- a/lib/dynflow/execution_plan/steps/run_step.rb +++ b/lib/dynflow/execution_plan/steps/run_step.rb @@ -3,7 +3,6 @@ module Dynflow module ExecutionPlan::Steps class RunStep < AbstractFlowStep - def self.state_transitions @state_transitions ||= { pending: [:running, :skipped, :error], # :skipped when it cannot be run because it depends on skipping step diff --git a/lib/dynflow/flows/abstract_composed.rb b/lib/dynflow/flows/abstract_composed.rb index 2145c2bd1..c659ac4d4 100644 --- a/lib/dynflow/flows/abstract_composed.rb +++ b/lib/dynflow/flows/abstract_composed.rb @@ -3,7 +3,6 @@ module Dynflow module Flows class AbstractComposed < Abstract - attr_reader :flows def initialize(flows) @@ -95,7 +94,6 @@ def expand_steps(index) index += 1 end end - end end end diff --git a/lib/dynflow/flows/atom.rb b/lib/dynflow/flows/atom.rb index 6662b3d97..b93566468 100644 --- a/lib/dynflow/flows/atom.rb +++ b/lib/dynflow/flows/atom.rb @@ -3,7 +3,6 @@ module Dynflow module Flows class Atom < Abstract - attr_reader :step_id def encode @@ -32,7 +31,6 @@ def self.new_from_hash(hash) check_class_matching hash new(hash[:step_id]) end - end end end diff --git a/lib/dynflow/flows/concurrence.rb b/lib/dynflow/flows/concurrence.rb index d5332642a..3814d3274 100644 --- a/lib/dynflow/flows/concurrence.rb +++ b/lib/dynflow/flows/concurrence.rb @@ -3,7 +3,6 @@ module Dynflow module Flows class Concurrence < AbstractComposed - protected def add_to_sequence(satisfying_flows, dependent_flow) diff --git a/lib/dynflow/flows/sequence.rb b/lib/dynflow/flows/sequence.rb index f3933bcdf..0f636ebd4 100644 --- a/lib/dynflow/flows/sequence.rb +++ b/lib/dynflow/flows/sequence.rb @@ -3,7 +3,6 @@ module Dynflow module Flows class Sequence < AbstractComposed - protected def add_to_sequence(satisfying_flows, dependent_flow) diff --git a/lib/dynflow/logger_adapters/abstract.rb b/lib/dynflow/logger_adapters/abstract.rb index 14ebeefcf..d5d5164a3 100644 --- a/lib/dynflow/logger_adapters/abstract.rb +++ b/lib/dynflow/logger_adapters/abstract.rb @@ -3,7 +3,6 @@ module Dynflow module LoggerAdapters class Abstract - # @returns [#fatal, #error, #warn, #info, #debug] logger object for logging errors from action execution def action_logger raise NotImplementedError diff --git a/lib/dynflow/logger_adapters/delegator.rb b/lib/dynflow/logger_adapters/delegator.rb index 1e876953a..85636fd31 100644 --- a/lib/dynflow/logger_adapters/delegator.rb +++ b/lib/dynflow/logger_adapters/delegator.rb @@ -3,7 +3,6 @@ module Dynflow module LoggerAdapters class Delegator < Abstract - attr_reader :action_logger, :dynflow_logger def initialize(action_logger, dynflow_logger, formatters = [Formatters::Exception]) diff --git a/lib/dynflow/middleware/resolver.rb b/lib/dynflow/middleware/resolver.rb index 414b73e92..c2830476a 100644 --- a/lib/dynflow/middleware/resolver.rb +++ b/lib/dynflow/middleware/resolver.rb @@ -4,7 +4,6 @@ module Dynflow class Middleware::Resolver - include TSort include Algebrick::TypeCheck @@ -60,6 +59,5 @@ def tsort_each_node(&block) def tsort_each_child(node, &block) @deps.fetch(node).each(&block) end - end end diff --git a/lib/dynflow/middleware/world.rb b/lib/dynflow/middleware/world.rb index 986c39f17..a4e6cec1f 100644 --- a/lib/dynflow/middleware/world.rb +++ b/lib/dynflow/middleware/world.rb @@ -2,7 +2,6 @@ module Dynflow class Middleware::World - include Algebrick::TypeCheck def initialize @@ -55,6 +54,5 @@ def middleware_classes(action_class) end return @middleware_classes_cache[action_class] end - end end diff --git a/lib/dynflow/persistence.rb b/lib/dynflow/persistence.rb index f9dd1ca8a..c0112e792 100644 --- a/lib/dynflow/persistence.rb +++ b/lib/dynflow/persistence.rb @@ -5,7 +5,6 @@ module Dynflow class Persistence - include Algebrick::TypeCheck attr_reader :adapter diff --git a/lib/dynflow/persistence_adapters/abstract.rb b/lib/dynflow/persistence_adapters/abstract.rb index 62b84a112..94509b061 100644 --- a/lib/dynflow/persistence_adapters/abstract.rb +++ b/lib/dynflow/persistence_adapters/abstract.rb @@ -3,7 +3,6 @@ module Dynflow module PersistenceAdapters class Abstract - # The logger is set by the world when used inside it attr_accessor :logger diff --git a/lib/dynflow/rails/daemon.rb b/lib/dynflow/rails/daemon.rb index 0b99bd417..5b401717d 100644 --- a/lib/dynflow/rails/daemon.rb +++ b/lib/dynflow/rails/daemon.rb @@ -176,7 +176,6 @@ def to_gb(string) else raise "Unknown unit: #{unit.inspect}!" end end - end end end diff --git a/lib/dynflow/semaphores/abstract.rb b/lib/dynflow/semaphores/abstract.rb index 3754fd2cf..ad1c9abb4 100644 --- a/lib/dynflow/semaphores/abstract.rb +++ b/lib/dynflow/semaphores/abstract.rb @@ -3,7 +3,6 @@ module Dynflow module Semaphores class Abstract - # Tries to get ticket from the semaphore # Returns true if thing got a ticket # Rturns false otherwise and puts the thing into the semaphore's queue diff --git a/lib/dynflow/semaphores/aggregating.rb b/lib/dynflow/semaphores/aggregating.rb index c0ed28dc4..12bb1c01a 100644 --- a/lib/dynflow/semaphores/aggregating.rb +++ b/lib/dynflow/semaphores/aggregating.rb @@ -3,7 +3,6 @@ module Dynflow module Semaphores class Aggregating < Abstract - attr_reader :children, :waiting def initialize(children) @@ -59,7 +58,6 @@ def release(n = 1, key = nil) @children[key].release n end end - end end end diff --git a/lib/dynflow/semaphores/dummy.rb b/lib/dynflow/semaphores/dummy.rb index b1802d44f..e5e74b7c6 100644 --- a/lib/dynflow/semaphores/dummy.rb +++ b/lib/dynflow/semaphores/dummy.rb @@ -3,7 +3,6 @@ module Dynflow module Semaphores class Dummy < Abstract - def wait(thing) true end diff --git a/lib/dynflow/semaphores/stateful.rb b/lib/dynflow/semaphores/stateful.rb index 84b450546..6c36d5d6a 100644 --- a/lib/dynflow/semaphores/stateful.rb +++ b/lib/dynflow/semaphores/stateful.rb @@ -3,7 +3,6 @@ module Dynflow module Semaphores class Stateful < Abstract - attr_reader :free, :tickets, :waiting, :meta def initialize(tickets, free = tickets, meta = {}) diff --git a/lib/dynflow/serializer.rb b/lib/dynflow/serializer.rb index 6a5903724..8d4cd1999 100644 --- a/lib/dynflow/serializer.rb +++ b/lib/dynflow/serializer.rb @@ -8,7 +8,6 @@ def self.serializer end class Serializer < Algebrick::Serializer - ARBITRARY_TYPE_KEY = :class MARSHAL_KEY = :marshaled diff --git a/lib/dynflow/serializers/abstract.rb b/lib/dynflow/serializers/abstract.rb index 1883a3d60..99324a642 100644 --- a/lib/dynflow/serializers/abstract.rb +++ b/lib/dynflow/serializers/abstract.rb @@ -7,7 +7,6 @@ module Serializers # Used by {DelayedPlan} to store arguments which should be passed into # the {Dynflow::Action}'s #plan method when the plan is executed. class Abstract - attr_reader :args, :serialized_args # @param args [Array] arguments to be serialized @@ -66,7 +65,6 @@ def serialize(arg) def deserialize(arg) raise NotImplementedError end - end end end diff --git a/lib/dynflow/serializers/noop.rb b/lib/dynflow/serializers/noop.rb index 64cd43224..31a643934 100644 --- a/lib/dynflow/serializers/noop.rb +++ b/lib/dynflow/serializers/noop.rb @@ -3,7 +3,6 @@ module Dynflow module Serializers class Noop < Abstract - def serialize(arg) arg end @@ -11,7 +10,6 @@ def serialize(arg) def deserialize(arg) arg end - end end end diff --git a/lib/dynflow/testing/managed_clock.rb b/lib/dynflow/testing/managed_clock.rb index afec452a8..2b7ab5523 100644 --- a/lib/dynflow/testing/managed_clock.rb +++ b/lib/dynflow/testing/managed_clock.rb @@ -3,7 +3,6 @@ module Dynflow module Testing class ManagedClock - attr_reader :pending_pings include Algebrick::Types diff --git a/lib/dynflow/throttle_limiter.rb b/lib/dynflow/throttle_limiter.rb index 65e5d0495..94b550d1e 100644 --- a/lib/dynflow/throttle_limiter.rb +++ b/lib/dynflow/throttle_limiter.rb @@ -2,7 +2,6 @@ module Dynflow class ThrottleLimiter - attr_reader :core def initialize(world) diff --git a/lib/dynflow/watchers/memory_consumption_watcher.rb b/lib/dynflow/watchers/memory_consumption_watcher.rb index e0b4e68a3..b0a72e0a8 100644 --- a/lib/dynflow/watchers/memory_consumption_watcher.rb +++ b/lib/dynflow/watchers/memory_consumption_watcher.rb @@ -5,7 +5,6 @@ module Dynflow module Watchers class MemoryConsumptionWatcher - attr_reader :memory_limit, :world def initialize(world, memory_limit, options) diff --git a/lib/dynflow/web/console.rb b/lib/dynflow/web/console.rb index 7aa5bb1d6..ace896427 100644 --- a/lib/dynflow/web/console.rb +++ b/lib/dynflow/web/console.rb @@ -4,7 +4,6 @@ module Dynflow module Web class Console < Sinatra::Base - set :public_folder, Web.web_dir('assets') set :views, Web.web_dir('views') set :per_page, 10 @@ -108,7 +107,6 @@ class Console < Sinatra::Base redirect(url "/#{plan.id}?notice=#{url_encode('The step does not support cancelling')}") end end - end end end diff --git a/lib/dynflow/world.rb b/lib/dynflow/world.rb index 87b83655f..117e3fc20 100644 --- a/lib/dynflow/world.rb +++ b/lib/dynflow/world.rb @@ -389,6 +389,5 @@ def spawn_and_wait(klass, name, *args) initialized.wait return actor end - end end diff --git a/test/action_test.rb b/test/action_test.rb index e4579e20e..91aac0bee 100644 --- a/test/action_test.rb +++ b/test/action_test.rb @@ -197,7 +197,6 @@ def wont_fail end class TestPollingAction < Dynflow::Action - class Config attr_accessor :external_service, :poll_max_retries, :poll_intervals, :attempts_before_next_interval @@ -400,7 +399,6 @@ def run; end end class ParentAction < Dynflow::Action - include Dynflow::Action::WithSubPlans def plan(*_) @@ -482,7 +480,6 @@ def create_sub_plans def batch(from, size) total_count.times.drop(from).take(size) end - end let(:execution_plan) { world.trigger(ParentAction, count: 2).finished.value } diff --git a/test/concurrency_control_test.rb b/test/concurrency_control_test.rb index 0aadbd478..5d620bee8 100644 --- a/test/concurrency_control_test.rb +++ b/test/concurrency_control_test.rb @@ -96,9 +96,7 @@ def successful?(plan) end class LoggingThrottleLimiter < Dynflow::ThrottleLimiter - class LoggingCore < Dynflow::ThrottleLimiter::Core - attr_reader :running def initialize(*args) diff --git a/test/support/code_workflow_example.rb b/test/support/code_workflow_example.rb index fdbcf3bb7..f79b087cb 100644 --- a/test/support/code_workflow_example.rb +++ b/test/support/code_workflow_example.rb @@ -6,7 +6,6 @@ module Support module CodeWorkflowExample class IncomingIssues < Dynflow::Action - def plan(issues) issues.each do |issue| plan_action(IncomingIssue, issue) @@ -37,7 +36,6 @@ def summary end class IncomingIssue < Dynflow::Action - def plan(issue) raise "You want me to fail" if issue == :fail plan_self(issue) @@ -48,11 +46,9 @@ def plan(issue) param :author, String param :text, String end - end class Triage < Dynflow::Action - def plan(issue) triage = plan_self(issue) plan_action(UpdateIssue, @@ -85,11 +81,9 @@ def finalize error! 'Trolling detected' if input[:text] == "trolling in finalize" TestExecutionLog.finalize << self end - end class UpdateIssue < Dynflow::Action - input_format do param :author, String param :text, String @@ -102,7 +96,6 @@ def run end class NotifyAssignee < Dynflow::Action - def self.subscribe Triage end @@ -146,7 +139,6 @@ def plan(commit, reviews = { 'Morfeus' => true, 'Neo' => true }) end class FastCommit < Dynflow::Action - def plan(commit) sequence do ci, review = concurrence do @@ -164,11 +156,9 @@ def plan(commit) input_format do param :sha, String end - end class Ci < Dynflow::Action - input_format do param :commit, Commit.input_format end @@ -183,7 +173,6 @@ def run end class Review < Dynflow::Action - input_format do param :reviewer, String param :commit, Commit.input_format @@ -203,7 +192,6 @@ def run end class Merge < Dynflow::Action - input_format do param :commit, Commit.input_format param :ci_result, Ci.output_format @@ -234,25 +222,21 @@ class DummyAnotherTrigger < Dynflow::Action end class DummySubscribe < Dynflow::Action - def self.subscribe DummyTrigger end def run end - end class DummyMultiSubscribe < Dynflow::Action - def self.subscribe [DummyTrigger, DummyAnotherTrigger] end def run end - end class CancelableSuspended < Dynflow::Action diff --git a/test/support/dummy_example.rb b/test/support/dummy_example.rb index 66f84b332..c066d778f 100644 --- a/test/support/dummy_example.rb +++ b/test/support/dummy_example.rb @@ -88,7 +88,6 @@ def run_progress end class WeightedPolling < Dynflow::Action - def plan(input) sequence do plan_self(input) diff --git a/test/support/middleware_example.rb b/test/support/middleware_example.rb index 2913e64ac..5c82bf161 100644 --- a/test/support/middleware_example.rb +++ b/test/support/middleware_example.rb @@ -3,7 +3,6 @@ module Support module MiddlewareExample class LogMiddleware < Dynflow::Middleware - def self.log @log end @@ -52,11 +51,9 @@ def finalize_phase(*_) pass log 'after_finalize_phase' end - end class LogRunMiddleware < Dynflow::Middleware - def log(message) LogMiddleware.log << "#{self.class.name[/\w+$/]}::#{message}" end @@ -106,7 +103,6 @@ def filter_sensitive_data end class LoggingAction < Dynflow::Action - middleware.use LogMiddleware def log(message) @@ -133,7 +129,6 @@ def finalize end class ObservingMiddleware < Dynflow::Middleware - def log(message) LogMiddleware.log << message end @@ -147,7 +142,6 @@ def run(*args) end class AnotherObservingMiddleware < ObservingMiddleware - def delay(*args) pass(*args).tap do log("delay#set-input:#{action.world.id}") @@ -159,7 +153,6 @@ def plan(*args) log("plan#input:#{action.input[:message]}") pass(*args) end - end class Action < Dynflow::Action diff --git a/test/support/rescue_example.rb b/test/support/rescue_example.rb index 6d3b54986..e0dd36d6d 100644 --- a/test/support/rescue_example.rb +++ b/test/support/rescue_example.rb @@ -6,7 +6,6 @@ module Support module RescueExample class ComplexActionWithSkip < Dynflow::Action - def plan(error_state) sequence do concurrence do @@ -21,20 +20,16 @@ def plan(error_state) def rescue_strategy_for_self Dynflow::Action::Rescue::Skip end - end class ComplexActionWithoutSkip < ComplexActionWithSkip - def rescue_strategy_for_planned_action(action) # enforce pause even when error on skipable action Dynflow::Action::Rescue::Pause end - end class AbstractAction < Dynflow::Action - def plan(identifier, desired_state) plan_self(identifier: identifier, desired_state: desired_state) end @@ -58,11 +53,9 @@ def finalize raise 'some error as you wish' end end - end class ActionWithSkip < AbstractAction - def run(event = nil) if event === Dynflow::Action::Skip output[:message] = "skipped because #{self.error.message}" @@ -75,19 +68,15 @@ def run(event = nil) def rescue_strategy_for_self Dynflow::Action::Rescue::Skip end - end class ActionWithFail < AbstractAction - def rescue_strategy_for_self Dynflow::Action::Rescue::Fail end - end class ComplexActionWithFail < ActionWithFail - def plan(error_state) sequence do concurrence do @@ -98,7 +87,6 @@ def plan(error_state) plan_action(ActionWithSkip, 6, :success) end end - end end diff --git a/test/support/test_execution_log.rb b/test/support/test_execution_log.rb index 63c599753..528801222 100644 --- a/test/support/test_execution_log.rb +++ b/test/support/test_execution_log.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true class TestExecutionLog - include Enumerable def initialize @@ -39,5 +38,4 @@ def self.run def self.finalize @finalize || [] end - end diff --git a/test/test_helper.rb b/test/test_helper.rb index adedc8758..c58efc78d 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -25,7 +25,6 @@ # To be able to stop a process in some step and perform assertions while paused class TestPause - def self.setup @pause = Concurrent::Promises.resolvable_future @ready = Concurrent::Promises.resolvable_future From 1f4ccb584fe75f1da0b058114fa63adce4c1d2aa Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:40:32 +0100 Subject: [PATCH 11/44] Fix Bundler/OrderedGems cop --- .rubocop_todo.yml | 9 --------- Gemfile | 4 ++-- doc/pages/Gemfile | 6 +++--- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c4548d6ce..67b53ae0b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,15 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. -# Include: **/*.gemfile, **/Gemfile, **/gems.rb -Bundler/OrderedGems: - Exclude: - - 'Gemfile' - - 'doc/pages/Gemfile' - # Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. diff --git a/Gemfile b/Gemfile index 7e1573c47..e7698b572 100644 --- a/Gemfile +++ b/Gemfile @@ -14,8 +14,8 @@ group :pry do end group :sidekiq do - gem 'sidekiq' gem 'gitlab-sidekiq-fetcher', :require => 'sidekiq-reliable-fetch' + gem 'sidekiq' end group :postgresql do @@ -36,8 +36,8 @@ end group :rails do gem 'daemons' - gem 'rails', '>= 4.2.9', '< 7' gem 'logging' + gem 'rails', '>= 4.2.9', '< 7' end group :telemetry do diff --git a/doc/pages/Gemfile b/doc/pages/Gemfile index e2051b269..6aa75ad80 100644 --- a/doc/pages/Gemfile +++ b/doc/pages/Gemfile @@ -2,10 +2,10 @@ source 'https://rubygems.org' -gem 'rake' gem 'jekyll' gem 'pry' +gem 'pygments.rb' +gem 'rake' +gem 'redcarpet' gem 'ruby-nuggets' # require by tags plugin gem 'therubyracer' -gem 'redcarpet' -gem 'pygments.rb' From ac0bdf1ce3b7ba7f0ef587fb91c57b59c24f20a0 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:41:07 +0100 Subject: [PATCH 12/44] Fix Gemspec/OrderedDependencies cop --- .rubocop_todo.yml | 8 -------- dynflow.gemspec | 18 +++++++++--------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 67b53ae0b..f4dba9de3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,14 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. -# Include: **/*.gemspec -Gemspec/OrderedDependencies: - Exclude: - - 'dynflow.gemspec' - # Offense count: 1 # Configuration parameters: Include. # Include: **/*.gemspec diff --git a/dynflow.gemspec b/dynflow.gemspec index ab95c09fc..acbdc6ab0 100644 --- a/dynflow.gemspec +++ b/dynflow.gemspec @@ -20,22 +20,22 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 2.3.0' - s.add_dependency "multi_json" - s.add_dependency "msgpack", '~> 1.3', '>= 1.3.3' - s.add_dependency "apipie-params" s.add_dependency "algebrick", '~> 0.7.0' + s.add_dependency "apipie-params" s.add_dependency "concurrent-ruby", '~> 1.1.3' s.add_dependency "concurrent-ruby-edge", '~> 0.6.0' + s.add_dependency "msgpack", '~> 1.3', '>= 1.3.3' + s.add_dependency "multi_json" s.add_dependency "sequel", '>= 4.0.0' - s.add_development_dependency "rake" - s.add_development_dependency "rack-test" + s.add_development_dependency 'activejob' + s.add_development_dependency "activerecord" s.add_development_dependency "minitest", "< 5.19" s.add_development_dependency "minitest-reporters" s.add_development_dependency "minitest-stub-const" - s.add_development_dependency "activerecord" - s.add_development_dependency 'activejob' - s.add_development_dependency "sqlite3" - s.add_development_dependency "sinatra" s.add_development_dependency 'mocha' + s.add_development_dependency "rack-test" + s.add_development_dependency "rake" + s.add_development_dependency "sinatra" + s.add_development_dependency "sqlite3" end From d0fda74627dbc144a7f1dac1121f0356c79571d7 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:41:52 +0100 Subject: [PATCH 13/44] Fix Gemspec/RequiredRubyVersion cop --- .rubocop_todo.yml | 7 ------- dynflow.gemspec | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f4dba9de3..c5ef4994f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,13 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 1 -# Configuration parameters: Include. -# Include: **/*.gemspec -Gemspec/RequiredRubyVersion: - Exclude: - - 'dynflow.gemspec' - # Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: IndentationWidth. diff --git a/dynflow.gemspec b/dynflow.gemspec index acbdc6ab0..64d0e1223 100644 --- a/dynflow.gemspec +++ b/dynflow.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |s| s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.require_paths = ["lib"] - s.required_ruby_version = '>= 2.3.0' + s.required_ruby_version = '>= 2.7.0' s.add_dependency "algebrick", '~> 0.7.0' s.add_dependency "apipie-params" From 063a540057aab6482ebcec8952de555d3cda4f23 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:42:46 +0100 Subject: [PATCH 14/44] Fix Layout/AssignmentIndentation cop --- .rubocop_todo.yml | 8 -------- lib/dynflow/director.rb | 2 +- lib/dynflow/world.rb | 14 +++++++------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c5ef4994f..6742b3a19 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,14 +6,6 @@ # 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: IndentationWidth. -Layout/AssignmentIndentation: - Exclude: - - 'lib/dynflow/director.rb' - - 'lib/dynflow/world.rb' - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleAlignWith. diff --git a/lib/dynflow/director.rb b/lib/dynflow/director.rb index f4f56c981..2e5fde186 100644 --- a/lib/dynflow/director.rb +++ b/lib/dynflow/director.rb @@ -311,7 +311,7 @@ def track_execution_plan(execution_plan_id, finished) end @execution_plan_managers[execution_plan_id] = - ExecutionPlanManager.new(@world, execution_plan, finished) + ExecutionPlanManager.new(@world, execution_plan, finished) rescue Dynflow::Error => e finished.reject e nil diff --git a/lib/dynflow/world.rb b/lib/dynflow/world.rb index 117e3fc20..b5903f43a 100644 --- a/lib/dynflow/world.rb +++ b/lib/dynflow/world.rb @@ -279,7 +279,7 @@ def terminating? def auto_execute coordinator.acquire(Coordinator::AutoExecuteLock.new(self)) do planned_execution_plans = - self.persistence.find_execution_plans filters: { 'state' => %w(planned paused), 'result' => (ExecutionPlan.results - [:error]).map(&:to_s) } + self.persistence.find_execution_plans filters: { 'state' => %w(planned paused), 'result' => (ExecutionPlan.results - [:error]).map(&:to_s) } planned_execution_plans.map do |ep| if coordinator.find_locks(Dynflow::Coordinator::ExecutionLock.unique_filter(ep.id)).empty? execute(ep.id) @@ -362,12 +362,12 @@ def start_termination def calculate_subscription_index @subscription_index = - action_classes.each_with_object(Hash.new { |h, k| h[k] = [] }) do |klass, index| - next unless klass.subscribe - Array(klass.subscribe).each do |subscribed_class| - index[Utils.constantize(subscribed_class.to_s)] << klass - end - end.tap { |o| o.freeze } + action_classes.each_with_object(Hash.new { |h, k| h[k] = [] }) do |klass, index| + next unless klass.subscribe + Array(klass.subscribe).each do |subscribed_class| + index[Utils.constantize(subscribed_class.to_s)] << klass + end + end.tap { |o| o.freeze } end def run_before_termination_hooks From e5824e8f509cf4fa87158732e383a3487b457f65 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:44:13 +0100 Subject: [PATCH 15/44] Fix Layout/ClosingHeredocIndentation cop --- .rubocop_todo.yml | 7 ------- lib/dynflow/web/console_helpers.rb | 4 ++-- test/executor_test.rb | 8 ++++---- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6742b3a19..14ec39062 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -14,13 +14,6 @@ Layout/BlockAlignment: Exclude: - 'test/test_helper.rb' -# Offense count: 6 -# Cop supports --auto-correct. -Layout/ClosingHeredocIndentation: - Exclude: - - 'lib/dynflow/web/console_helpers.rb' - - 'test/executor_test.rb' - # Offense count: 16 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/dynflow/web/console_helpers.rb b/lib/dynflow/web/console_helpers.rb index 804028f29..7c2648280 100644 --- a/lib/dynflow/web/console_helpers.rb +++ b/lib/dynflow/web/console_helpers.rb @@ -37,7 +37,7 @@ def prettyprint(value) pretty_value = prettify_value(value) <<-HTML
#{h(pretty_value)}
- HTML + HTML else "" end @@ -91,7 +91,7 @@ def show_action_data(label, value) #{h(label)} #{value_html}

- HTML + HTML else "" end diff --git a/test/executor_test.rb b/test/executor_test.rb index 91b4106b2..fc039c0cf 100644 --- a/test/executor_test.rb +++ b/test/executor_test.rb @@ -494,7 +494,7 @@ def persisted_plan 13: Triage(success) {\"author\"=>\"John Doe\", \"text\"=>\"ok\"} --> {\"classification\"=>{\"assignee\"=>\"John Doe\", \"severity\"=>\"medium\"}} 16: UpdateIssue(success) {\"author\"=>\"John Doe\", \"text\"=>\"trolling\", \"assignee\"=>\"John Doe\", \"severity\"=>\"medium\"} --> {} 18: NotifyAssignee(success) {\"triage\"=>{\"classification\"=>{\"assignee\"=>\"John Doe\", \"severity\"=>\"medium\"}}} --> {} - EXECUTED_RUN_FLOW + EXECUTED_RUN_FLOW end end @@ -533,7 +533,7 @@ def persisted_plan 14: Triage(success) {\"author\"=>\"John Doe\", \"text\"=>\"ok\"} --> {\"classification\"=>{\"assignee\"=>\"John Doe\", \"severity\"=>\"medium\"}} 19: NotifyAssignee(success) {\"triage\"=>{\"classification\"=>{\"assignee\"=>\"John Doe\", \"severity\"=>\"medium\"}}} --> {} 20: IncomingIssues(success) {\"issues\"=>[{\"author\"=>\"Peter Smith\", \"text\"=>\"Failing test\"}, {\"author\"=>\"John Doe\", \"text\"=>\"trolling in finalize\"}]} --> {} - EXECUTED_RUN_FLOW + EXECUTED_RUN_FLOW end end @@ -572,7 +572,7 @@ def persisted_plan 13: Triage(skipped) {\"author\"=>\"John Doe\", \"text\"=>\"trolling\"} --> {} 16: UpdateIssue(skipped) {\"author\"=>\"John Doe\", \"text\"=>\"trolling\", \"assignee\"=>Step(13).output[:classification][:assignee], \"severity\"=>Step(13).output[:classification][:severity]} --> {} 18: NotifyAssignee(skipped) {\"triage\"=>Step(13).output} --> {} - EXECUTED_RUN_FLOW + EXECUTED_RUN_FLOW assert_finalize_flow <<-FINALIZE_FLOW, resumed_execution_plan Dynflow::Flows::Sequence @@ -581,7 +581,7 @@ def persisted_plan 14: Triage(skipped) {\"author\"=>\"John Doe\", \"text\"=>\"trolling\"} --> {} 19: NotifyAssignee(skipped) {\"triage\"=>Step(13).output} --> {} 20: IncomingIssues(success) {\"issues\"=>[{\"author\"=>\"Peter Smith\", \"text\"=>\"Failing test\"}, {\"author\"=>\"John Doe\", \"text\"=>\"trolling\"}]} --> {} - FINALIZE_FLOW + FINALIZE_FLOW end end From b59cf549b086e54caf097f797341dfcccf4b5147 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:44:58 +0100 Subject: [PATCH 16/44] Fix Layout/EmptyLineBetweenDefs cop --- .rubocop_todo.yml | 9 --------- lib/dynflow/utils/indifferent_hash.rb | 4 ++++ test/executor_test.rb | 2 ++ test/support/dummy_example.rb | 1 + 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 14ec39062..23b3355b7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,15 +30,6 @@ Layout/DotPosition: - 'test/rescue_test.rb' - 'test/web_console_test.rb' -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. -Layout/EmptyLineBetweenDefs: - Exclude: - - 'lib/dynflow/utils/indifferent_hash.rb' - - 'test/executor_test.rb' - - 'test/support/dummy_example.rb' - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/dynflow/utils/indifferent_hash.rb b/lib/dynflow/utils/indifferent_hash.rb index 096c4ed67..3a099a859 100644 --- a/lib/dynflow/utils/indifferent_hash.rb +++ b/lib/dynflow/utils/indifferent_hash.rb @@ -97,9 +97,13 @@ def delete(key) end def stringify_keys!; self end + def deep_stringify_keys!; self end + def stringify_keys; dup end + def deep_stringify_keys; dup end + def to_options!; self end def select(*args, &block) diff --git a/test/executor_test.rb b/test/executor_test.rb index fc039c0cf..40c9b37e1 100644 --- a/test/executor_test.rb +++ b/test/executor_test.rb @@ -12,7 +12,9 @@ module RedisMocks def release_orchestrator_lock; end + def wait_for_orchestrator_lock; end + def reacquire_orchestrator_lock; end end diff --git a/test/support/dummy_example.rb b/test/support/dummy_example.rb index c066d778f..19ea38af4 100644 --- a/test/support/dummy_example.rb +++ b/test/support/dummy_example.rb @@ -25,6 +25,7 @@ class DummyCustomDelaySerializer < Dynflow::Action def delay(delay_options, *args) MySerializer.new(args) end + def run; end end From c72f5755c21c096897d81cac299c5f27585d4744 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:45:36 +0100 Subject: [PATCH 17/44] Fix Layout/EmptyLinesAroundAccessModifier cop --- .rubocop_todo.yml | 8 -------- lib/dynflow/utils/indifferent_hash.rb | 1 + 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 23b3355b7..52dff4ad8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,14 +30,6 @@ Layout/DotPosition: - 'test/rescue_test.rb' - 'test/web_console_test.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: around, only_before -Layout/EmptyLinesAroundAccessModifier: - Exclude: - - 'lib/dynflow/utils/indifferent_hash.rb' - # Offense count: 77 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/dynflow/utils/indifferent_hash.rb b/lib/dynflow/utils/indifferent_hash.rb index 3a099a859..622c3468f 100644 --- a/lib/dynflow/utils/indifferent_hash.rb +++ b/lib/dynflow/utils/indifferent_hash.rb @@ -124,6 +124,7 @@ def to_hash end protected + def convert_key(key) key.kind_of?(Symbol) ? key.to_s : key end From 78f475b90e2f6776896ae65b449dcf015942c90c Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:46:11 +0100 Subject: [PATCH 18/44] Fix Layout/EmptyLinesAroundBlockBody cop --- .rubocop_todo.yml | 7 ------- test/abnormal_states_recovery_test.rb | 3 --- test/action_test.rb | 6 ------ test/batch_sub_tasks_test.rb | 1 - test/clock_test.rb | 2 -- test/dispatcher_test.rb | 1 - test/execution_plan_test.rb | 23 ----------------------- test/executor_test.rb | 20 -------------------- test/flows_test.rb | 1 - test/future_execution_test.rb | 2 -- test/middleware_test.rb | 2 -- test/persistence_test.rb | 1 - test/rescue_test.rb | 9 --------- test/semaphores_test.rb | 2 -- test/test_helper.rb | 1 - test/testing_test.rb | 2 -- test/web_console_test.rb | 1 - 17 files changed, 84 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 52dff4ad8..937cc6313 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,13 +30,6 @@ Layout/DotPosition: - 'test/rescue_test.rb' - 'test/web_console_test.rb' -# Offense count: 77 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Enabled: false - # Offense count: 137 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/test/abnormal_states_recovery_test.rb b/test/abnormal_states_recovery_test.rb index c4796b3e4..47f360050 100644 --- a/test/abnormal_states_recovery_test.rb +++ b/test/abnormal_states_recovery_test.rb @@ -8,7 +8,6 @@ module Dynflow module ConsistencyCheckTest describe "consistency check" do - include TestHelpers def with_invalidation_while_executing(finish) @@ -44,7 +43,6 @@ def with_invalidation_while_executing(finish) let(:client_world_2) { create_world(false) } describe "for plans assigned to invalid world" do - before do # mention the executors to make sure they are initialized [executor_world, executor_world_2] @@ -188,7 +186,6 @@ def with_invalidation_while_executing(finish) end describe 'auto execute' do - before do client_world.persistence.delete_execution_plans({}) end diff --git a/test/action_test.rb b/test/action_test.rb index 91aac0bee..55f9d3588 100644 --- a/test/action_test.rb +++ b/test/action_test.rb @@ -5,11 +5,9 @@ module Dynflow describe 'action' do - let(:world) { WorldFactory.create_world } describe Action::Missing do - let :action_data do { class: 'RenamedAction', id: 1, @@ -33,7 +31,6 @@ module Dynflow end describe 'children' do - smart_action_class = Class.new(Dynflow::Action) smarter_action_class = Class.new(smart_action_class) @@ -51,7 +48,6 @@ module Dynflow end describe Action::Present do - let :execution_plan do result = world.trigger(Support::CodeWorkflowExample::IncomingIssues, issues_data) _(result).must_be :planned? @@ -75,7 +71,6 @@ module Dynflow end describe 'serialization' do - include Testing it 'fails when input is not serializable' do @@ -383,7 +378,6 @@ def next_ping(action) end describe Action::WithSubPlans do - class FailureSimulator class << self attr_accessor :fail_in_child_plan, :fail_in_child_run diff --git a/test/batch_sub_tasks_test.rb b/test/batch_sub_tasks_test.rb index 1f25b35ea..e293a5abd 100644 --- a/test/batch_sub_tasks_test.rb +++ b/test/batch_sub_tasks_test.rb @@ -110,7 +110,6 @@ def total_count _(action.send(:can_spawn_next_batch?)).must_equal false _(action.current_batch).must_be :empty? end - end end end diff --git a/test/clock_test.rb b/test/clock_test.rb index 88e961acf..10073a05b 100644 --- a/test/clock_test.rb +++ b/test/clock_test.rb @@ -6,7 +6,6 @@ clock_class = Dynflow::Clock describe clock_class do - let(:clock) { clock_class.spawn 'clock' } it 'refuses who without #<< method' do @@ -51,5 +50,4 @@ end threads.each &:join end - end diff --git a/test/dispatcher_test.rb b/test/dispatcher_test.rb index 780a99496..714fbaa42 100644 --- a/test/dispatcher_test.rb +++ b/test/dispatcher_test.rb @@ -5,7 +5,6 @@ module Dynflow module DispatcherTest describe "dispatcher" do - include TestHelpers let(:persistence_adapter) { WorldFactory.persistence_adapter } diff --git a/test/execution_plan_test.rb b/test/execution_plan_test.rb index 5a019ddca..c513b8454 100644 --- a/test/execution_plan_test.rb +++ b/test/execution_plan_test.rb @@ -5,7 +5,6 @@ module Dynflow module ExecutionPlanTest describe ExecutionPlan do - include PlanAssertions let(:world) { WorldFactory.create_world } @@ -16,7 +15,6 @@ module ExecutionPlanTest end describe 'serialization' do - let :execution_plan do world.plan(Support::CodeWorkflowExample::FastCommit, 'sha' => 'abc123') end @@ -26,7 +24,6 @@ module ExecutionPlanTest end describe 'serialized execution plan' do - before { execution_plan.save } after { world.persistence.delete_execution_plans(:uuid => execution_plan.id) } @@ -64,9 +61,7 @@ module ExecutionPlanTest deserialized_execution_plan.execution_history.events, "invalid plan is supposed to still store execution history" end - end - end describe '#label' do @@ -84,24 +79,20 @@ module ExecutionPlanTest end end describe '#result' do - let :execution_plan do world.plan(Support::CodeWorkflowExample::FastCommit, 'sha' => 'abc123') end describe 'for error in planning phase' do - before { execution_plan.steps[2].set_state :error, true } it 'should be :error' do _(execution_plan.result).must_equal :error _(execution_plan.error?).must_equal true end - end describe 'for error in running phase' do - before do step_id = execution_plan.run_flow.all_step_ids[2] execution_plan.steps[step_id].set_state :error, true @@ -110,11 +101,9 @@ module ExecutionPlanTest it 'should be :error' do _(execution_plan.result).must_equal :error end - end describe 'for pending step in running phase' do - before do step_id = execution_plan.run_flow.all_step_ids[2] execution_plan.steps[step_id].set_state :pending, true @@ -123,11 +112,9 @@ module ExecutionPlanTest it 'should be :pending' do _(execution_plan.result).must_equal :pending end - end describe 'for all steps successful or skipped' do - before do execution_plan.run_flow.all_step_ids.each_with_index do |step_id, index| step = execution_plan.steps[step_id] @@ -138,9 +125,7 @@ module ExecutionPlanTest it 'should be :warning' do _(execution_plan.result).must_equal :warning end - end - end describe 'sub plans' do @@ -172,11 +157,9 @@ module ExecutionPlanTest NotifyAssignee PLAN_STEPS end - end describe 'persisted action' do - let :execution_plan do world.plan(Support::CodeWorkflowExample::IncomingIssues, issues_data) end @@ -207,7 +190,6 @@ module ExecutionPlanTest end describe 'planning algorithm' do - describe 'single dependencies' do let :execution_plan do world.plan(Support::CodeWorkflowExample::IncomingIssues, issues_data) @@ -226,7 +208,6 @@ module ExecutionPlanTest 18: NotifyAssignee(pending) {"triage"=>Step(13).output} RUN_FLOW end - end describe 'error in planning phase' do @@ -287,7 +268,6 @@ module ExecutionPlanTest end describe 'finalize flow' do - let :execution_plan do world.plan(Support::CodeWorkflowExample::IncomingIssues, issues_data) end @@ -302,7 +282,6 @@ module ExecutionPlanTest 20: IncomingIssues(pending) {\"issues\"=>[{\"author\"=>\"Peter Smith\", \"text\"=>\"Failing test\"}, {\"author\"=>\"John Doe\", \"text\"=>\"Internal server error\"}]} RUN_FLOW end - end end @@ -356,7 +335,6 @@ module ExecutionPlanTest end describe ExecutionPlan::Steps::Error do - it "doesn't fail when deserializing with missing class" do error = ExecutionPlan::Steps::Error.new_from_hash(exception_class: "RenamedError", message: "This errror is not longer here", @@ -365,7 +343,6 @@ module ExecutionPlanTest _(error.exception_class.to_s).must_equal "Dynflow::Errors::UnknownError[RenamedError]" _(error.exception.inspect).must_equal "Dynflow::Errors::UnknownError[RenamedError]: This errror is not longer here" end - end describe 'with singleton actions' do diff --git a/test/executor_test.rb b/test/executor_test.rb index 40c9b37e1..df0add462 100644 --- a/test/executor_test.rb +++ b/test/executor_test.rb @@ -74,9 +74,7 @@ module ExecutorTest end describe "execution plan state" do - describe "after successful planning" do - let :execution_plan do world.plan(Support::CodeWorkflowExample::IncomingIssues, issues_data) end @@ -103,7 +101,6 @@ module ExecutorTest end describe "after error in planning" do - class FailingAction < Dynflow::Action def plan raise "I failed" @@ -117,7 +114,6 @@ def plan it "is stopped" do _(execution_plan.state).must_equal :stopped end - end describe "when being executed" do @@ -169,7 +165,6 @@ def plan end describe "execution of run flow" do - before do TestExecutionLog.setup end @@ -359,11 +354,9 @@ def persisted_plan assert_equal :success, ep.run_steps.first.state end end - end describe "action with empty flows" do - let :execution_plan do world.plan(Support::CodeWorkflowExample::Dummy, { :text => "dummy" }).tap do |plan| assert_equal plan.run_flow.size, 0 @@ -382,11 +375,9 @@ def persisted_plan world.execute(execution_plan.id) assert_raises(Dynflow::Error) { world.execute(execution_plan.id).value! } end - end describe 'action with empty run flow but some finalize flow' do - let :execution_plan do world.plan(Support::CodeWorkflowExample::DummyWithFinalize, { :text => "dummy" }).tap do |plan| assert_equal plan.run_flow.size, 0 @@ -398,7 +389,6 @@ def persisted_plan _(result.result).must_equal :success _(result.state).must_equal :stopped end - end describe 'running' do @@ -420,7 +410,6 @@ def persisted_plan EXECUTED_RUN_FLOW end end - end describe "execution of finalize flow" do @@ -457,7 +446,6 @@ def persisted_plan _(TestExecutionLog.finalize.size).must_equal 0 end end - end describe "re-execution of run flow after fix in run phase" do @@ -498,11 +486,9 @@ def persisted_plan 18: NotifyAssignee(success) {\"triage\"=>{\"classification\"=>{\"assignee\"=>\"John Doe\", \"severity\"=>\"medium\"}}} --> {} EXECUTED_RUN_FLOW end - end describe "re-execution of run flow after fix in finalize phase" do - after do TestExecutionLog.teardown end @@ -537,11 +523,9 @@ def persisted_plan 20: IncomingIssues(success) {\"issues\"=>[{\"author\"=>\"Peter Smith\", \"text\"=>\"Failing test\"}, {\"author\"=>\"John Doe\", \"text\"=>\"trolling in finalize\"}]} --> {} EXECUTED_RUN_FLOW end - end describe "re-execution of run flow after skipping" do - after do TestExecutionLog.teardown end @@ -584,7 +568,6 @@ def persisted_plan 19: NotifyAssignee(skipped) {\"triage\"=>Step(13).output} --> {} 20: IncomingIssues(success) {\"issues\"=>[{\"author\"=>\"Peter Smith\", \"text\"=>\"Failing test\"}, {\"author\"=>\"John Doe\", \"text\"=>\"trolling\"}]} --> {} FINALIZE_FLOW - end end @@ -620,7 +603,6 @@ def assert_next_steps(expected_next_step_ids, finished_step_id = nil, success = end describe 'what_is_next with errors' do - it "doesn't return next steps if requirements failed" do assert_next_steps([4, 13]) assert_next_steps([], 4, false) @@ -634,7 +616,6 @@ def assert_next_steps(expected_next_step_ids, finished_step_id = nil, success = assert manager.done? end end - end describe 'Pool::JobStorage' do @@ -676,7 +657,6 @@ def assert_next_steps(expected_next_step_ids, finished_step_id = nil, success = assert_nil storage.pop end end - end describe 'termination' do diff --git a/test/flows_test.rb b/test/flows_test.rb index 6d1c1bd4a..30b78856e 100644 --- a/test/flows_test.rb +++ b/test/flows_test.rb @@ -5,7 +5,6 @@ module Dynflow describe 'flow' do - class TestRegistry < Flows::Registry class << self def reset! diff --git a/test/future_execution_test.rb b/test/future_execution_test.rb index 8cc633c9d..cc02a57ca 100644 --- a/test/future_execution_test.rb +++ b/test/future_execution_test.rb @@ -10,7 +10,6 @@ module FutureExecutionTest include Dynflow::Testing::Factories describe 'action scheduling' do - before do @start_at = Time.now.utc + 180 world.persistence.delete_delayed_plans({}) @@ -102,7 +101,6 @@ module FutureExecutionTest _(execution_plan.errors.first.message).must_match /could not be started before set time/ _(history_names.call(execution_plan)).must_equal %W(delay timeout) end - end describe 'polling delayed executor' do diff --git a/test/middleware_test.rb b/test/middleware_test.rb index b5ea6df78..87f029873 100644 --- a/test/middleware_test.rb +++ b/test/middleware_test.rb @@ -79,7 +79,6 @@ module MiddlewareTest WorldFactory.create_world.tap do |world| world.middleware.use(Support::MiddlewareExample::AnotherLogRunMiddleware, after: Support::MiddlewareExample::LogRunMiddleware) - end end @@ -184,7 +183,6 @@ module MiddlewareTest _(presenter_without_middleware.input['text']).must_equal('Lord Voldemort is comming') end end - end end end diff --git a/test/persistence_test.rb b/test/persistence_test.rb index 79f9c1762..791d3497d 100644 --- a/test/persistence_test.rb +++ b/test/persistence_test.rb @@ -7,7 +7,6 @@ module Dynflow module PersistenceTest describe 'persistence adapters' do - let :execution_plans_data do [{ id: 'plan1', :label => 'test1', root_plan_step_id: 1, class: 'Dynflow::ExecutionPlan', state: 'paused' }, { id: 'plan2', :label => 'test2', root_plan_step_id: 1, class: 'Dynflow::ExecutionPlan', state: 'stopped' }, diff --git a/test/rescue_test.rb b/test/rescue_test.rb index 7f2ca35d3..7c8caca7b 100644 --- a/test/rescue_test.rb +++ b/test/rescue_test.rb @@ -5,7 +5,6 @@ module Dynflow module RescueTest describe 'on error' do - Example = Support::RescueExample let(:world) { WorldFactory.create_world } @@ -22,7 +21,6 @@ def execute(*args) describe 'no auto rescue' do describe 'of simple skippable action in run phase' do - let :execution_plan do execute(Example::ActionWithSkip, 1, :error_on_run) end @@ -37,7 +35,6 @@ def execute(*args) end describe 'of simple skippable action in finalize phase' do - let :execution_plan do execute(Example::ActionWithSkip, 1, :error_on_finalize) end @@ -52,7 +49,6 @@ def execute(*args) end describe 'of complex action with skips in run phase' do - let :execution_plan do execute(Example::ComplexActionWithSkip, :error_on_run) end @@ -67,7 +63,6 @@ def execute(*args) end describe 'of complex action with skips in finalize phase' do - let :execution_plan do execute(Example::ComplexActionWithSkip, :error_on_finalize) end @@ -82,7 +77,6 @@ def execute(*args) end describe 'of complex action without skips' do - let :execution_plan do execute(Example::ComplexActionWithoutSkip, :error_on_run) end @@ -97,7 +91,6 @@ def execute(*args) end describe 'of complex action with fail' do - let :execution_plan do execute(Example::ComplexActionWithFail, :error_on_run) end @@ -113,7 +106,6 @@ def execute(*args) end describe 'auto rescue' do - let(:world) do WorldFactory.create_world do |config| config.auto_rescue = true @@ -216,7 +208,6 @@ def execute(*args) _(execution_plan.execution_history.map { |h| [h.name, h.world_id] }).must_equal(expected_history) end end - end end end diff --git a/test/semaphores_test.rb b/test/semaphores_test.rb index 1441552ee..d34a9047c 100644 --- a/test/semaphores_test.rb +++ b/test/semaphores_test.rb @@ -5,7 +5,6 @@ module Dynflow module SemaphoresTest describe ::Dynflow::Semaphores::Stateful do - let(:semaphore_class) { ::Dynflow::Semaphores::Stateful } let(:tickets_count) { 5 } @@ -42,7 +41,6 @@ module SemaphoresTest waiting = semaphore.get_waiting _(waiting).must_equal 3 end - end describe ::Dynflow::Semaphores::Dummy do diff --git a/test/test_helper.rb b/test/test_helper.rb index c58efc78d..34e719471 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -302,7 +302,6 @@ def teardown wait_method.bind(self).call(timeout || default_timeout) end end - end events_test.call diff --git a/test/testing_test.rb b/test/testing_test.rb index 229c9c7cf..0379143df 100644 --- a/test/testing_test.rb +++ b/test/testing_test.rb @@ -10,7 +10,6 @@ module Dynflow include Testing describe 'testing' do - specify '#plan_action' do input = { 'input' => 'input' } action = create_and_plan_action Support::DummyExample::WeightedPolling, input @@ -101,7 +100,6 @@ module Dynflow end describe 'testing examples' do - describe CWE::Commit do it 'plans' do action = create_and_plan_action CWE::Commit, sha = 'commit-sha' diff --git a/test/web_console_test.rb b/test/web_console_test.rb index 2598e2b98..7ee8c5440 100644 --- a/test/web_console_test.rb +++ b/test/web_console_test.rb @@ -9,7 +9,6 @@ module Dynflow describe 'web console' do - include Rack::Test::Methods let(:world) { WorldFactory.create_world } From b51524231623c8b1dbf982e31d91d8f2347deb7f Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:47:04 +0100 Subject: [PATCH 19/44] Fix Layout/EmptyLinesAroundMethodBody cop --- .rubocop_todo.yml | 14 -------------- doc/pages/plugins/toc.rb | 1 - test/dispatcher_test.rb | 1 - 3 files changed, 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 937cc6313..1ae4f273b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,26 +30,12 @@ Layout/DotPosition: - 'test/rescue_test.rb' - 'test/web_console_test.rb' -# Offense count: 137 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only -Layout/EmptyLinesAroundClassBody: - Enabled: false - # Offense count: 1 # Cop supports --auto-correct. Layout/EmptyLinesAroundExceptionHandlingKeywords: Exclude: - 'test/test_helper.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundMethodBody: - Exclude: - - 'doc/pages/plugins/toc.rb' - - 'test/dispatcher_test.rb' - # Offense count: 50 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/doc/pages/plugins/toc.rb b/doc/pages/plugins/toc.rb index bbf9df718..fcf35d385 100644 --- a/doc/pages/plugins/toc.rb +++ b/doc/pages/plugins/toc.rb @@ -3,7 +3,6 @@ module Jekyll module FancyToCFilter def fancytoc(input) - converter = @context.registers[:site].converters.find { |c| c.is_a? Jekyll::Converters::Markdown } extensions = converter.instance_variable_get(:@parser).instance_variable_get(:@redcarpet_extensions) toc_generator = Redcarpet::Markdown.new(Redcarpet::Render::HTML_TOC, extensions) diff --git a/test/dispatcher_test.rb b/test/dispatcher_test.rb index 714fbaa42..a64c55113 100644 --- a/test/dispatcher_test.rb +++ b/test/dispatcher_test.rb @@ -72,7 +72,6 @@ def self.supports_dynamic_retry assert_plan_reexecuted(plan) end end - end def self.supports_ping_pong From 6ac9e57447b22796eb3ef4c52d2aa0ffdb521402 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:47:37 +0100 Subject: [PATCH 20/44] Fix Layout/EmptyLinesAroundModuleBody cop --- .rubocop_todo.yml | 7 ------- doc/pages/plugins/plantuml.rb | 1 - doc/pages/plugins/play.rb | 1 - doc/pages/plugins/tags.rb | 3 --- examples/orchestrate.rb | 1 - examples/orchestrate_evented.rb | 2 -- lib/dynflow/action/format.rb | 3 --- lib/dynflow/action/polling.rb | 2 -- lib/dynflow/action/progress.rb | 2 -- lib/dynflow/action/rescue.rb | 1 - lib/dynflow/action/with_polling_sub_plans.rb | 1 - lib/dynflow/actor.rb | 1 - lib/dynflow/clock.rb | 1 - lib/dynflow/coordinator_adapters.rb | 2 -- lib/dynflow/delayed_executors.rb | 2 -- lib/dynflow/execution_plan/hooks.rb | 1 - lib/dynflow/execution_plan/steps.rb | 2 -- lib/dynflow/executors.rb | 1 - lib/dynflow/flows.rb | 2 -- lib/dynflow/flows/abstract.rb | 1 - lib/dynflow/persistence.rb | 1 - lib/dynflow/persistence_adapters/sequel.rb | 1 - lib/dynflow/serializers.rb | 2 -- lib/dynflow/testing/assertions.rb | 1 - lib/dynflow/testing/mimic.rb | 1 - lib/dynflow/transaction_adapters.rb | 2 -- lib/dynflow/utils.rb | 1 - lib/dynflow/web.rb | 1 - test/abnormal_states_recovery_test.rb | 1 - test/middleware_test.rb | 1 - test/semaphores_test.rb | 1 - test/support/code_workflow_example.rb | 2 -- test/support/rescue_example.rb | 2 -- test/test_helper.rb | 2 -- test/testing_test.rb | 1 - 35 files changed, 57 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1ae4f273b..9db081a29 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -36,13 +36,6 @@ Layout/EmptyLinesAroundExceptionHandlingKeywords: Exclude: - 'test/test_helper.rb' -# Offense count: 50 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines -Layout/EmptyLinesAroundModuleBody: - Enabled: false - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. diff --git a/doc/pages/plugins/plantuml.rb b/doc/pages/plugins/plantuml.rb index ff7989645..35ea941f1 100644 --- a/doc/pages/plugins/plantuml.rb +++ b/doc/pages/plugins/plantuml.rb @@ -14,7 +14,6 @@ require 'fileutils' module Jekyll - class PlantUMLBlock < Liquid::Block attr_reader :config diff --git a/doc/pages/plugins/play.rb b/doc/pages/plugins/play.rb index caf7fe03c..d4d33d53a 100644 --- a/doc/pages/plugins/play.rb +++ b/doc/pages/plugins/play.rb @@ -4,7 +4,6 @@ require 'pry' module Jekyll - class Play < Generator def generate(site) # pp site diff --git a/doc/pages/plugins/tags.rb b/doc/pages/plugins/tags.rb index bfd616014..ffabd42bf 100644 --- a/doc/pages/plugins/tags.rb +++ b/doc/pages/plugins/tags.rb @@ -4,7 +4,6 @@ require 'erb' module Jekyll - class Tagger < Generator safe true @@ -95,7 +94,6 @@ def read_yaml(*) end module Filters - def tag_cloud(site) active_tag_data.map { |tag, set| tag_link(tag, tag_url(tag), :class => "set-#{set} label label-default") @@ -131,5 +129,4 @@ def active_tag_data(site = Tagger.site) site.config["tag_data"].reject { |tag, set| site.config["ignored_tags"].include? tag } end end - end diff --git a/examples/orchestrate.rb b/examples/orchestrate.rb index 16ddb36e2..921d0d830 100755 --- a/examples/orchestrate.rb +++ b/examples/orchestrate.rb @@ -24,7 +24,6 @@ require_relative 'example_helper' module Orchestrate - class CreateInfrastructure < Dynflow::Action def plan sequence do diff --git a/examples/orchestrate_evented.rb b/examples/orchestrate_evented.rb index b1825c5da..9ec63f972 100755 --- a/examples/orchestrate_evented.rb +++ b/examples/orchestrate_evented.rb @@ -24,7 +24,6 @@ DESC module OrchestrateEvented - class CreateInfrastructure < Dynflow::Action def plan(get_stuck = false) sequence do @@ -152,7 +151,6 @@ def on_finish end end end - end if $0 == __FILE__ diff --git a/lib/dynflow/action/format.rb b/lib/dynflow/action/format.rb index 2419ff675..d0c2dbe6e 100644 --- a/lib/dynflow/action/format.rb +++ b/lib/dynflow/action/format.rb @@ -1,12 +1,10 @@ # frozen_string_literal: true module Dynflow - # Input/output format validation logic calling # input_format/output_format with block acts as a setter for # specifying the format. Without a block it acts as a getter module Action::Format - # we don't evaluate tbe block immediatelly, but postpone it till all the # action classes are loaded, because we can use them to reference output format def input_format(&block) @@ -42,7 +40,6 @@ def output_format(&block) end end end - end end diff --git a/lib/dynflow/action/polling.rb b/lib/dynflow/action/polling.rb index a4a4a9f83..5669e983f 100644 --- a/lib/dynflow/action/polling.rb +++ b/lib/dynflow/action/polling.rb @@ -4,7 +4,6 @@ module Dynflow module Action::Polling - def self.included(base) base.send :include, Action::Timeouts end @@ -117,6 +116,5 @@ def rescue_external_task(error) raise error end end - end end diff --git a/lib/dynflow/action/progress.rb b/lib/dynflow/action/progress.rb index b88739e02..9499eb3e1 100644 --- a/lib/dynflow/action/progress.rb +++ b/lib/dynflow/action/progress.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Dynflow - # Methods for specifying the progress of the action # the +*_progress+ methods should return number in 0..1. # The weight is there to increase/decrease the portion of this task @@ -11,7 +10,6 @@ module Dynflow # The +*_progress+ is run only when the action is in running/suspend state. Otherwise # the progress is 1 for success/skipped actions and 0 for errorneous ones. module Action::Progress - class Calculate < Middleware def run(*args) with_progress_calculation(*args) do diff --git a/lib/dynflow/action/rescue.rb b/lib/dynflow/action/rescue.rb index 069e1841a..18d58417b 100644 --- a/lib/dynflow/action/rescue.rb +++ b/lib/dynflow/action/rescue.rb @@ -2,7 +2,6 @@ module Dynflow module Action::Rescue - Strategy = Algebrick.type do variants Skip = atom, Pause = atom, Fail = atom end diff --git a/lib/dynflow/action/with_polling_sub_plans.rb b/lib/dynflow/action/with_polling_sub_plans.rb index b5b43e4ef..4950e7f60 100644 --- a/lib/dynflow/action/with_polling_sub_plans.rb +++ b/lib/dynflow/action/with_polling_sub_plans.rb @@ -2,7 +2,6 @@ module Dynflow module Action::WithPollingSubPlans - REFRESH_INTERVAL = 10 Poll = Algebrick.atom diff --git a/lib/dynflow/actor.rb b/lib/dynflow/actor.rb index 29fba6510..1702a52cc 100644 --- a/lib/dynflow/actor.rb +++ b/lib/dynflow/actor.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module Dynflow - FULL_BACKTRACE = %w[1 y yes].include?((ENV['DYNFLOW_FULL_BACKTRACE'] || '').downcase) BACKTRACE_LIMIT = begin limit = ENV['DYNFLOW_BACKTRACE_LIMIT'].to_i diff --git a/lib/dynflow/clock.rb b/lib/dynflow/clock.rb index c7df41e56..8a31e8643 100644 --- a/lib/dynflow/clock.rb +++ b/lib/dynflow/clock.rb @@ -125,5 +125,4 @@ def ping(who, time, with_what = nil, where = :<<, optional: false) end end end - end diff --git a/lib/dynflow/coordinator_adapters.rb b/lib/dynflow/coordinator_adapters.rb index 81b447ab0..6942d0271 100644 --- a/lib/dynflow/coordinator_adapters.rb +++ b/lib/dynflow/coordinator_adapters.rb @@ -2,9 +2,7 @@ module Dynflow module CoordinatorAdapters - require 'dynflow/coordinator_adapters/abstract' require 'dynflow/coordinator_adapters/sequel' - end end diff --git a/lib/dynflow/delayed_executors.rb b/lib/dynflow/delayed_executors.rb index deb127c5b..7d8a0f957 100644 --- a/lib/dynflow/delayed_executors.rb +++ b/lib/dynflow/delayed_executors.rb @@ -2,10 +2,8 @@ module Dynflow module DelayedExecutors - require 'dynflow/delayed_executors/abstract' require 'dynflow/delayed_executors/abstract_core' require 'dynflow/delayed_executors/polling' - end end diff --git a/lib/dynflow/execution_plan/hooks.rb b/lib/dynflow/execution_plan/hooks.rb index ce91ec01f..c2d9f5758 100644 --- a/lib/dynflow/execution_plan/hooks.rb +++ b/lib/dynflow/execution_plan/hooks.rb @@ -3,7 +3,6 @@ module Dynflow class ExecutionPlan module Hooks - HOOK_KINDS = (ExecutionPlan.states + [:success, :failure]).freeze # A register holding information about hook classes and events diff --git a/lib/dynflow/execution_plan/steps.rb b/lib/dynflow/execution_plan/steps.rb index 150c79ee1..935050b9d 100644 --- a/lib/dynflow/execution_plan/steps.rb +++ b/lib/dynflow/execution_plan/steps.rb @@ -2,13 +2,11 @@ module Dynflow module ExecutionPlan::Steps - require 'dynflow/execution_plan/steps/error' require 'dynflow/execution_plan/steps/abstract' require 'dynflow/execution_plan/steps/abstract_flow_step' require 'dynflow/execution_plan/steps/plan_step' require 'dynflow/execution_plan/steps/run_step' require 'dynflow/execution_plan/steps/finalize_step' - end end diff --git a/lib/dynflow/executors.rb b/lib/dynflow/executors.rb index 6353f2476..155b2a650 100644 --- a/lib/dynflow/executors.rb +++ b/lib/dynflow/executors.rb @@ -2,7 +2,6 @@ module Dynflow module Executors - require 'dynflow/executors/parallel' class << self diff --git a/lib/dynflow/flows.rb b/lib/dynflow/flows.rb index 98798ab1d..4d1c7748d 100644 --- a/lib/dynflow/flows.rb +++ b/lib/dynflow/flows.rb @@ -4,13 +4,11 @@ module Dynflow module Flows - require 'dynflow/flows/registry' require 'dynflow/flows/abstract' require 'dynflow/flows/atom' require 'dynflow/flows/abstract_composed' require 'dynflow/flows/concurrence' require 'dynflow/flows/sequence' - end end diff --git a/lib/dynflow/flows/abstract.rb b/lib/dynflow/flows/abstract.rb index d4d3bc588..06ae4048e 100644 --- a/lib/dynflow/flows/abstract.rb +++ b/lib/dynflow/flows/abstract.rb @@ -2,7 +2,6 @@ module Dynflow module Flows - class Abstract < Serializable include Algebrick::TypeCheck diff --git a/lib/dynflow/persistence.rb b/lib/dynflow/persistence.rb index c0112e792..dd3922420 100644 --- a/lib/dynflow/persistence.rb +++ b/lib/dynflow/persistence.rb @@ -3,7 +3,6 @@ require 'dynflow/persistence_adapters' module Dynflow - class Persistence include Algebrick::TypeCheck diff --git a/lib/dynflow/persistence_adapters/sequel.rb b/lib/dynflow/persistence_adapters/sequel.rb index d4615841d..9163b2c5a 100644 --- a/lib/dynflow/persistence_adapters/sequel.rb +++ b/lib/dynflow/persistence_adapters/sequel.rb @@ -8,7 +8,6 @@ # rubocop:disable Metrics/ClassLength module Dynflow module PersistenceAdapters - Sequel.extension :migration Sequel.database_timezone = :utc diff --git a/lib/dynflow/serializers.rb b/lib/dynflow/serializers.rb index ff19721b9..b85ac78b7 100644 --- a/lib/dynflow/serializers.rb +++ b/lib/dynflow/serializers.rb @@ -2,9 +2,7 @@ module Dynflow module Serializers - require 'dynflow/serializers/abstract' require 'dynflow/serializers/noop' - end end diff --git a/lib/dynflow/testing/assertions.rb b/lib/dynflow/testing/assertions.rb index 8b0e9bf8c..d7e530aec 100644 --- a/lib/dynflow/testing/assertions.rb +++ b/lib/dynflow/testing/assertions.rb @@ -75,7 +75,6 @@ def refute_finalize_phase(action) Match! action.state, :success _(action.execution_plan.planned_finalize_steps).wont_include action end - end end end diff --git a/lib/dynflow/testing/mimic.rb b/lib/dynflow/testing/mimic.rb index 83d41fc4d..8889ce2f4 100644 --- a/lib/dynflow/testing/mimic.rb +++ b/lib/dynflow/testing/mimic.rb @@ -2,7 +2,6 @@ module Dynflow module Testing - # when extended into Class or an_object it makes all instances of the class or the object # mimic the supplied types. It does so by hooking into kind_of? method. # @example diff --git a/lib/dynflow/transaction_adapters.rb b/lib/dynflow/transaction_adapters.rb index cb80ee4c1..d2ebb291e 100644 --- a/lib/dynflow/transaction_adapters.rb +++ b/lib/dynflow/transaction_adapters.rb @@ -2,10 +2,8 @@ module Dynflow module TransactionAdapters - require 'dynflow/transaction_adapters/abstract' require 'dynflow/transaction_adapters/none' require 'dynflow/transaction_adapters/active_record' - end end diff --git a/lib/dynflow/utils.rb b/lib/dynflow/utils.rb index e0144032f..51449667e 100644 --- a/lib/dynflow/utils.rb +++ b/lib/dynflow/utils.rb @@ -2,7 +2,6 @@ module Dynflow module Utils - require 'dynflow/utils/indifferent_hash' require 'dynflow/utils/priority_queue' diff --git a/lib/dynflow/web.rb b/lib/dynflow/web.rb index 1981970f6..2ca31e1fa 100644 --- a/lib/dynflow/web.rb +++ b/lib/dynflow/web.rb @@ -7,7 +7,6 @@ module Dynflow module Web - def self.setup(&block) console = Sinatra.new(Web::Console) { instance_exec(&block)} Rack::Builder.app do diff --git a/test/abnormal_states_recovery_test.rb b/test/abnormal_states_recovery_test.rb index 47f360050..af5f9dfae 100644 --- a/test/abnormal_states_recovery_test.rb +++ b/test/abnormal_states_recovery_test.rb @@ -6,7 +6,6 @@ module Dynflow module ConsistencyCheckTest - describe "consistency check" do include TestHelpers diff --git a/test/middleware_test.rb b/test/middleware_test.rb index 87f029873..a1723a56f 100644 --- a/test/middleware_test.rb +++ b/test/middleware_test.rb @@ -4,7 +4,6 @@ module Dynflow module MiddlewareTest - describe 'Middleware' do let(:world) { WorldFactory.create_world } let(:log) { Support::MiddlewareExample::LogMiddleware.log } diff --git a/test/semaphores_test.rb b/test/semaphores_test.rb index d34a9047c..52a3f672d 100644 --- a/test/semaphores_test.rb +++ b/test/semaphores_test.rb @@ -93,6 +93,5 @@ def assert_semaphore_state(semaphore, state_a, state_b) assert_semaphore_state semaphore, 0, 0 end end - end end diff --git a/test/support/code_workflow_example.rb b/test/support/code_workflow_example.rb index f79b087cb..3d8b46a0f 100644 --- a/test/support/code_workflow_example.rb +++ b/test/support/code_workflow_example.rb @@ -4,7 +4,6 @@ module Support module CodeWorkflowExample - class IncomingIssues < Dynflow::Action def plan(issues) issues.each do |issue| @@ -286,6 +285,5 @@ def run_progress external_task && external_task[:progress].to_f / 100 end end - end end diff --git a/test/support/rescue_example.rb b/test/support/rescue_example.rb index e0dd36d6d..0387ce045 100644 --- a/test/support/rescue_example.rb +++ b/test/support/rescue_example.rb @@ -4,7 +4,6 @@ module Support module RescueExample - class ComplexActionWithSkip < Dynflow::Action def plan(error_state) sequence do @@ -88,6 +87,5 @@ def plan(error_state) end end end - end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 34e719471..ae8b45e0b 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -78,7 +78,6 @@ def delete_record(record) end module WorldFactory - def self.created_worlds @created_worlds ||= [] end @@ -330,7 +329,6 @@ def finish end module PlanAssertions - def inspect_flow(execution_plan, flow) out = "".dup inspect_subflow(out, execution_plan, flow, "".dup) diff --git a/test/testing_test.rb b/test/testing_test.rb index 0379143df..111202002 100644 --- a/test/testing_test.rb +++ b/test/testing_test.rb @@ -3,7 +3,6 @@ require_relative 'test_helper' module Dynflow - CWE = Support::CodeWorkflowExample describe Testing do From 54e58096f4763849f714da0e3fae2d7c8950701e Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:48:17 +0100 Subject: [PATCH 21/44] Fix Layout/EndAlignment cop --- .rubocop_todo.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9db081a29..8e8a92092 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -36,14 +36,6 @@ Layout/EmptyLinesAroundExceptionHandlingKeywords: Exclude: - 'test/test_helper.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. -# SupportedStylesAlignWith: keyword, variable, start_of_line -Layout/EndAlignment: - Exclude: - - 'lib/dynflow/action/timeouts.rb' - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. From d34fed237fe0d9e64a299487541a9d98c6815c9a Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:48:56 +0100 Subject: [PATCH 22/44] Fix Layout/ExtraSpacing cop --- .rubocop_todo.yml | 8 -------- lib/dynflow/web.rb | 2 +- test/abnormal_states_recovery_test.rb | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8e8a92092..e2522bca5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -36,14 +36,6 @@ Layout/EmptyLinesAroundExceptionHandlingKeywords: Exclude: - 'test/test_helper.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Exclude: - - 'lib/dynflow/web.rb' - - 'test/abnormal_states_recovery_test.rb' - # Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. diff --git a/lib/dynflow/web.rb b/lib/dynflow/web.rb index 2ca31e1fa..a0de56a8a 100644 --- a/lib/dynflow/web.rb +++ b/lib/dynflow/web.rb @@ -10,7 +10,7 @@ module Web def self.setup(&block) console = Sinatra.new(Web::Console) { instance_exec(&block)} Rack::Builder.app do - run Rack::URLMap.new('/' => console) + run Rack::URLMap.new('/' => console) end end diff --git a/test/abnormal_states_recovery_test.rb b/test/abnormal_states_recovery_test.rb index af5f9dfae..1169c743d 100644 --- a/test/abnormal_states_recovery_test.rb +++ b/test/abnormal_states_recovery_test.rb @@ -301,7 +301,7 @@ def with_invalidation_while_executing(finish) _(client_world.coordinator.find_worlds(false, id: [invalid_world.id, invalid_world_2.id]).size).must_equal 2 results = client_world.worlds_validity_check(true, :id => invalid_world.id) - _(results).must_equal(invalid_world.id => :invalidated) + _(results).must_equal(invalid_world.id => :invalidated) _(client_world.coordinator.find_worlds(false, id: [invalid_world.id, invalid_world_2.id]).size).must_equal 1 end end From 509f2c6486c35f0219ddd501724812e7f9a2a67c Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:49:36 +0100 Subject: [PATCH 23/44] Fix Layout/EmptyLinesAroundExceptionHandlingKeywords cop --- .rubocop_todo.yml | 6 ------ test/test_helper.rb | 1 - 2 files changed, 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e2522bca5..6ef121275 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,12 +30,6 @@ Layout/DotPosition: - 'test/rescue_test.rb' - 'test/web_console_test.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundExceptionHandlingKeywords: - Exclude: - - 'test/test_helper.rb' - # Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. diff --git a/test/test_helper.rb b/test/test_helper.rb index ae8b45e0b..f1add071f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -14,7 +14,6 @@ require 'dynflow' require 'dynflow/testing' begin require 'pry'; rescue LoadError; nil end - require 'support/code_workflow_example' require 'support/middleware_example' require 'support/rescue_example' From 2ba63a82b4627ab3446dde7b3280062683958a8e Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:53:32 +0100 Subject: [PATCH 24/44] Fix Layout/DotPosition cop --- .rubocop_todo.yml | 16 ---------------- lib/dynflow/action.rb | 12 ++++++------ lib/dynflow/persistence.rb | 6 +++--- lib/dynflow/persistence_adapters/sequel.rb | 8 ++++---- lib/dynflow/rails.rb | 4 ++-- lib/dynflow/testing/assertions.rb | 8 ++++---- test/daemon_test.rb | 4 ++-- test/dispatcher_test.rb | 4 ++-- test/rescue_test.rb | 4 ++-- test/web_console_test.rb | 6 +++--- 10 files changed, 28 insertions(+), 44 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6ef121275..e93cc3d0c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -14,22 +14,6 @@ Layout/BlockAlignment: Exclude: - 'test/test_helper.rb' -# Offense count: 16 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: leading, trailing -Layout/DotPosition: - Exclude: - - 'lib/dynflow/action.rb' - - 'lib/dynflow/persistence.rb' - - 'lib/dynflow/persistence_adapters/sequel.rb' - - 'lib/dynflow/rails.rb' - - 'lib/dynflow/testing/assertions.rb' - - 'test/daemon_test.rb' - - 'test/dispatcher_test.rb' - - 'test/rescue_test.rb' - - 'test/web_console_test.rb' - # Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. diff --git a/lib/dynflow/action.rb b/lib/dynflow/action.rb index 716568c74..2812763e3 100644 --- a/lib/dynflow/action.rb +++ b/lib/dynflow/action.rb @@ -236,10 +236,10 @@ def plan_step # returned actions are in Present phase def planned_actions(filter = Action) phase! Present - plan_step. - planned_steps(execution_plan). - map { |s| s.action(execution_plan) }. - select { |a| a.is_a?(filter) } + plan_step + .planned_steps(execution_plan) + .map { |s| s.action(execution_plan) } + .select { |a| a.is_a?(filter) } end # @param [Class] filter_class return only actions which are kind of `filter_class` @@ -248,8 +248,8 @@ def planned_actions(filter = Action) def all_planned_actions(filter_class = Action) phase! Present mine = planned_actions - (mine + mine.reduce([]) { |arr, action| arr + action.all_planned_actions }). - select { |a| a.is_a?(filter_class) } + (mine + mine.reduce([]) { |arr, action| arr + action.all_planned_actions }) + .select { |a| a.is_a?(filter_class) } end def run_step diff --git a/lib/dynflow/persistence.rb b/lib/dynflow/persistence.rb index dd3922420..51d4bef97 100644 --- a/lib/dynflow/persistence.rb +++ b/lib/dynflow/persistence.rb @@ -17,9 +17,9 @@ def initialize(world, persistence_adapter, options = {}) end def load_action(step) - attributes = adapter. - load_action(step.execution_plan_id, step.action_id). - update(step: step, phase: step.phase) + attributes = adapter + .load_action(step.execution_plan_id, step.action_id) + .update(step: step, phase: step.phase) return Action.from_hash(attributes, step.world) end diff --git a/lib/dynflow/persistence_adapters/sequel.rb b/lib/dynflow/persistence_adapters/sequel.rb index 9163b2c5a..a1130a469 100644 --- a/lib/dynflow/persistence_adapters/sequel.rb +++ b/lib/dynflow/persistence_adapters/sequel.rb @@ -491,13 +491,13 @@ def filter(what, data_set, filters) end if filters.key?('caller_execution_plan_id') - data_set = data_set.join_table(:inner, TABLES[:action], :execution_plan_uuid => :uuid). - select_all(TABLES[:execution_plan]).distinct + data_set = data_set.join_table(:inner, TABLES[:action], :execution_plan_uuid => :uuid) + .select_all(TABLES[:execution_plan]).distinct end if filters.key?('delayed') filters.delete('delayed') - data_set = data_set.join_table(:inner, TABLES[:delayed], :execution_plan_uuid => :uuid). - select_all(TABLES[:execution_plan]).distinct + data_set = data_set.join_table(:inner, TABLES[:delayed], :execution_plan_uuid => :uuid) + .select_all(TABLES[:execution_plan]).distinct end end diff --git a/lib/dynflow/rails.rb b/lib/dynflow/rails.rb index c6e9b8e17..1b5b44eeb 100644 --- a/lib/dynflow/rails.rb +++ b/lib/dynflow/rails.rb @@ -33,8 +33,8 @@ def initialize! return @world if @world if config.lazy_initialization && defined?(::PhusionPassenger) - config.dynflow_logger. - warn('Dynflow: lazy loading with PhusionPassenger might lead to unexpected results') + config.dynflow_logger + .warn('Dynflow: lazy loading with PhusionPassenger might lead to unexpected results') end init_world.tap do |world| @world = world diff --git a/lib/dynflow/testing/assertions.rb b/lib/dynflow/testing/assertions.rb index d7e530aec..c50cf9eb9 100644 --- a/lib/dynflow/testing/assertions.rb +++ b/lib/dynflow/testing/assertions.rb @@ -25,8 +25,8 @@ def assert_action_planned_with(action, planned_action_class, *plan_input, &block def assert_action_planned(action, planned_action_class) Match! action.phase, Action::Plan Match! action.state, :success - found = action.execution_plan.planned_plan_steps. - select { |a| a.is_a?(planned_action_class) } + found = action.execution_plan.planned_plan_steps + .select { |a| a.is_a?(planned_action_class) } assert(!found.empty?, "Action #{planned_action_class} was not planned") found @@ -35,8 +35,8 @@ def assert_action_planned(action, planned_action_class) def refute_action_planned(action, planned_action_class) Match! action.phase, Action::Plan Match! action.state, :success - found = action.execution_plan.planned_plan_steps. - select { |a| a.is_a?(planned_action_class) } + found = action.execution_plan.planned_plan_steps + .select { |a| a.is_a?(planned_action_class) } assert(found.empty?, "Action #{planned_action_class} was planned") found diff --git a/test/daemon_test.rb b/test/daemon_test.rb index e265cdbef..a7f510775 100644 --- a/test/daemon_test.rb +++ b/test/daemon_test.rb @@ -35,8 +35,8 @@ class DaemonTest < ActiveSupport::TestCase @daemon.stubs(:sleep).returns(true) # don't pause the execution @current_folder = File.expand_path('../support/rails/', __FILE__) ::ActiveRecord::Base.configurations = { 'development' => {} } - ::Dynflow::Rails::Configuration.any_instance.stubs(:initialize_persistence). - returns(WorldFactory.persistence_adapter) + ::Dynflow::Rails::Configuration.any_instance.stubs(:initialize_persistence) + .returns(WorldFactory.persistence_adapter) end teardown do diff --git a/test/dispatcher_test.rb b/test/dispatcher_test.rb index a64c55113..7e579932c 100644 --- a/test/dispatcher_test.rb +++ b/test/dispatcher_test.rb @@ -27,8 +27,8 @@ def self.dispatcher_works_with_this_connector it 'succeeds when expected' do result = client_world.trigger(Support::DummyExample::DeprecatedEventedAction, :timeout => 3) step = wait_for do - client_world.persistence.load_execution_plan(result.id). - steps_in_state(:suspended).first + client_world.persistence.load_execution_plan(result.id) + .steps_in_state(:suspended).first end client_world.event(step.execution_plan_id, step.id, 'finish') plan = result.finished.value diff --git a/test/rescue_test.rb b/test/rescue_test.rb index 7c8caca7b..3e3388e48 100644 --- a/test/rescue_test.rb +++ b/test/rescue_test.rb @@ -120,8 +120,8 @@ def execute(*args) it 'skips the action and continues' do _(rescued_plan.state).must_equal :stopped _(rescued_plan.result).must_equal :warning - _(rescued_plan.entry_action.output[:message]). - must_equal "skipped because some error as you wish" + _(rescued_plan.entry_action.output[:message]) + .must_equal "skipped because some error as you wish" end end diff --git a/test/web_console_test.rb b/test/web_console_test.rb index 7ee8c5440..39a5e5426 100644 --- a/test/web_console_test.rb +++ b/test/web_console_test.rb @@ -13,9 +13,9 @@ module Dynflow let(:world) { WorldFactory.create_world } let :execution_plan_id do - world.trigger(Support::CodeWorkflowExample::FastCommit, 'sha' => 'abc123'). - tap { |o| o.finished.wait }. - id + world.trigger(Support::CodeWorkflowExample::FastCommit, 'sha' => 'abc123') + .tap { |o| o.finished.wait } + .id end let :app do From be0238fbcc7e4cf0a6319985fe57950123bdc3a2 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:54:00 +0100 Subject: [PATCH 25/44] Fix Layout/HeredocIndentation cop --- .rubocop_todo.yml | 7 ------- examples/memory_limit_watcher.rb | 16 ++++++++-------- examples/remote_executor.rb | 18 +++++++++--------- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e93cc3d0c..7bc0369f2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,13 +35,6 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 3 -# Cop supports --auto-correct. -Layout/HeredocIndentation: - Exclude: - - 'examples/memory_limit_watcher.rb' - - 'examples/remote_executor.rb' - # Offense count: 1 # Cop supports --auto-correct. Layout/LeadingEmptyLines: diff --git a/examples/memory_limit_watcher.rb b/examples/memory_limit_watcher.rb index 665cfb96f..917ebf89c 100644 --- a/examples/memory_limit_watcher.rb +++ b/examples/memory_limit_watcher.rb @@ -3,14 +3,14 @@ require_relative 'example_helper' -example_description = < Date: Mon, 29 Jan 2024 10:54:16 +0100 Subject: [PATCH 26/44] Fix Layout/LeadingEmptyLines cop --- .rubocop_todo.yml | 6 ------ lib/dynflow/web/console.rb | 1 - 2 files changed, 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7bc0369f2..2b59c86bf 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,12 +35,6 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -Layout/LeadingEmptyLines: - Exclude: - - 'lib/dynflow/web/console.rb' - # Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/dynflow/web/console.rb b/lib/dynflow/web/console.rb index ace896427..cd0639b4d 100644 --- a/lib/dynflow/web/console.rb +++ b/lib/dynflow/web/console.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true module Dynflow From fd41705357e6dc2e4e34a92ee3d225e0b85549ad Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:57:34 +0100 Subject: [PATCH 27/44] Fix Layout/MultilineMethodCallBraceLayout, Layout/MultilineMethodCallIndentation, Layout/ClosingParenthesisIndentation cops --- .rubocop_todo.yml | 28 --------------------- doc/pages/plugins/graphviz.rb | 8 +++--- lib/dynflow/action.rb | 11 ++++---- lib/dynflow/active_job/queue_adapter.rb | 2 +- lib/dynflow/persistence.rb | 4 +-- lib/dynflow/persistence_adapters/sequel.rb | 6 ++--- lib/dynflow/rails.rb | 2 +- lib/dynflow/testing/assertions.rb | 4 +-- lib/dynflow/testing/dummy_planned_action.rb | 3 ++- lib/dynflow/testing/factories.rb | 12 ++++++--- test/action_test.rb | 10 ++++---- test/daemon_test.rb | 2 +- test/dead_letter_silencer_test.rb | 2 +- test/dispatcher_test.rb | 2 +- test/execution_plan_test.rb | 6 ++--- test/web_console_test.rb | 4 +-- 16 files changed, 42 insertions(+), 64 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2b59c86bf..494c8a53b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,34 +35,6 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineMethodCallBraceLayout: - Exclude: - - 'lib/dynflow/action.rb' - - 'lib/dynflow/testing/dummy_planned_action.rb' - - 'lib/dynflow/testing/factories.rb' - -# Offense count: 28 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Layout/MultilineMethodCallIndentation: - Exclude: - - 'doc/pages/plugins/graphviz.rb' - - 'lib/dynflow/action.rb' - - 'lib/dynflow/active_job/queue_adapter.rb' - - 'lib/dynflow/persistence.rb' - - 'lib/dynflow/persistence_adapters/sequel.rb' - - 'lib/dynflow/testing/assertions.rb' - - 'test/action_test.rb' - - 'test/dead_letter_silencer_test.rb' - - 'test/dispatcher_test.rb' - - 'test/execution_plan_test.rb' - - 'test/web_console_test.rb' - # Offense count: 65 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. diff --git a/doc/pages/plugins/graphviz.rb b/doc/pages/plugins/graphviz.rb index 6a1ec2df1..d37d157d3 100644 --- a/doc/pages/plugins/graphviz.rb +++ b/doc/pages/plugins/graphviz.rb @@ -13,9 +13,9 @@ class GraphvizBlock < Liquid::Block DOT_EXTS = (ENV['PATHEXT'] || '.exe;.bat;.com').split(";") DOT_EXTS.unshift '' DOT_PATH = ENV['PATH'].split(File::PATH_SEPARATOR) - .map { |a| File.join a, DOT_EXEC } - .map { |a| DOT_EXTS.map { |ex| a+ex } }.flatten - .find { |c| File.executable_real? c } + .map { |a| File.join a, DOT_EXEC } + .map { |a| DOT_EXTS.map { |ex| a+ex } }.flatten + .find { |c| File.executable_real? c } raise "not found a executable file: #{DOT_EXEC}" if DOT_PATH.nil? DOT_CMD = "#{DOT_PATH} #{DOT_OPTS}" @@ -89,7 +89,7 @@ def remove_declarations(svg) def remove_xmlns_attrs(svg) svg.sub(%[xmlns="http://www.w3.org/2000/svg"], '') - .sub(%[xmlns:xlink="http://www.w3.org/1999/xlink"], '') + .sub(%[xmlns:xlink="http://www.w3.org/1999/xlink"], '') end def add_desc_attrs(svg) diff --git a/lib/dynflow/action.rb b/lib/dynflow/action.rb index 2812763e3..06caec6f0 100644 --- a/lib/dynflow/action.rb +++ b/lib/dynflow/action.rb @@ -237,9 +237,9 @@ def plan_step def planned_actions(filter = Action) phase! Present plan_step - .planned_steps(execution_plan) - .map { |s| s.action(execution_plan) } - .select { |a| a.is_a?(filter) } + .planned_steps(execution_plan) + .map { |s| s.action(execution_plan) } + .select { |a| a.is_a?(filter) } end # @param [Class] filter_class return only actions which are kind of `filter_class` @@ -249,7 +249,7 @@ def all_planned_actions(filter_class = Action) phase! Present mine = planned_actions (mine + mine.reduce([]) { |arr, action| arr + action.all_planned_actions }) - .select { |a| a.is_a?(filter_class) } + .select { |a| a.is_a?(filter_class) } end def run_step @@ -279,7 +279,8 @@ def to_hash input: input }, if phase? Run, Finalize, Present { output: output } - end) + end + ) end def state diff --git a/lib/dynflow/active_job/queue_adapter.rb b/lib/dynflow/active_job/queue_adapter.rb index bb2f877b4..59c69e400 100644 --- a/lib/dynflow/active_job/queue_adapter.rb +++ b/lib/dynflow/active_job/queue_adapter.rb @@ -14,7 +14,7 @@ def enqueue(job) def enqueue_at(job, timestamp) job.provider_job_id = job.job_id ::Rails.application.dynflow.world - .delay_with_options(id: job.provider_job_id, + .delay_with_options(id: job.provider_job_id, action_class: JobWrapper, delay_options: { :start_at => Time.at(timestamp) }, args: [job.serialize]) diff --git a/lib/dynflow/persistence.rb b/lib/dynflow/persistence.rb index 51d4bef97..7facce490 100644 --- a/lib/dynflow/persistence.rb +++ b/lib/dynflow/persistence.rb @@ -18,8 +18,8 @@ def initialize(world, persistence_adapter, options = {}) def load_action(step) attributes = adapter - .load_action(step.execution_plan_id, step.action_id) - .update(step: step, phase: step.phase) + .load_action(step.execution_plan_id, step.action_id) + .update(step: step, phase: step.phase) return Action.from_hash(attributes, step.world) end diff --git a/lib/dynflow/persistence_adapters/sequel.rb b/lib/dynflow/persistence_adapters/sequel.rb index a1130a469..6bab26ab3 100644 --- a/lib/dynflow/persistence_adapters/sequel.rb +++ b/lib/dynflow/persistence_adapters/sequel.rb @@ -80,7 +80,7 @@ def find_execution_plan_counts(options = {}) def find_execution_plan_statuses(options) plans = filter(:execution_plan, table(:execution_plan), options[:filters]) - .select(:uuid, :state, :result) + .select(:uuid, :state, :result) plans.each_with_object({}) do |current, acc| uuid = current.delete(:uuid) @@ -492,12 +492,12 @@ def filter(what, data_set, filters) if filters.key?('caller_execution_plan_id') data_set = data_set.join_table(:inner, TABLES[:action], :execution_plan_uuid => :uuid) - .select_all(TABLES[:execution_plan]).distinct + .select_all(TABLES[:execution_plan]).distinct end if filters.key?('delayed') filters.delete('delayed') data_set = data_set.join_table(:inner, TABLES[:delayed], :execution_plan_uuid => :uuid) - .select_all(TABLES[:execution_plan]).distinct + .select_all(TABLES[:execution_plan]).distinct end end diff --git a/lib/dynflow/rails.rb b/lib/dynflow/rails.rb index 1b5b44eeb..c24424ad9 100644 --- a/lib/dynflow/rails.rb +++ b/lib/dynflow/rails.rb @@ -34,7 +34,7 @@ def initialize! if config.lazy_initialization && defined?(::PhusionPassenger) config.dynflow_logger - .warn('Dynflow: lazy loading with PhusionPassenger might lead to unexpected results') + .warn('Dynflow: lazy loading with PhusionPassenger might lead to unexpected results') end init_world.tap do |world| @world = world diff --git a/lib/dynflow/testing/assertions.rb b/lib/dynflow/testing/assertions.rb index c50cf9eb9..12a906a71 100644 --- a/lib/dynflow/testing/assertions.rb +++ b/lib/dynflow/testing/assertions.rb @@ -26,7 +26,7 @@ def assert_action_planned(action, planned_action_class) Match! action.phase, Action::Plan Match! action.state, :success found = action.execution_plan.planned_plan_steps - .select { |a| a.is_a?(planned_action_class) } + .select { |a| a.is_a?(planned_action_class) } assert(!found.empty?, "Action #{planned_action_class} was not planned") found @@ -36,7 +36,7 @@ def refute_action_planned(action, planned_action_class) Match! action.phase, Action::Plan Match! action.state, :success found = action.execution_plan.planned_plan_steps - .select { |a| a.is_a?(planned_action_class) } + .select { |a| a.is_a?(planned_action_class) } assert(found.empty?, "Action #{planned_action_class} was planned") found diff --git a/lib/dynflow/testing/dummy_planned_action.rb b/lib/dynflow/testing/dummy_planned_action.rb index b9e65c5e4..12ae55e9d 100644 --- a/lib/dynflow/testing/dummy_planned_action.rb +++ b/lib/dynflow/testing/dummy_planned_action.rb @@ -9,7 +9,8 @@ class DummyPlannedAction def initialize(klass) mimic! klass @output = ExecutionPlan::OutputReference.new( - Testing.get_id.to_s, Testing.get_id, Testing.get_id) + Testing.get_id.to_s, Testing.get_id, Testing.get_id + ) end def execute(execution_plan, event, from_subscription, *args) diff --git a/lib/dynflow/testing/factories.rb b/lib/dynflow/testing/factories.rb index 49b376d7d..b484fed2c 100644 --- a/lib/dynflow/testing/factories.rb +++ b/lib/dynflow/testing/factories.rb @@ -17,7 +17,8 @@ def create_action(action_class, trigger = nil) plan_step_id: step.id, run_step_id: nil, finalize_step_id: nil }, - execution_plan.world).tap do |action| + execution_plan.world + ).tap do |action| action.set_plan_context(execution_plan, trigger, false) end end @@ -33,7 +34,8 @@ def create_action_presentation(action_class) run_step_id: nil, finalize_step_id: nil, input: nil }, - execution_plan.world) + execution_plan.world + ) end # @return [Action::PlanPhase] @@ -67,7 +69,8 @@ def run_action(plan_action, event = nil, &stubbing) finalize_step_id: nil, phase: Action::Run, input: plan_action.input }, - plan_action.world) + plan_action.world + ) else plan_action @@ -94,7 +97,8 @@ def finalize_action(run_action, &stubbing) finalize_step_id: step.id, phase: Action::Finalize, input: run_action.input }, - run_action.world) + run_action.world + ) stubbing.call finalize_action if stubbing finalize_action.execute diff --git a/test/action_test.rb b/test/action_test.rb index 55f9d3588..b77572b51 100644 --- a/test/action_test.rb +++ b/test/action_test.rb @@ -781,7 +781,7 @@ def run plan = world.plan(SingletonAction) _(plan.state).must_equal :planned lock_filter = ::Dynflow::Coordinator::SingletonActionLock - .unique_filter plan.entry_action.class.name + .unique_filter plan.entry_action.class.name _(world.coordinator.find_locks(lock_filter).count).must_equal 1 plan = world.execute(plan.id).wait!.value _(plan.state).must_equal :stopped @@ -793,7 +793,7 @@ def run plan = world.plan(SingletonActionWithFinalize) _(plan.state).must_equal :planned lock_filter = ::Dynflow::Coordinator::SingletonActionLock - .unique_filter plan.entry_action.class.name + .unique_filter plan.entry_action.class.name _(world.coordinator.find_locks(lock_filter).count).must_equal 1 plan = world.execute(plan.id).wait!.value _(plan.state).must_equal :stopped @@ -805,7 +805,7 @@ def run plan = world.plan(SuspendedSingletonAction) _(plan.state).must_equal :planned lock_filter = ::Dynflow::Coordinator::SingletonActionLock - .unique_filter plan.entry_action.class.name + .unique_filter plan.entry_action.class.name _(world.coordinator.find_locks(lock_filter).count).must_equal 1 future = world.execute(plan.id) wait_for do @@ -851,7 +851,7 @@ def run # The lock was released when plan3 stopped lock_filter = ::Dynflow::Coordinator::SingletonActionLock - .unique_filter plan3.entry_action.class.name + .unique_filter plan3.entry_action.class.name _(world.coordinator.find_locks(lock_filter)).must_be :empty? end @@ -860,7 +860,7 @@ def run plan1 = world.plan(BadAction, true) _(plan1.state).must_equal :planned lock_filter = ::Dynflow::Coordinator::SingletonActionLock - .unique_filter plan1.entry_action.class.name + .unique_filter plan1.entry_action.class.name _(world.coordinator.find_locks(lock_filter).count).must_equal 0 plan2 = world.plan(BadAction, false) _(plan2.state).must_equal :planned diff --git a/test/daemon_test.rb b/test/daemon_test.rb index a7f510775..70981d4e2 100644 --- a/test/daemon_test.rb +++ b/test/daemon_test.rb @@ -36,7 +36,7 @@ class DaemonTest < ActiveSupport::TestCase @current_folder = File.expand_path('../support/rails/', __FILE__) ::ActiveRecord::Base.configurations = { 'development' => {} } ::Dynflow::Rails::Configuration.any_instance.stubs(:initialize_persistence) - .returns(WorldFactory.persistence_adapter) + .returns(WorldFactory.persistence_adapter) end teardown do diff --git a/test/dead_letter_silencer_test.rb b/test/dead_letter_silencer_test.rb index af86d9a16..dbf3fa395 100644 --- a/test/dead_letter_silencer_test.rb +++ b/test/dead_letter_silencer_test.rb @@ -13,7 +13,7 @@ module DeadLetterSilencerTest it 'is started for each world' do _(world.dead_letter_handler.actor_class) - .must_equal ::Dynflow::DeadLetterSilencer + .must_equal ::Dynflow::DeadLetterSilencer end describe ::Dynflow::DeadLetterSilencer::Matcher do diff --git a/test/dispatcher_test.rb b/test/dispatcher_test.rb index 7e579932c..ce5c6060f 100644 --- a/test/dispatcher_test.rb +++ b/test/dispatcher_test.rb @@ -28,7 +28,7 @@ def self.dispatcher_works_with_this_connector result = client_world.trigger(Support::DummyExample::DeprecatedEventedAction, :timeout => 3) step = wait_for do client_world.persistence.load_execution_plan(result.id) - .steps_in_state(:suspended).first + .steps_in_state(:suspended).first end client_world.event(step.execution_plan_id, step.id, 'finish') plan = result.finished.value diff --git a/test/execution_plan_test.rb b/test/execution_plan_test.rb index c513b8454..e776baf5e 100644 --- a/test/execution_plan_test.rb +++ b/test/execution_plan_test.rb @@ -44,7 +44,7 @@ module ExecutionPlanTest it 'handles issues with loading the data' do world.persistence.adapter.send(:table, :step) - .where(execution_plan_uuid: execution_plan.id).delete + .where(execution_plan_uuid: execution_plan.id).delete refute deserialized_execution_plan.valid? assert_equal Dynflow::Errors::DataConsistencyError, deserialized_execution_plan.exception.class [:label, :state, :started_at, :ended_at].each do |attr| @@ -360,7 +360,7 @@ def run plan = world.plan(SingletonAction) _(plan.state).must_equal :planned lock_filter = ::Dynflow::Coordinator::SingletonActionLock - .unique_filter plan.entry_action.class.name + .unique_filter plan.entry_action.class.name _(world.coordinator.find_locks(lock_filter).count).must_equal 1 plan = world.execute(plan.id).wait!.value _(plan.state).must_equal :stopped @@ -372,7 +372,7 @@ def run plan = world.plan(SingletonAction, :fail => true) _(plan.state).must_equal :planned lock_filter = ::Dynflow::Coordinator::SingletonActionLock - .unique_filter plan.entry_action.class.name + .unique_filter plan.entry_action.class.name _(world.coordinator.find_locks(lock_filter).count).must_equal 1 plan = world.execute(plan.id).wait!.value _(plan.state).must_equal :paused diff --git a/test/web_console_test.rb b/test/web_console_test.rb index 39a5e5426..0a363e979 100644 --- a/test/web_console_test.rb +++ b/test/web_console_test.rb @@ -14,8 +14,8 @@ module Dynflow let :execution_plan_id do world.trigger(Support::CodeWorkflowExample::FastCommit, 'sha' => 'abc123') - .tap { |o| o.finished.wait } - .id + .tap { |o| o.finished.wait } + .id end let :app do From 37dabb1080815139050b0c90f8b091fddac122c2 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:58:02 +0100 Subject: [PATCH 28/44] Fix Layout/SpaceAroundOperators cop --- .rubocop_todo.yml | 7 ------ doc/pages/plugins/graphviz.rb | 2 +- doc/pages/plugins/plantuml.rb | 2 +- examples/example_helper.rb | 6 ++--- lib/dynflow/action.rb | 6 ++--- lib/dynflow/action/polling.rb | 2 +- lib/dynflow/clock.rb | 2 +- lib/dynflow/director/queue_hash.rb | 2 +- lib/dynflow/execution_plan.rb | 6 ++--- lib/dynflow/execution_plan/steps/abstract.rb | 4 +-- lib/dynflow/round_robin.rb | 2 +- lib/dynflow/testing/mimic.rb | 2 +- lib/dynflow/web/console_helpers.rb | 2 +- lib/dynflow/world.rb | 2 +- test/action_test.rb | 4 +-- test/persistence_test.rb | 26 ++++++++++---------- test/support/dummy_example.rb | 2 +- test/testing_test.rb | 2 +- test/world_test.rb | 4 +-- 19 files changed, 39 insertions(+), 46 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 494c8a53b..e55f1ea8d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,13 +35,6 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 65 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. -# SupportedStylesForExponentOperator: space, no_space -Layout/SpaceAroundOperators: - Enabled: false - # Offense count: 1 # Cop supports --auto-correct. Layout/SpaceBeforeComma: diff --git a/doc/pages/plugins/graphviz.rb b/doc/pages/plugins/graphviz.rb index d37d157d3..7ac3effb2 100644 --- a/doc/pages/plugins/graphviz.rb +++ b/doc/pages/plugins/graphviz.rb @@ -14,7 +14,7 @@ class GraphvizBlock < Liquid::Block DOT_EXTS.unshift '' DOT_PATH = ENV['PATH'].split(File::PATH_SEPARATOR) .map { |a| File.join a, DOT_EXEC } - .map { |a| DOT_EXTS.map { |ex| a+ex } }.flatten + .map { |a| DOT_EXTS.map { |ex| a + ex } }.flatten .find { |c| File.executable_real? c } raise "not found a executable file: #{DOT_EXEC}" if DOT_PATH.nil? DOT_CMD = "#{DOT_PATH} #{DOT_OPTS}" diff --git a/doc/pages/plugins/plantuml.rb b/doc/pages/plugins/plantuml.rb index 35ea941f1..60ba0dc98 100644 --- a/doc/pages/plugins/plantuml.rb +++ b/doc/pages/plugins/plantuml.rb @@ -31,7 +31,7 @@ def render(context) if !File.exist?(filepath) plantuml_jar = File.expand_path(plantuml_jar_path) cmd = "java -Djava.awt.headless=true -jar " + plantuml_jar + dot_cmd + " -pipe > " + filepath - result, status = Open3.capture2e(cmd, :stdin_data=>code) + result, status = Open3.capture2e(cmd, :stdin_data => code) Jekyll.logger.debug(filepath + " -->\t" + status.inspect() + "\t" + result) end diff --git a/examples/example_helper.rb b/examples/example_helper.rb index 58b350dcd..9317a7d3e 100644 --- a/examples/example_helper.rb +++ b/examples/example_helper.rb @@ -5,9 +5,9 @@ require 'dynflow' class ExampleHelper - CONSOLE_URL='http://localhost:4567' - DYNFLOW_URL="#{CONSOLE_URL}/dynflow" - SIDEKIQ_URL="#{CONSOLE_URL}/sidekiq" + CONSOLE_URL = 'http://localhost:4567' + DYNFLOW_URL = "#{CONSOLE_URL}/dynflow" + SIDEKIQ_URL = "#{CONSOLE_URL}/sidekiq" class << self def world diff --git a/lib/dynflow/action.rb b/lib/dynflow/action.rb index 06caec6f0..d752bf0d6 100644 --- a/lib/dynflow/action.rb +++ b/lib/dynflow/action.rb @@ -124,12 +124,12 @@ def initialize(attributes, world) @run_step_id = Type! attributes.fetch(:run_step_id), Integer, NilClass @finalize_step_id = Type! attributes.fetch(:finalize_step_id), Integer, NilClass - @execution_plan = Type!(attributes.fetch(:execution_plan), ExecutionPlan) if phase? Present + @execution_plan = Type!(attributes.fetch(:execution_plan), ExecutionPlan) if phase? Present @caller_execution_plan_id = Type!(attributes.fetch(:caller_execution_plan_id, nil), String, NilClass) @caller_action_id = Type!(attributes.fetch(:caller_action_id, nil), Integer, NilClass) - getter =-> key, required do + getter = -> key, required do required ? attributes.fetch(key) : attributes.fetch(key, {}) end @@ -308,7 +308,7 @@ def execute(*args) # @return [Array] - ids of steps referenced from action def required_step_ids(input = self.input) results = [] - recursion =-> value do + recursion = -> value do case value when Hash value.values.each { |v| recursion.(v) } diff --git a/lib/dynflow/action/polling.rb b/lib/dynflow/action/polling.rb index 5669e983f..6fca7b8d8 100644 --- a/lib/dynflow/action/polling.rb +++ b/lib/dynflow/action/polling.rb @@ -71,7 +71,7 @@ def attempts_before_next_interval # Returns the time to wait between two polling intervals. def poll_interval - interval_level = poll_attempts[:total]/attempts_before_next_interval + interval_level = poll_attempts[:total] / attempts_before_next_interval poll_intervals[interval_level] || poll_intervals.last end diff --git a/lib/dynflow/clock.rb b/lib/dynflow/clock.rb index 8a31e8643..0974df978 100644 --- a/lib/dynflow/clock.rb +++ b/lib/dynflow/clock.rb @@ -116,7 +116,7 @@ def current_time def ping(who, time, with_what = nil, where = :<<, optional: false) Type! time, Time, Numeric - time = current_time + time if time.is_a? Numeric + time = current_time + time if time.is_a? Numeric if who.is_a?(Action::Suspended) who.plan_event(with_what, time, optional: optional) else diff --git a/lib/dynflow/director/queue_hash.rb b/lib/dynflow/director/queue_hash.rb index 6665d4fc8..2844e0b42 100644 --- a/lib/dynflow/director/queue_hash.rb +++ b/lib/dynflow/director/queue_hash.rb @@ -8,7 +8,7 @@ class QueueHash def initialize(key_type = Object, value_type = Object) @key_type = key_type @value_type = value_type - @stash = Hash.new { |hash, key| hash[key] = [] } + @stash = Hash.new { |hash, key| hash[key] = [] } end def push(key, value) diff --git a/lib/dynflow/execution_plan.rb b/lib/dynflow/execution_plan.rb index 662a1679b..453b59ca8 100644 --- a/lib/dynflow/execution_plan.rb +++ b/lib/dynflow/execution_plan.rb @@ -83,9 +83,9 @@ def initialize(world, real_time = 0.0, execution_history = ExecutionHistory.new) id ||= SecureRandom.uuid - @id = Type! id, String - @world = Type! world, World - @label = Type! label, String, NilClass + @id = Type! id, String + @world = Type! world, World + @label = Type! label, String, NilClass self.state = state @run_flow = Type! run_flow, Flows::Abstract @finalize_flow = Type! finalize_flow, Flows::Abstract diff --git a/lib/dynflow/execution_plan/steps/abstract.rb b/lib/dynflow/execution_plan/steps/abstract.rb index 3cad75715..7bb962b5e 100644 --- a/lib/dynflow/execution_plan/steps/abstract.rb +++ b/lib/dynflow/execution_plan/steps/abstract.rb @@ -38,7 +38,7 @@ def initialize(execution_plan_id, @progress_done = Type! progress_done, Numeric, NilClass @progress_weight = Type! progress_weight, Numeric, NilClass - @queue = Type! queue, Symbol, NilClass + @queue = Type! queue, Symbol, NilClass self.state = state.to_sym @@ -163,7 +163,7 @@ def self.new_from_hash(hash, execution_plan_id, world) private def with_meta_calculation(action, &block) - start = Time.now.utc + start = Time.now.utc @started_at ||= start block.call ensure diff --git a/lib/dynflow/round_robin.rb b/lib/dynflow/round_robin.rb index 97008129b..12bf031d1 100644 --- a/lib/dynflow/round_robin.rb +++ b/lib/dynflow/round_robin.rb @@ -20,7 +20,7 @@ def delete(item) end def next - @cursor = 0 if @cursor > @data.size-1 + @cursor = 0 if @cursor > @data.size - 1 @data[@cursor] ensure @cursor += 1 diff --git a/lib/dynflow/testing/mimic.rb b/lib/dynflow/testing/mimic.rb index 8889ce2f4..0bf7449c2 100644 --- a/lib/dynflow/testing/mimic.rb +++ b/lib/dynflow/testing/mimic.rb @@ -18,7 +18,7 @@ def ===(v) end def mimic!(*types) - define =-> _ do + define = -> _ do define_method :mimic_types do types end diff --git a/lib/dynflow/web/console_helpers.rb b/lib/dynflow/web/console_helpers.rb index 7c2648280..91d4e1464 100644 --- a/lib/dynflow/web/console_helpers.rb +++ b/lib/dynflow/web/console_helpers.rb @@ -180,7 +180,7 @@ def filter_checkbox(field, values) checked = field_filter && field_filter.include?(value) %{#{value}} end.join(' ') - out %= checkboxes + out %= checkboxes return out end end diff --git a/lib/dynflow/world.rb b/lib/dynflow/world.rb index b5903f43a..6694980ff 100644 --- a/lib/dynflow/world.rb +++ b/lib/dynflow/world.rb @@ -87,7 +87,7 @@ def before_termination(&block) end def update_register - @meta ||= @config.meta + @meta ||= @config.meta @meta['queues'] = @config.queues if @executor @meta['delayed_executor'] = true if @delayed_executor @meta['execution_plan_cleaner'] = true if @execution_plan_cleaner diff --git a/test/action_test.rb b/test/action_test.rb index b77572b51..203dbadb0 100644 --- a/test/action_test.rb +++ b/test/action_test.rb @@ -498,7 +498,7 @@ def batch(from, size) end specify "it saves the information about number for sub plans in the output" do - _(execution_plan.entry_action.output).must_equal('total_count' => 2, + _(execution_plan.entry_action.output).must_equal('total_count' => 2, 'failed_count' => 0, 'success_count' => 2, 'pending_count' => 0) @@ -506,7 +506,7 @@ def batch(from, size) specify "when a sub plan fails, the caller action fails as well" do FailureSimulator.fail_in_child_run = true - _(execution_plan.entry_action.output).must_equal('total_count' => 2, + _(execution_plan.entry_action.output).must_equal('total_count' => 2, 'failed_count' => 2, 'success_count' => 0, 'pending_count' => 0) diff --git a/test/persistence_test.rb b/test/persistence_test.rb index 791d3497d..747723dfc 100644 --- a/test/persistence_test.rb +++ b/test/persistence_test.rb @@ -172,26 +172,26 @@ def self.it_acts_as_persistence_adapter _(loaded_plans).must_equal({ 'plan1' => { state: 'paused', result: nil} }) loaded_plans = adapter.find_execution_plan_statuses(filters: { state: ['paused'] }) - _(loaded_plans).must_equal({"plan1"=>{:state=>"paused", :result=>nil}, - "plan3"=>{:state=>"paused", :result=>nil}, - "plan4"=>{:state=>"paused", :result=>nil}}) + _(loaded_plans).must_equal({"plan1" => {:state => "paused", :result => nil}, + "plan3" => {:state => "paused", :result => nil}, + "plan4" => {:state => "paused", :result => nil}}) loaded_plans = adapter.find_execution_plan_statuses(filters: { state: ['stopped'] }) - _(loaded_plans).must_equal({"plan2"=>{:state=>"stopped", :result=>nil}}) + _(loaded_plans).must_equal({"plan2" => {:state => "stopped", :result => nil}}) loaded_plans = adapter.find_execution_plan_statuses(filters: { state: [] }) _(loaded_plans).must_equal({}) loaded_plans = adapter.find_execution_plan_statuses(filters: { state: ['stopped', 'paused'] }) - _(loaded_plans).must_equal({"plan1"=>{:state=>"paused", :result=>nil}, - "plan2"=>{:state=>"stopped", :result=>nil}, - "plan3"=>{:state=>"paused", :result=>nil}, "plan4"=>{:state=>"paused", :result=>nil}}) + _(loaded_plans).must_equal({"plan1" => {:state => "paused", :result => nil}, + "plan2" => {:state => "stopped", :result => nil}, + "plan3" => {:state => "paused", :result => nil}, "plan4" => {:state => "paused", :result => nil}}) loaded_plans = adapter.find_execution_plan_statuses(filters: { 'state' => ['stopped', 'paused'] }) - _(loaded_plans).must_equal({"plan1"=>{:state=>"paused", :result=>nil}, - "plan2"=>{:state=>"stopped", :result=>nil}, - "plan3"=>{:state=>"paused", :result=>nil}, - "plan4"=>{:state=>"paused", :result=>nil}}) + _(loaded_plans).must_equal({"plan1" => {:state => "paused", :result => nil}, + "plan2" => {:state => "stopped", :result => nil}, + "plan3" => {:state => "paused", :result => nil}, + "plan4" => {:state => "paused", :result => nil}}) loaded_plans = adapter.find_execution_plan_statuses(filters: { label: ['test1'], :delayed => true }) _(loaded_plans).must_equal({}) @@ -283,7 +283,7 @@ def self.it_acts_as_persistence_adapter actions = CSV.read(backup_dir + "/actions.csv", :headers => true) assert_equal 1, actions.count assert_equal 'plan1', actions.first.to_hash['execution_plan_uuid'] - steps = CSV.read(backup_dir +"/steps.csv", :headers => true) + steps = CSV.read(backup_dir + "/steps.csv", :headers => true) assert_equal 1, steps.count assert_equal 'plan1', steps.first.to_hash['execution_plan_uuid'] end @@ -451,7 +451,7 @@ def self.it_acts_as_persistence_adapter envelopes = [client_envelope, executor_envelope] envelopes.each { |e| adapter.push_envelope(e) } - adapter.insert_coordinator_record({"class"=>"Dynflow::Coordinator::ExecutorWorld", + adapter.insert_coordinator_record({"class" => "Dynflow::Coordinator::ExecutorWorld", "id" => executor_world_id, "meta" => {}, "active" => true }) assert_equal 1, adapter.prune_undeliverable_envelopes diff --git a/test/support/dummy_example.rb b/test/support/dummy_example.rb index 19ea38af4..94c3a9a71 100644 --- a/test/support/dummy_example.rb +++ b/test/support/dummy_example.rb @@ -45,7 +45,7 @@ def run sleep input[:interval] action_logger.debug 'done with sleeping' $slow_actions_done ||= 0 - $slow_actions_done +=1 + $slow_actions_done += 1 end def queue diff --git a/test/testing_test.rb b/test/testing_test.rb index 111202002..daaeaaa8a 100644 --- a/test/testing_test.rb +++ b/test/testing_test.rb @@ -63,7 +63,7 @@ module Dynflow 3.times { progress_action_time action } _(action.output).must_equal('task' => { 'progress' => 30, 'done' => false } , - 'poll_attempts' => {'total' => 2, 'failed'=> 0 }) + 'poll_attempts' => {'total' => 2, 'failed' => 0 }) _(action.run_progress).must_equal 0.3 run_action action, Dynflow::Action::Polling::Poll diff --git a/test/world_test.rb b/test/world_test.rb index a64bcde9f..818432b53 100644 --- a/test/world_test.rb +++ b/test/world_test.rb @@ -27,7 +27,7 @@ module WorldTest describe '#get_execution_status' do let(:base) do { :default => { :pool_size => 5, :free_workers => 5, :queue_size => 0 }, - :slow => { :pool_size=> 1, :free_workers=> 1, :queue_size => 0} } + :slow => { :pool_size => 1, :free_workers => 1, :queue_size => 0} } end it 'retrieves correct execution items count' do @@ -35,7 +35,7 @@ module WorldTest id = 'something like uuid' expected = base.dup expected[:default][:queue_size] = 0 - expected[:slow][:queue_size] = 0 + expected[:slow][:queue_size] = 0 _(world.get_execution_status(world.id, id, 5).value!).must_equal(expected) end end From f6938679f2bd7eaef86024d1bcb7bb49fa5918f9 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:58:21 +0100 Subject: [PATCH 29/44] Fix Layout/SpaceBeforeComma cop --- .rubocop_todo.yml | 6 ------ test/testing_test.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e55f1ea8d..94c9ae183 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,12 +35,6 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -Layout/SpaceBeforeComma: - Exclude: - - 'test/testing_test.rb' - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/test/testing_test.rb b/test/testing_test.rb index daaeaaa8a..0f662cb64 100644 --- a/test/testing_test.rb +++ b/test/testing_test.rb @@ -62,7 +62,7 @@ module Dynflow _(action.run_progress).must_equal 0 3.times { progress_action_time action } - _(action.output).must_equal('task' => { 'progress' => 30, 'done' => false } , + _(action.output).must_equal('task' => { 'progress' => 30, 'done' => false }, 'poll_attempts' => {'total' => 2, 'failed' => 0 }) _(action.run_progress).must_equal 0.3 From ecc04eea1314dc65ed45eb4d9118813a154c7a27 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:58:57 +0100 Subject: [PATCH 30/44] Fix Layout/SpaceInLambdaLiteral cop --- .rubocop_todo.yml | 10 ---------- lib/dynflow/action.rb | 4 ++-- lib/dynflow/clock.rb | 2 +- lib/dynflow/testing/mimic.rb | 2 +- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 94c9ae183..4932ff4f0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,16 +35,6 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: require_no_space, require_space -Layout/SpaceInLambdaLiteral: - Exclude: - - 'lib/dynflow/action.rb' - - 'lib/dynflow/clock.rb' - - 'lib/dynflow/testing/mimic.rb' - # Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. diff --git a/lib/dynflow/action.rb b/lib/dynflow/action.rb index d752bf0d6..0ff5eb2bc 100644 --- a/lib/dynflow/action.rb +++ b/lib/dynflow/action.rb @@ -129,7 +129,7 @@ def initialize(attributes, world) @caller_execution_plan_id = Type!(attributes.fetch(:caller_execution_plan_id, nil), String, NilClass) @caller_action_id = Type!(attributes.fetch(:caller_action_id, nil), Integer, NilClass) - getter = -> key, required do + getter = ->key, required do required ? attributes.fetch(key) : attributes.fetch(key, {}) end @@ -308,7 +308,7 @@ def execute(*args) # @return [Array] - ids of steps referenced from action def required_step_ids(input = self.input) results = [] - recursion = -> value do + recursion = ->value do case value when Hash value.values.each { |v| recursion.(v) } diff --git a/lib/dynflow/clock.rb b/lib/dynflow/clock.rb index 0974df978..3655769cd 100644 --- a/lib/dynflow/clock.rb +++ b/lib/dynflow/clock.rb @@ -13,7 +13,7 @@ class Clock < Actor module Timer def self.[](*fields) - super(*fields).tap { |v| Match! v.who, -> who { who.respond_to? v.where } } + super(*fields).tap { |v| Match! v.who, ->who { who.respond_to? v.where } } end include Comparable diff --git a/lib/dynflow/testing/mimic.rb b/lib/dynflow/testing/mimic.rb index 0bf7449c2..4952ae78c 100644 --- a/lib/dynflow/testing/mimic.rb +++ b/lib/dynflow/testing/mimic.rb @@ -18,7 +18,7 @@ def ===(v) end def mimic!(*types) - define = -> _ do + define = ->_ do define_method :mimic_types do types end From 8faa2cb85c343e1f24308d1080160cc143c2be82 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:59:16 +0100 Subject: [PATCH 31/44] Fix Layout/SpaceInsideBlockBraces cop --- .rubocop_todo.yml | 14 -------------- lib/dynflow/actor.rb | 2 +- lib/dynflow/dispatcher/executor_dispatcher.rb | 2 +- lib/dynflow/execution_plan.rb | 2 +- lib/dynflow/middleware/resolver.rb | 2 +- lib/dynflow/telemetry_adapters/statsd.rb | 2 +- lib/dynflow/web.rb | 2 +- 7 files changed, 6 insertions(+), 20 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4932ff4f0..c1d1d4e50 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,20 +35,6 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideBlockBraces: - Exclude: - - 'lib/dynflow/actor.rb' - - 'lib/dynflow/dispatcher/executor_dispatcher.rb' - - 'lib/dynflow/execution_plan.rb' - - 'lib/dynflow/middleware/resolver.rb' - - 'lib/dynflow/telemetry_adapters/statsd.rb' - - 'lib/dynflow/web.rb' - # Offense count: 63 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. diff --git a/lib/dynflow/actor.rb b/lib/dynflow/actor.rb index 1702a52cc..84305865d 100644 --- a/lib/dynflow/actor.rb +++ b/lib/dynflow/actor.rb @@ -94,7 +94,7 @@ def filter_line(line) # takes an array of backtrace lines and replaces each chunk def filter_backtrace(backtrace) trace = backtrace.map { |line| filter_line(line) } - .chunk_while { |l1, l2| l1 == l2} + .chunk_while { |l1, l2| l1 == l2 } .map(&:first) if BACKTRACE_LIMIT count = trace.count diff --git a/lib/dynflow/dispatcher/executor_dispatcher.rb b/lib/dynflow/dispatcher/executor_dispatcher.rb index 6c37cac4d..9de385473 100644 --- a/lib/dynflow/dispatcher/executor_dispatcher.rb +++ b/lib/dynflow/dispatcher/executor_dispatcher.rb @@ -10,7 +10,7 @@ def initialize(world, semaphore) def handle_request(envelope) match(envelope.message, - on(Planning) { perform_planning(envelope, envelope.message)}, + on(Planning) { perform_planning(envelope, envelope.message) }, on(Execution) { perform_execution(envelope, envelope.message) }, on(Event) { perform_event(envelope, envelope.message) }, on(Status) { get_execution_status(envelope, envelope.message) }) diff --git a/lib/dynflow/execution_plan.rb b/lib/dynflow/execution_plan.rb index 453b59ca8..971ff3fc9 100644 --- a/lib/dynflow/execution_plan.rb +++ b/lib/dynflow/execution_plan.rb @@ -238,7 +238,7 @@ def failed_steps end def steps_in_state(*states) - self.steps.values.find_all {|step| states.include?(step.state) } + self.steps.values.find_all { |step| states.include?(step.state) } end def generate_action_id diff --git a/lib/dynflow/middleware/resolver.rb b/lib/dynflow/middleware/resolver.rb index c2830476a..f7649b203 100644 --- a/lib/dynflow/middleware/resolver.rb +++ b/lib/dynflow/middleware/resolver.rb @@ -49,7 +49,7 @@ def normalize_rules(rules) middleware_deps.reject! { |dep| !deps.has_key?(dep) } end - return deps.delete_if {|klass, _| klass.nil? } + return deps.delete_if { |klass, _| klass.nil? } end def tsort_each_node(&block) diff --git a/lib/dynflow/telemetry_adapters/statsd.rb b/lib/dynflow/telemetry_adapters/statsd.rb index a779d3c19..f74404e1f 100644 --- a/lib/dynflow/telemetry_adapters/statsd.rb +++ b/lib/dynflow/telemetry_adapters/statsd.rb @@ -43,7 +43,7 @@ def observe_histogram(name, value, tags) def name_tag_mapping(name, tags) instances = @instances[name] return name if instances.nil? || instances.empty? - (name.to_s + '.' + instances.map {|x| tags[x]}.compact.join('.')).tr('-:/ ', '____') + (name.to_s + '.' + instances.map { |x| tags[x] }.compact.join('.')).tr('-:/ ', '____') end end end diff --git a/lib/dynflow/web.rb b/lib/dynflow/web.rb index a0de56a8a..3e473bc60 100644 --- a/lib/dynflow/web.rb +++ b/lib/dynflow/web.rb @@ -8,7 +8,7 @@ module Dynflow module Web def self.setup(&block) - console = Sinatra.new(Web::Console) { instance_exec(&block)} + console = Sinatra.new(Web::Console) { instance_exec(&block) } Rack::Builder.app do run Rack::URLMap.new('/' => console) end From b54424c729c255645a7c049c8a34286f569dc6ec Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 10:59:44 +0100 Subject: [PATCH 32/44] Fix Layout/SpaceInsideHashLiteralBraces cop --- .rubocop_todo.yml | 16 --------- lib/dynflow/config.rb | 2 +- lib/dynflow/executors/parallel.rb | 2 +- lib/dynflow/persistence_adapters/sequel.rb | 2 +- .../021_create_output_chunks.rb | 4 +-- test/flows_test.rb | 2 +- test/persistence_test.rb | 36 +++++++++---------- test/testing_test.rb | 8 ++--- test/world_test.rb | 4 +-- 9 files changed, 30 insertions(+), 46 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c1d1d4e50..70e531eba 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,22 +35,6 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 63 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - Exclude: - - 'lib/dynflow/config.rb' - - 'lib/dynflow/executors/parallel.rb' - - 'lib/dynflow/persistence_adapters/sequel.rb' - - 'lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb' - - 'test/flows_test.rb' - - 'test/persistence_test.rb' - - 'test/testing_test.rb' - - 'test/world_test.rb' - # Offense count: 8 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/dynflow/config.rb b/lib/dynflow/config.rb index 82afd6413..bc467109d 100644 --- a/lib/dynflow/config.rb +++ b/lib/dynflow/config.rb @@ -52,7 +52,7 @@ class QueuesConfig attr_reader :queues def initialize - @queues = {:default => {}} + @queues = { :default => {} } end # Add a new queue to the configuration diff --git a/lib/dynflow/executors/parallel.rb b/lib/dynflow/executors/parallel.rb index 2f4744079..c9c26fd4a 100644 --- a/lib/dynflow/executors/parallel.rb +++ b/lib/dynflow/executors/parallel.rb @@ -13,7 +13,7 @@ class Parallel def initialize(world, executor_class:, heartbeat_interval:, - queues_options: { :default => { :pool_size => 5 }}) + queues_options: { :default => { :pool_size => 5 } }) @world = world @logger = world.logger @core = executor_class.spawn name: 'parallel-executor-core', diff --git a/lib/dynflow/persistence_adapters/sequel.rb b/lib/dynflow/persistence_adapters/sequel.rb index 6bab26ab3..38339d7ad 100644 --- a/lib/dynflow/persistence_adapters/sequel.rb +++ b/lib/dynflow/persistence_adapters/sequel.rb @@ -254,7 +254,7 @@ def insert_coordinator_record(value) def update_coordinator_record(class_name, record_id, value) coordinator_feature! - save :coordinator_record, {class: class_name, :id => record_id}, value + save :coordinator_record, { class: class_name, :id => record_id }, value end def delete_coordinator_record(class_name, record_id) diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb b/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb index 8c93722c5..14a114141 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb @@ -7,9 +7,9 @@ primary_key :id column_properties = if type.to_s.include?('postgres') - {type: :uuid} + { type: :uuid } else - {type: String, size: 36, fixed: true, null: false} + { type: String, size: 36, fixed: true, null: false } end foreign_key :execution_plan_uuid, :dynflow_execution_plans, **column_properties index :execution_plan_uuid diff --git a/test/flows_test.rb b/test/flows_test.rb index 30b78856e..0df16f019 100644 --- a/test/flows_test.rb +++ b/test/flows_test.rb @@ -22,7 +22,7 @@ def reset! TestRegistry.register!(TestRegistry, 'TS') TestRegistry.register!(Integer, 'I') map = TestRegistry.instance_variable_get("@serialization_map") - _(map).must_equal({'TS' => TestRegistry, 'I' => Integer}) + _(map).must_equal({ 'TS' => TestRegistry, 'I' => Integer }) end it "prevents overwriting values" do diff --git a/test/persistence_test.rb b/test/persistence_test.rb index 747723dfc..aa0e87ecc 100644 --- a/test/persistence_test.rb +++ b/test/persistence_test.rb @@ -20,8 +20,8 @@ module PersistenceTest caller_execution_plan_id: nil, caller_action_id: nil, class: 'Dynflow::Action', - input: {key: 'value'}, - output: {something: 'else'}, + input: { key: 'value' }, + output: { something: 'else' }, plan_step_id: 1, run_step_id: 2, finalize_step_id: 3 @@ -169,29 +169,29 @@ def self.it_acts_as_persistence_adapter prepare_and_save_plans if adapter.ordering_by.include?('state') loaded_plans = adapter.find_execution_plan_statuses(filters: { label: ['test1'] }) - _(loaded_plans).must_equal({ 'plan1' => { state: 'paused', result: nil} }) + _(loaded_plans).must_equal({ 'plan1' => { state: 'paused', result: nil } }) loaded_plans = adapter.find_execution_plan_statuses(filters: { state: ['paused'] }) - _(loaded_plans).must_equal({"plan1" => {:state => "paused", :result => nil}, - "plan3" => {:state => "paused", :result => nil}, - "plan4" => {:state => "paused", :result => nil}}) + _(loaded_plans).must_equal({ "plan1" => { :state => "paused", :result => nil }, + "plan3" => { :state => "paused", :result => nil }, + "plan4" => { :state => "paused", :result => nil } }) loaded_plans = adapter.find_execution_plan_statuses(filters: { state: ['stopped'] }) - _(loaded_plans).must_equal({"plan2" => {:state => "stopped", :result => nil}}) + _(loaded_plans).must_equal({ "plan2" => { :state => "stopped", :result => nil } }) loaded_plans = adapter.find_execution_plan_statuses(filters: { state: [] }) _(loaded_plans).must_equal({}) loaded_plans = adapter.find_execution_plan_statuses(filters: { state: ['stopped', 'paused'] }) - _(loaded_plans).must_equal({"plan1" => {:state => "paused", :result => nil}, - "plan2" => {:state => "stopped", :result => nil}, - "plan3" => {:state => "paused", :result => nil}, "plan4" => {:state => "paused", :result => nil}}) + _(loaded_plans).must_equal({ "plan1" => { :state => "paused", :result => nil }, + "plan2" => { :state => "stopped", :result => nil }, + "plan3" => { :state => "paused", :result => nil }, "plan4" => { :state => "paused", :result => nil } }) loaded_plans = adapter.find_execution_plan_statuses(filters: { 'state' => ['stopped', 'paused'] }) - _(loaded_plans).must_equal({"plan1" => {:state => "paused", :result => nil}, - "plan2" => {:state => "stopped", :result => nil}, - "plan3" => {:state => "paused", :result => nil}, - "plan4" => {:state => "paused", :result => nil}}) + _(loaded_plans).must_equal({ "plan1" => { :state => "paused", :result => nil }, + "plan2" => { :state => "stopped", :result => nil }, + "plan3" => { :state => "paused", :result => nil }, + "plan4" => { :state => "paused", :result => nil } }) loaded_plans = adapter.find_execution_plan_statuses(filters: { label: ['test1'], :delayed => true }) _(loaded_plans).must_equal({}) @@ -276,7 +276,7 @@ def self.it_acts_as_persistence_adapter it 'creates backup dir and produce backup including steps and actions' do prepare_plans_with_steps Dir.mktmpdir do |backup_dir| - _(adapter.delete_execution_plans({'uuid' => 'plan1'}, 100, backup_dir)).must_equal 1 + _(adapter.delete_execution_plans({ 'uuid' => 'plan1' }, 100, backup_dir)).must_equal 1 plans = CSV.read(backup_dir + "/execution_plans.csv", :headers => true) assert_equal 1, plans.count assert_equal 'plan1', plans.first.to_hash['uuid'] @@ -376,7 +376,7 @@ def self.it_acts_as_persistence_adapter it 'deletes output chunks' do prepare_plans_with_actions - adapter.save_output_chunks('plan1', 1, [{chunk: "Hello", timestamp: Time.now}, {chunk: "Bye", timestamp: Time.now}]) + adapter.save_output_chunks('plan1', 1, [{ chunk: "Hello", timestamp: Time.now }, { chunk: "Bye", timestamp: Time.now }]) chunks = adapter.load_output_chunks('plan1', 1) _(chunks.length).must_equal 2 deleted = adapter.delete_output_chunks('plan1', 1) @@ -451,7 +451,7 @@ def self.it_acts_as_persistence_adapter envelopes = [client_envelope, executor_envelope] envelopes.each { |e| adapter.push_envelope(e) } - adapter.insert_coordinator_record({"class" => "Dynflow::Coordinator::ExecutorWorld", + adapter.insert_coordinator_record({ "class" => "Dynflow::Coordinator::ExecutorWorld", "id" => executor_world_id, "meta" => {}, "active" => true }) assert_equal 1, adapter.prune_undeliverable_envelopes @@ -526,7 +526,7 @@ def self.it_acts_as_persistence_adapter value = 'a' * 1000 - adata = action_data.merge({:output => { :key => value }}) + adata = action_data.merge({ :output => { :key => value } }) plan_record = adapter.send(:prepare_record, :execution_plan, plan.merge(:uuid => plan[:id])) action_record = adapter.send(:prepare_record, :action, adata.dup) diff --git a/test/testing_test.rb b/test/testing_test.rb index 0f662cb64..e3b17aa7f 100644 --- a/test/testing_test.rb +++ b/test/testing_test.rb @@ -63,19 +63,19 @@ module Dynflow 3.times { progress_action_time action } _(action.output).must_equal('task' => { 'progress' => 30, 'done' => false }, - 'poll_attempts' => {'total' => 2, 'failed' => 0 }) + 'poll_attempts' => { 'total' => 2, 'failed' => 0 }) _(action.run_progress).must_equal 0.3 run_action action, Dynflow::Action::Polling::Poll run_action action, Dynflow::Action::Polling::Poll _(action.output).must_equal('task' => { 'progress' => 50, 'done' => false }, - 'poll_attempts' => {'total' => 4, 'failed' => 0 }) + 'poll_attempts' => { 'total' => 4, 'failed' => 0 }) _(action.run_progress).must_equal 0.5 5.times { progress_action_time action } _(action.output).must_equal('task' => { 'progress' => 100, 'done' => true }, - 'poll_attempts' => {'total' => 9, 'failed' => 0 }) + 'poll_attempts' => { 'total' => 9, 'failed' => 0 }) _(action.run_progress).must_equal 1 end @@ -123,7 +123,7 @@ module Dynflow it 'plans' do _(planned_action.input).must_equal Utils.stringify_keys(input) - assert_run_phase planned_action, { commit: "sha", reviewer: "name", result: true} + assert_run_phase planned_action, { commit: "sha", reviewer: "name", result: true } refute_finalize_phase planned_action _(planned_action.execution_plan.planned_plan_steps).must_be_empty diff --git a/test/world_test.rb b/test/world_test.rb index 818432b53..e87135ad8 100644 --- a/test/world_test.rb +++ b/test/world_test.rb @@ -15,7 +15,7 @@ module WorldTest registered_world.meta.delete('last_seen') _(registered_world.meta).must_equal('hostname' => Socket.gethostname, 'pid' => Process.pid, 'queues' => { 'default' => { 'pool_size' => 5 }, - 'slow' => { 'pool_size' => 1 }}) + 'slow' => { 'pool_size' => 1 } }) end it 'is configurable' do @@ -27,7 +27,7 @@ module WorldTest describe '#get_execution_status' do let(:base) do { :default => { :pool_size => 5, :free_workers => 5, :queue_size => 0 }, - :slow => { :pool_size => 1, :free_workers => 1, :queue_size => 0} } + :slow => { :pool_size => 1, :free_workers => 1, :queue_size => 0 } } end it 'retrieves correct execution items count' do From 859542fe71323e3b0cc4af71ebf1b59a3ac8d442 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 11:00:02 +0100 Subject: [PATCH 33/44] Fix Layout/SpaceInsideParens cop --- .rubocop_todo.yml | 12 ------------ lib/dynflow/persistence_adapters/sequel.rb | 2 +- lib/dynflow/serializer.rb | 2 +- lib/dynflow/utils/indifferent_hash.rb | 2 +- test/abnormal_states_recovery_test.rb | 4 ++-- test/executor_test.rb | 2 +- 6 files changed, 6 insertions(+), 18 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 70e531eba..62e6f2373 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,18 +35,6 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 8 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceInsideParens: - Exclude: - - 'lib/dynflow/persistence_adapters/sequel.rb' - - 'lib/dynflow/serializer.rb' - - 'lib/dynflow/utils/indifferent_hash.rb' - - 'test/abnormal_states_recovery_test.rb' - - 'test/executor_test.rb' - # Offense count: 16 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/dynflow/persistence_adapters/sequel.rb b/lib/dynflow/persistence_adapters/sequel.rb index 38339d7ad..db91b2942 100644 --- a/lib/dynflow/persistence_adapters/sequel.rb +++ b/lib/dynflow/persistence_adapters/sequel.rb @@ -365,7 +365,7 @@ def save(what, condition, value, with_data: true, update_conditions: {}) def load_record(what, condition) table = table(what) - if (record = with_retry { table.first(Utils.symbolize_keys(condition)) } ) + if (record = with_retry { table.first(Utils.symbolize_keys(condition)) }) load_data(record, what) else raise KeyError, "searching: #{what} by: #{condition.inspect}" diff --git a/lib/dynflow/serializer.rb b/lib/dynflow/serializer.rb index 8d4cd1999..b243a2429 100644 --- a/lib/dynflow/serializer.rb +++ b/lib/dynflow/serializer.rb @@ -38,7 +38,7 @@ def parse_other(other, options = {}) end if (type_name = other[ARBITRARY_TYPE_KEY] || other[ARBITRARY_TYPE_KEY.to_s]) - if type_name == 'Time' && ( time_str = other['value'] ) + if type_name == 'Time' && (time_str = other['value']) return Serializable.send(:string_to_time, time_str) end type = Utils.constantize(type_name) rescue nil diff --git a/lib/dynflow/utils/indifferent_hash.rb b/lib/dynflow/utils/indifferent_hash.rb index 622c3468f..647f8f933 100644 --- a/lib/dynflow/utils/indifferent_hash.rb +++ b/lib/dynflow/utils/indifferent_hash.rb @@ -85,7 +85,7 @@ def reverse_merge(other_hash) end def reverse_merge!(other_hash) - replace(reverse_merge( other_hash )) + replace(reverse_merge(other_hash)) end def replace(other_hash) diff --git a/test/abnormal_states_recovery_test.rb b/test/abnormal_states_recovery_test.rb index 1169c743d..b80050805 100644 --- a/test/abnormal_states_recovery_test.rb +++ b/test/abnormal_states_recovery_test.rb @@ -270,10 +270,10 @@ def with_invalidation_while_executing(finish) end it 'by default, the auto_validity_check is enabled only for executor words' do - client_world_config = Config::ForWorld.new(Config.new.tap { |c| c.executor = false }, create_world ) + client_world_config = Config::ForWorld.new(Config.new.tap { |c| c.executor = false }, create_world) _(client_world_config.auto_validity_check).must_equal false - executor_world_config = Config::ForWorld.new(Config.new.tap { |c| c.executor = Executors::Parallel::Core }, create_world ) + executor_world_config = Config::ForWorld.new(Config.new.tap { |c| c.executor = Executors::Parallel::Core }, create_world) _(executor_world_config.auto_validity_check).must_equal true end diff --git a/test/executor_test.rb b/test/executor_test.rb index df0add462..8a9f8fba2 100644 --- a/test/executor_test.rb +++ b/test/executor_test.rb @@ -665,7 +665,7 @@ def assert_next_steps(expected_next_step_ids, finished_step_id = nil, success = it 'waits for currently running actions' do $slow_actions_done = 0 running = world.trigger(Support::DummyExample::Slow, 1) - suspended = world.trigger(Support::DummyExample::DeprecatedEventedAction, :timeout => 3 ) + suspended = world.trigger(Support::DummyExample::DeprecatedEventedAction, :timeout => 3) sleep 0.2 world.terminate.wait _($slow_actions_done).must_equal 1 From 4ed43681dc3a200c302ad9979e8d6278b7a4c707 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 11:00:24 +0100 Subject: [PATCH 34/44] Fix Layout/SpaceInsideStringInterpolation cop --- .rubocop_todo.yml | 13 ------------- lib/dynflow/config.rb | 6 +++--- lib/dynflow/connectors/database.rb | 2 +- lib/dynflow/connectors/direct.rb | 2 +- lib/dynflow/execution_history.rb | 2 +- lib/dynflow/web/console_helpers.rb | 2 +- test/test_helper.rb | 2 +- 7 files changed, 8 insertions(+), 21 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 62e6f2373..e1c1ccc15 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,19 +35,6 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 16 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceInsideStringInterpolation: - Exclude: - - 'lib/dynflow/config.rb' - - 'lib/dynflow/connectors/database.rb' - - 'lib/dynflow/connectors/direct.rb' - - 'lib/dynflow/execution_history.rb' - - 'lib/dynflow/web/console_helpers.rb' - - 'test/test_helper.rb' - # Offense count: 8 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/dynflow/config.rb b/lib/dynflow/config.rb index bc467109d..38a5280f1 100644 --- a/lib/dynflow/config.rb +++ b/lib/dynflow/config.rb @@ -7,11 +7,11 @@ class Config include Algebrick::TypeCheck def self.config_attr(name, *types, &default) - self.send(:define_method, "validate_#{ name }!") do |value| + self.send(:define_method, "validate_#{name}!") do |value| Type! value, *types unless types.empty? end self.send(:define_method, name) do - var_name = "@#{ name }" + var_name = "@#{name}" if instance_variable_defined?(var_name) return instance_variable_get(var_name) else @@ -42,7 +42,7 @@ def method_missing(name) return @cache[name] if @cache.key?(name) value = @config.send(name) value = value.call(@world, self) if value.is_a? Proc - validation_method = "validate_#{ name }!" + validation_method = "validate_#{name}!" @config.send(validation_method, value) if @config.respond_to?(validation_method) @cache[name] = value end diff --git a/lib/dynflow/connectors/database.rb b/lib/dynflow/connectors/database.rb index 128b0478a..5d7cca9a3 100644 --- a/lib/dynflow/connectors/database.rb +++ b/lib/dynflow/connectors/database.rb @@ -22,7 +22,7 @@ def started? def start @started.set true @thread = Thread.new do - @db.listen("world:#{ @world_id }", :loop => true) do + @db.listen("world:#{@world_id}", :loop => true) do if started? @core << :check_inbox else diff --git a/lib/dynflow/connectors/direct.rb b/lib/dynflow/connectors/direct.rb index 88268ec10..503b39ba0 100644 --- a/lib/dynflow/connectors/direct.rb +++ b/lib/dynflow/connectors/direct.rb @@ -29,7 +29,7 @@ def handle_envelope(envelope) if world = find_receiver(envelope) @connector.receive(world, envelope) else - log(Logger::ERROR, "Receiver for envelope #{ envelope } not found") + log(Logger::ERROR, "Receiver for envelope #{envelope} not found") end end diff --git a/lib/dynflow/execution_history.rb b/lib/dynflow/execution_history.rb index d5a1c1711..25bedab8c 100644 --- a/lib/dynflow/execution_history.rb +++ b/lib/dynflow/execution_history.rb @@ -36,7 +36,7 @@ def to_hash end def inspect - "ExecutionHistory: #{ @events.inspect }" + "ExecutionHistory: #{@events.inspect}" end def self.new_from_hash(value) diff --git a/lib/dynflow/web/console_helpers.rb b/lib/dynflow/web/console_helpers.rb index 91d4e1464..413d395d4 100644 --- a/lib/dynflow/web/console_helpers.rb +++ b/lib/dynflow/web/console_helpers.rb @@ -178,7 +178,7 @@ def filter_checkbox(field, values) checkboxes = values.map do |value| field_filter = filtering_options[:filters][field] checked = field_filter && field_filter.include?(value) - %{#{value}} + %{#{value}} end.join(' ') out %= checkboxes return out diff --git a/test/test_helper.rb b/test/test_helper.rb index f1add071f..5cd8e5990 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -127,7 +127,7 @@ def self.coordinator_adapter def self.clean_coordinator_records persistence_adapter = WorldFactory.persistence_adapter persistence_adapter.find_coordinator_records({}).each do |w| - warn "Unexpected coordinator record: #{ w }" + warn "Unexpected coordinator record: #{w}" persistence_adapter.delete_coordinator_record(w[:class], w[:id]) end end From d08abec706cb720c087b14fe4e21910d0cf22514 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 11:00:43 +0100 Subject: [PATCH 35/44] Fix Layout/TrailingEmptyLines cop --- .rubocop_todo.yml | 15 --------------- lib/dynflow/action/format.rb | 1 - lib/dynflow/action/progress.rb | 1 - lib/dynflow/action/rescue.rb | 1 - .../sequel_migrations/004_coordinator_records.rb | 1 - .../009_fix_mysql_data_length.rb | 1 - lib/dynflow/round_robin.rb | 1 - test/abnormal_states_recovery_test.rb | 1 - test/activejob_adapter_test.rb | 1 - 9 files changed, 23 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e1c1ccc15..3e9eb9073 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,21 +35,6 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 8 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: final_newline, final_blank_line -Layout/TrailingEmptyLines: - Exclude: - - 'lib/dynflow/action/format.rb' - - 'lib/dynflow/action/progress.rb' - - 'lib/dynflow/action/rescue.rb' - - 'lib/dynflow/persistence_adapters/sequel_migrations/004_coordinator_records.rb' - - 'lib/dynflow/persistence_adapters/sequel_migrations/009_fix_mysql_data_length.rb' - - 'lib/dynflow/round_robin.rb' - - 'test/abnormal_states_recovery_test.rb' - - 'test/activejob_adapter_test.rb' - # Offense count: 2 Lint/AmbiguousBlockAssociation: Exclude: diff --git a/lib/dynflow/action/format.rb b/lib/dynflow/action/format.rb index d0c2dbe6e..bc9369982 100644 --- a/lib/dynflow/action/format.rb +++ b/lib/dynflow/action/format.rb @@ -42,4 +42,3 @@ def output_format(&block) end end end - diff --git a/lib/dynflow/action/progress.rb b/lib/dynflow/action/progress.rb index 9499eb3e1..c73ec772c 100644 --- a/lib/dynflow/action/progress.rb +++ b/lib/dynflow/action/progress.rb @@ -59,4 +59,3 @@ def finalize_progress_weight attr_accessor :calculated_progress end end - diff --git a/lib/dynflow/action/rescue.rb b/lib/dynflow/action/rescue.rb index 18d58417b..8b6c5bc22 100644 --- a/lib/dynflow/action/rescue.rb +++ b/lib/dynflow/action/rescue.rb @@ -65,4 +65,3 @@ def combine_suggested_strategies(suggested_strategies) end end end - diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/004_coordinator_records.rb b/lib/dynflow/persistence_adapters/sequel_migrations/004_coordinator_records.rb index 3cc9d94f5..3dd4e2dbe 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/004_coordinator_records.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/004_coordinator_records.rb @@ -13,4 +13,3 @@ end end end - diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/009_fix_mysql_data_length.rb b/lib/dynflow/persistence_adapters/sequel_migrations/009_fix_mysql_data_length.rb index f1d405cf8..df49e691a 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/009_fix_mysql_data_length.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/009_fix_mysql_data_length.rb @@ -23,4 +23,3 @@ end end end - diff --git a/lib/dynflow/round_robin.rb b/lib/dynflow/round_robin.rb index 12bf031d1..b6e3cb505 100644 --- a/lib/dynflow/round_robin.rb +++ b/lib/dynflow/round_robin.rb @@ -36,4 +36,3 @@ def empty? attr_writer :data end end - diff --git a/test/abnormal_states_recovery_test.rb b/test/abnormal_states_recovery_test.rb index b80050805..689cc5d59 100644 --- a/test/abnormal_states_recovery_test.rb +++ b/test/abnormal_states_recovery_test.rb @@ -379,4 +379,3 @@ def plan_in_state(state) end end end - diff --git a/test/activejob_adapter_test.rb b/test/activejob_adapter_test.rb index c469fb1e3..bda839037 100644 --- a/test/activejob_adapter_test.rb +++ b/test/activejob_adapter_test.rb @@ -72,4 +72,3 @@ def perform(msg) end end end - From 85a9677cd8369f8d0ad278f6f05818ad8d637279 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 11:01:55 +0100 Subject: [PATCH 36/44] Fix Lint/AmbiguousBlockAssociation cop --- .rubocop_todo.yml | 5 ----- lib/dynflow/director/running_steps_manager.rb | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3e9eb9073..f5869da83 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,11 +35,6 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 2 -Lint/AmbiguousBlockAssociation: - Exclude: - - 'lib/dynflow/director/running_steps_manager.rb' - # Offense count: 9 # Cop supports --auto-correct. Lint/AmbiguousOperator: diff --git a/lib/dynflow/director/running_steps_manager.rb b/lib/dynflow/director/running_steps_manager.rb index 736d307de..11639678a 100644 --- a/lib/dynflow/director/running_steps_manager.rb +++ b/lib/dynflow/director/running_steps_manager.rb @@ -51,13 +51,13 @@ def done(step) while (work = @work_items.shift(step.id)) @world.logger.debug "step #{step.execution_plan_id}:#{step.id} dropping event #{work.request_id}/#{work.event}" finish_event_result(work) do |f| - f.reject UnprocessableEvent.new("Message dropped").tap { |e| e.set_backtrace(caller) } + f.reject(UnprocessableEvent.new("Message dropped").tap { |e| e.set_backtrace(caller) }) end end while (event = @events.shift(step.id)) @world.logger.debug "step #{step.execution_plan_id}:#{step.id} dropping event #{event.request_id}/#{event}" if event.result - event.result.reject UnprocessableEvent.new("Message dropped").tap { |e| e.set_backtrace(caller) } + event.result.reject(UnprocessableEvent.new("Message dropped").tap { |e| e.set_backtrace(caller) }) end end unless @work_items.empty?(step.id) && @events.empty?(step.id) From cb6e7e4f1510dddc3aafdd3961930030cb6753c6 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 11:02:12 +0100 Subject: [PATCH 37/44] Fix Lint/AmbiguousOperator cop --- .rubocop_todo.yml | 13 ------------- lib/dynflow/debug/telemetry/persistence.rb | 2 +- test/action_test.rb | 2 +- test/clock_test.rb | 2 +- test/concurrency_control_test.rb | 2 +- test/support/middleware_example.rb | 2 +- 6 files changed, 5 insertions(+), 18 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f5869da83..dee3e2098 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,19 +35,6 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 9 -# Cop supports --auto-correct. -Lint/AmbiguousOperator: - Exclude: - - 'lib/dynflow/debug/telemetry/persistence.rb' - - 'lib/dynflow/telemetry.rb' - - 'lib/dynflow/testing/factories.rb' - - 'lib/dynflow/testing/mimic.rb' - - 'test/action_test.rb' - - 'test/clock_test.rb' - - 'test/concurrency_control_test.rb' - - 'test/support/middleware_example.rb' - # Offense count: 3 # Cop supports --auto-correct. Lint/AmbiguousRegexpLiteral: diff --git a/lib/dynflow/debug/telemetry/persistence.rb b/lib/dynflow/debug/telemetry/persistence.rb index f4f108f5f..782c69f1d 100644 --- a/lib/dynflow/debug/telemetry/persistence.rb +++ b/lib/dynflow/debug/telemetry/persistence.rb @@ -33,7 +33,7 @@ module Persistence methods.each do |name| define_method(name) do |*args| - Dynflow::Telemetry.measure(:dynflow_persistence, :method => name, :world => @world.id) { super *args } + Dynflow::Telemetry.measure(:dynflow_persistence, :method => name, :world => @world.id) { super(*args) } end end end diff --git a/test/action_test.rb b/test/action_test.rb index 203dbadb0..2a976a49d 100644 --- a/test/action_test.rb +++ b/test/action_test.rb @@ -406,7 +406,7 @@ def create_sub_plans def resume(*args) output[:custom_resume] = true - super *args + super(*args) end end diff --git a/test/clock_test.rb b/test/clock_test.rb index 10073a05b..32bb598b2 100644 --- a/test/clock_test.rb +++ b/test/clock_test.rb @@ -48,6 +48,6 @@ assert_equal (0...times).to_a, Array.new(times) { q.pop }.sort end end - threads.each &:join + threads.each(&:join) end end diff --git a/test/concurrency_control_test.rb b/test/concurrency_control_test.rb index 5d620bee8..9d81dbbc2 100644 --- a/test/concurrency_control_test.rb +++ b/test/concurrency_control_test.rb @@ -101,7 +101,7 @@ class LoggingCore < Dynflow::ThrottleLimiter::Core def initialize(*args) @running = [0] - super *args + super(*args) end def release(*args) diff --git a/test/support/middleware_example.rb b/test/support/middleware_example.rb index 5c82bf161..9d0f4421d 100644 --- a/test/support/middleware_example.rb +++ b/test/support/middleware_example.rb @@ -17,7 +17,7 @@ def log(message) def delay(*args) log 'before_delay' - pass *args + pass(*args) log 'after_delay' end From b1ac92dc5b70952b811a226ee72bb176ba6f9ec3 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 11:02:34 +0100 Subject: [PATCH 38/44] Fix Lint/AmbiguousRegexpLiteral cop --- .rubocop_todo.yml | 8 -------- doc/pages/plugins/graphviz.rb | 2 +- test/dispatcher_test.rb | 2 +- test/future_execution_test.rb | 2 +- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index dee3e2098..e02597b92 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,14 +35,6 @@ Layout/FirstHashElementIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 3 -# Cop supports --auto-correct. -Lint/AmbiguousRegexpLiteral: - Exclude: - - 'doc/pages/plugins/graphviz.rb' - - 'test/dispatcher_test.rb' - - 'test/future_execution_test.rb' - # Offense count: 8 # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: diff --git a/doc/pages/plugins/graphviz.rb b/doc/pages/plugins/graphviz.rb index 7ac3effb2..2e5e175f5 100644 --- a/doc/pages/plugins/graphviz.rb +++ b/doc/pages/plugins/graphviz.rb @@ -61,7 +61,7 @@ def filter_for_inline_svg(code) code = add_desc_attrs code code = insert_desc_elements code code = wrap_with_div code - code = code.gsub / Date: Mon, 29 Jan 2024 11:03:16 +0100 Subject: [PATCH 39/44] Fix Lint/DisjunctiveAssignmentInConstructor cop --- .rubocop_todo.yml | 6 ------ lib/dynflow/coordinator.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e02597b92..3e576ad8c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -48,12 +48,6 @@ Lint/AssignmentInCondition: - 'lib/dynflow/web/console_helpers.rb' - 'test/test_helper.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Lint/DisjunctiveAssignmentInConstructor: - Exclude: - - 'lib/dynflow/coordinator.rb' - # Offense count: 4 Lint/DuplicateMethods: Exclude: diff --git a/lib/dynflow/coordinator.rb b/lib/dynflow/coordinator.rb index c215f6f02..267de13a4 100644 --- a/lib/dynflow/coordinator.rb +++ b/lib/dynflow/coordinator.rb @@ -41,7 +41,7 @@ def self.constantize(name) end def initialize(*args) - @data ||= {} + @data = {} @data = Utils.indifferent_hash(@data.merge(class: self.class.name)) end From 39f574f32b1b70c05c39654914170bb71b8293f8 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 11:05:03 +0100 Subject: [PATCH 40/44] Fix Lint/EmptyWhen cop --- .rubocop_todo.yml | 6 ------ lib/dynflow/action.rb | 1 + 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3e576ad8c..c65bb2325 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -56,12 +56,6 @@ Lint/DuplicateMethods: - 'lib/dynflow/rails/configuration.rb' - 'lib/dynflow/rails/daemon.rb' -# Offense count: 1 -# Configuration parameters: AllowComments. -Lint/EmptyWhen: - Exclude: - - 'lib/dynflow/action.rb' - # Offense count: 6 Lint/IneffectiveAccessModifier: Exclude: diff --git a/lib/dynflow/action.rb b/lib/dynflow/action.rb index 0ff5eb2bc..a497730c5 100644 --- a/lib/dynflow/action.rb +++ b/lib/dynflow/action.rb @@ -503,6 +503,7 @@ def with_error_handling(propagate_error = nil, &block) when :skipping self.state = :skipped when :suspended, :error + # Do nothing else raise "wrong state #{self.state}" end From cff23af37ea7c94bc28eac234608b39be99b213c Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 11:06:30 +0100 Subject: [PATCH 41/44] Fix Lint/ParenthesesAsGroupedExpression cop --- .rubocop_todo.yml | 6 ------ test/concurrency_control_test.rb | 8 ++++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c65bb2325..759e124e7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -71,12 +71,6 @@ Lint/MissingCopEnableDirective: Exclude: - 'test/persistence_test.rb' -# Offense count: 4 -# Cop supports --auto-correct. -Lint/ParenthesesAsGroupedExpression: - Exclude: - - 'test/concurrency_control_test.rb' - # Offense count: 1 Lint/RandOne: Exclude: diff --git a/test/concurrency_control_test.rb b/test/concurrency_control_test.rb index 9d81dbbc2..fd2b50449 100644 --- a/test/concurrency_control_test.rb +++ b/test/concurrency_control_test.rb @@ -82,8 +82,8 @@ def create_sub_plans end def check_step(plan, total, finished) - _(world.throttle_limiter.observe(plan.id).length).must_equal (total - finished) - _(plan.sub_plans.select { |sub| planned? sub }.count).must_equal (total - finished) + _(world.throttle_limiter.observe(plan.id).length).must_equal(total - finished) + _(plan.sub_plans.select { |sub| planned? sub }.count).must_equal(total - finished) _(plan.sub_plans.select { |sub| successful? sub }.count).must_equal finished end @@ -232,12 +232,12 @@ def core_class planned, running = plan.sub_plans.partition { |sub| planned? sub } _(planned.count).must_equal total - level _(running.count).must_equal level - _(world.throttle_limiter.observe(plan.id).length).must_equal (total - 1) + _(world.throttle_limiter.observe(plan.id).length).must_equal(total - 1) 4.times { klok.progress } wait_for { future.resolved? } finished, stopped = plan.sub_plans.partition { |sub| successful? sub } _(finished.count).must_equal level - _(stopped.count).must_equal (total - level) + _(stopped.count).must_equal(total - level) end end end From c328c0afd00566ab2159f51a896bbc2c5aa1cddd Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 11:08:04 +0100 Subject: [PATCH 42/44] Fix Lint/RedundantCopDisableDirective cop --- .rubocop_todo.yml | 6 ------ lib/dynflow/config.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 759e124e7..8ddc9f580 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -76,12 +76,6 @@ Lint/RandOne: Exclude: - 'examples/orchestrate_evented.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Lint/RedundantCopDisableDirective: - Exclude: - - 'lib/dynflow/config.rb' - # Offense count: 1 # Cop supports --auto-correct. Lint/RedundantRequireStatement: diff --git a/lib/dynflow/config.rb b/lib/dynflow/config.rb index 38a5280f1..79bd4178d 100644 --- a/lib/dynflow/config.rb +++ b/lib/dynflow/config.rb @@ -205,7 +205,7 @@ def validate(config_for_world) "it's #{ar_pool_size} but there is #{config_for_world.pool_size} " + 'threads in Dynflow pool.' end - rescue ActiveRecord::ConnectionNotEstablished # rubocop:disable Lint/HandleExceptions + rescue ActiveRecord::ConnectionNotEstablished # If in tests or in an environment where ActiveRecord doesn't have a # real DB connection, we want to skip AR configuration altogether end From 07ee87406877b57915444a6e5f6324f1293d0ce1 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 11:08:25 +0100 Subject: [PATCH 43/44] Fix Lint/RedundantRequireStatement cop --- .rubocop_todo.yml | 6 ------ lib/dynflow.rb | 1 - 2 files changed, 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8ddc9f580..e3de666a9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -76,12 +76,6 @@ Lint/RandOne: Exclude: - 'examples/orchestrate_evented.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Lint/RedundantRequireStatement: - Exclude: - - 'lib/dynflow.rb' - # Offense count: 3 Lint/RescueException: Exclude: diff --git a/lib/dynflow.rb b/lib/dynflow.rb index 69155cb93..f1e8191e5 100644 --- a/lib/dynflow.rb +++ b/lib/dynflow.rb @@ -2,7 +2,6 @@ require 'apipie-params' require 'algebrick' -require 'thread' require 'set' require 'base64' require 'concurrent' From 163959897aef3204d0a10946a910d5e550d39bea Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Mon, 29 Jan 2024 11:09:13 +0100 Subject: [PATCH 44/44] Fix Lint/SendWithMixinArgument cop --- .rubocop_todo.yml | 9 --------- lib/dynflow.rb | 5 +---- lib/dynflow/debug/telemetry/persistence.rb | 2 +- test/activejob_adapter_test.rb | 2 +- test/executor_test.rb | 2 +- 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e3de666a9..ed6654930 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -91,15 +91,6 @@ Lint/ScriptPermission: - 'examples/memory_limit_watcher.rb' - 'examples/sub_plan_concurrency_control.rb' -# Offense count: 4 -# Cop supports --auto-correct. -Lint/SendWithMixinArgument: - Exclude: - - 'lib/dynflow.rb' - - 'lib/dynflow/debug/telemetry/persistence.rb' - - 'test/activejob_adapter_test.rb' - - 'test/executor_test.rb' - # Offense count: 3 Lint/ShadowingOuterLocalVariable: Exclude: diff --git a/lib/dynflow.rb b/lib/dynflow.rb index f1e8191e5..6faea02a1 100644 --- a/lib/dynflow.rb +++ b/lib/dynflow.rb @@ -79,10 +79,7 @@ def self.from_hash(hash) class Railtie < ::Rails::Railtie config.before_initialize do - ::ActiveJob::QueueAdapters.send( - :include, - Dynflow::ActiveJob::QueueAdapters - ) + ::ActiveJob::QueueAdapters.include Dynflow::ActiveJob::QueueAdapters end end end diff --git a/lib/dynflow/debug/telemetry/persistence.rb b/lib/dynflow/debug/telemetry/persistence.rb index 782c69f1d..ad5cb38ca 100644 --- a/lib/dynflow/debug/telemetry/persistence.rb +++ b/lib/dynflow/debug/telemetry/persistence.rb @@ -41,4 +41,4 @@ module Persistence end end -::Dynflow::Persistence.send(:prepend, ::Dynflow::Debug::Persistence) +::Dynflow::Persistence.prepend ::Dynflow::Debug::Persistence diff --git a/test/activejob_adapter_test.rb b/test/activejob_adapter_test.rb index bda839037..aff0e5062 100644 --- a/test/activejob_adapter_test.rb +++ b/test/activejob_adapter_test.rb @@ -22,7 +22,7 @@ def perform(msg) end before(:all) do - ::ActiveJob::QueueAdapters.send(:include, ::Dynflow::ActiveJob::QueueAdapters) + ::ActiveJob::QueueAdapters.include ::Dynflow::ActiveJob::QueueAdapters ::ActiveJob::Base.queue_adapter = :dynflow dynflow_mock = Minitest::Mock.new dynflow_mock.expect(:world, world) diff --git a/test/executor_test.rb b/test/executor_test.rb index 8a9f8fba2..a5b48e90d 100644 --- a/test/executor_test.rb +++ b/test/executor_test.rb @@ -18,7 +18,7 @@ def wait_for_orchestrator_lock; end def reacquire_orchestrator_lock; end end -::Dynflow::Executors::Sidekiq::Core.send(:prepend, RedisMocks) +::Dynflow::Executors::Sidekiq::Core.prepend RedisMocks module Dynflow module ExecutorTest