From 4fb2d206a2257640aa9156992d62cfa759ed172d Mon Sep 17 00:00:00 2001 From: Jason Hanggi Date: Tue, 22 Jan 2019 00:24:34 -0600 Subject: [PATCH] Add frozen string literal cop --- .rubocop.yml | 3 +++ Gemfile | 2 ++ Rakefile | 2 ++ flow_machine.gemspec | 2 ++ lib/flow_machine.rb | 2 ++ lib/flow_machine/callback.rb | 2 ++ lib/flow_machine/change_callback.rb | 2 ++ lib/flow_machine/state_callback.rb | 2 ++ lib/flow_machine/version.rb | 2 ++ lib/flow_machine/workflow.rb | 2 ++ lib/flow_machine/workflow/factory_methods.rb | 2 ++ lib/flow_machine/workflow/model_extension.rb | 2 ++ lib/flow_machine/workflow_state.rb | 2 ++ lib/tasks/workflow_tasks.rake | 2 ++ spec/flow_machine/factory_methods_spec.rb | 2 ++ spec/flow_machine/multiple_workflow_spec.rb | 2 ++ spec/flow_machine/workflow/model_extension_spec.rb | 2 ++ spec/flow_machine/workflow_callback_spec.rb | 2 ++ spec/flow_machine/workflow_change_callback_spec.rb | 2 ++ spec/flow_machine/workflow_spec.rb | 2 ++ spec/flow_machine/workflow_state/transition_callbacks_spec.rb | 2 ++ spec/flow_machine/workflow_state_spec.rb | 2 ++ spec/spec_helper.rb | 2 ++ 23 files changed, 47 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index d41a9a9..52d7df5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,6 +4,9 @@ inherit_from: Style/StringLiterals: EnforcedStyle: double_quotes +Style/FrozenStringLiteralComment: + EnforcedStyle: always + Metrics/LineLength: Max: 120 diff --git a/Gemfile b/Gemfile index 0aad991..34cc712 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source "https://rubygems.org" # Declare your gem's dependencies in workflow.gemspec. diff --git a/Rakefile b/Rakefile index 7a09a08..7f3d637 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require "bundler/setup" rescue LoadError diff --git a/flow_machine.gemspec b/flow_machine.gemspec index fab66b2..9589030 100644 --- a/flow_machine.gemspec +++ b/flow_machine.gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + $LOAD_PATH.push File.expand_path("lib", __dir__) # Maintain your gem's version: diff --git a/lib/flow_machine.rb b/lib/flow_machine.rb index c2341c0..38f048b 100644 --- a/lib/flow_machine.rb +++ b/lib/flow_machine.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + $LOAD_PATH.unshift(File.dirname(__FILE__)) require "flow_machine/workflow" diff --git a/lib/flow_machine/callback.rb b/lib/flow_machine/callback.rb index 55bf547..cc756ff 100644 --- a/lib/flow_machine/callback.rb +++ b/lib/flow_machine/callback.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/object/blank" require "active_support/core_ext/array/extract_options" diff --git a/lib/flow_machine/change_callback.rb b/lib/flow_machine/change_callback.rb index c28723d..ed75280 100644 --- a/lib/flow_machine/change_callback.rb +++ b/lib/flow_machine/change_callback.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FlowMachine class ChangeCallback < FlowMachine::StateCallback attr_accessor :field diff --git a/lib/flow_machine/state_callback.rb b/lib/flow_machine/state_callback.rb index f635c5c..dc6cc69 100644 --- a/lib/flow_machine/state_callback.rb +++ b/lib/flow_machine/state_callback.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FlowMachine class StateCallback < FlowMachine::Callback def run_method(target, method) diff --git a/lib/flow_machine/version.rb b/lib/flow_machine/version.rb index 09c9d17..9760ca4 100644 --- a/lib/flow_machine/version.rb +++ b/lib/flow_machine/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FlowMachine VERSION = "0.2.3".freeze end diff --git a/lib/flow_machine/workflow.rb b/lib/flow_machine/workflow.rb index c975e06..2bd9873 100644 --- a/lib/flow_machine/workflow.rb +++ b/lib/flow_machine/workflow.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/module/delegation" require "active_support/core_ext/object/try" require "flow_machine/workflow/factory_methods" diff --git a/lib/flow_machine/workflow/factory_methods.rb b/lib/flow_machine/workflow/factory_methods.rb index b610973..289250d 100644 --- a/lib/flow_machine/workflow/factory_methods.rb +++ b/lib/flow_machine/workflow/factory_methods.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # These methods are extended in the base FlowMachine module module FlowMachine module FactoryMethods diff --git a/lib/flow_machine/workflow/model_extension.rb b/lib/flow_machine/workflow/model_extension.rb index 8836a5e..353cf0a 100644 --- a/lib/flow_machine/workflow/model_extension.rb +++ b/lib/flow_machine/workflow/model_extension.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FlowMachine module Workflow module ModelExtension diff --git a/lib/flow_machine/workflow_state.rb b/lib/flow_machine/workflow_state.rb index 9f61397..5fa614c 100644 --- a/lib/flow_machine/workflow_state.rb +++ b/lib/flow_machine/workflow_state.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/module/delegation" require "active_support/inflector" diff --git a/lib/tasks/workflow_tasks.rake b/lib/tasks/workflow_tasks.rake index 61fc456..34ed772 100644 --- a/lib/tasks/workflow_tasks.rake +++ b/lib/tasks/workflow_tasks.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # desc "Explaining what the task does" # task :workflow do # # Task goes here diff --git a/spec/flow_machine/factory_methods_spec.rb b/spec/flow_machine/factory_methods_spec.rb index 0129715..1cf7e16 100644 --- a/spec/flow_machine/factory_methods_spec.rb +++ b/spec/flow_machine/factory_methods_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe FlowMachine::Workflow do class TestClass; end diff --git a/spec/flow_machine/multiple_workflow_spec.rb b/spec/flow_machine/multiple_workflow_spec.rb index c993f65..2db899f 100644 --- a/spec/flow_machine/multiple_workflow_spec.rb +++ b/spec/flow_machine/multiple_workflow_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe FlowMachine::Workflow do let(:state_class1) do Class.new(FlowMachine::WorkflowState) do diff --git a/spec/flow_machine/workflow/model_extension_spec.rb b/spec/flow_machine/workflow/model_extension_spec.rb index b68cab1..3d3ff45 100644 --- a/spec/flow_machine/workflow/model_extension_spec.rb +++ b/spec/flow_machine/workflow/model_extension_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "ostruct" RSpec.describe FlowMachine::Workflow::ModelExtension do diff --git a/spec/flow_machine/workflow_callback_spec.rb b/spec/flow_machine/workflow_callback_spec.rb index fb21483..fcf26a3 100644 --- a/spec/flow_machine/workflow_callback_spec.rb +++ b/spec/flow_machine/workflow_callback_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe FlowMachine::Callback do let(:object) { double } diff --git a/spec/flow_machine/workflow_change_callback_spec.rb b/spec/flow_machine/workflow_change_callback_spec.rb index ad0bd60..0243d41 100644 --- a/spec/flow_machine/workflow_change_callback_spec.rb +++ b/spec/flow_machine/workflow_change_callback_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe FlowMachine::ChangeCallback do subject(:callback) { described_class.new(:field, :method, if: :condition?) } diff --git a/spec/flow_machine/workflow_spec.rb b/spec/flow_machine/workflow_spec.rb index e677d21..10052b7 100644 --- a/spec/flow_machine/workflow_spec.rb +++ b/spec/flow_machine/workflow_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "ostruct" RSpec.describe FlowMachine::Workflow do diff --git a/spec/flow_machine/workflow_state/transition_callbacks_spec.rb b/spec/flow_machine/workflow_state/transition_callbacks_spec.rb index 5bcbd19..cdebbe9 100644 --- a/spec/flow_machine/workflow_state/transition_callbacks_spec.rb +++ b/spec/flow_machine/workflow_state/transition_callbacks_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "ostruct" RSpec.describe FlowMachine::WorkflowState do diff --git a/spec/flow_machine/workflow_state_spec.rb b/spec/flow_machine/workflow_state_spec.rb index 0cd6e83..b1231dc 100644 --- a/spec/flow_machine/workflow_state_spec.rb +++ b/spec/flow_machine/workflow_state_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe FlowMachine::WorkflowState do class StateTestClass < described_class def self.state_name diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8de2d7d..bec97fe 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + GEM_ROOT = File.expand_path("..", __dir__) $LOAD_PATH.unshift File.join(GEM_ROOT, "lib")