diff --git a/examples/rails/bin/yarn b/examples/rails/bin/yarn index bc1038f..4c0c8c7 100755 --- a/examples/rails/bin/yarn +++ b/examples/rails/bin/yarn @@ -3,11 +3,9 @@ APP_ROOT = File.expand_path("..", __dir__) Dir.chdir(APP_ROOT) do - begin - exec "yarnpkg", *ARGV - rescue Errno::ENOENT - warn "Yarn executable was not detected in the system." - warn "Download Yarn at https://yarnpkg.com/en/docs/install" - exit 1 - end + exec "yarnpkg", *ARGV +rescue Errno::ENOENT + warn "Yarn executable was not detected in the system." + warn "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 end diff --git a/examples/rails/config/environments/production.rb b/examples/rails/config/environments/production.rb index 11d25d4..85b8ab0 100644 --- a/examples/rails/config/environments/production.rb +++ b/examples/rails/config/environments/production.rb @@ -63,7 +63,7 @@ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV["RAILS_LOG_TO_STDOUT"].present? - logger = ActiveSupport::Logger.new(STDOUT) + logger = ActiveSupport::Logger.new($stdout) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end diff --git a/examples/rails/config/puma.rb b/examples/rails/config/puma.rb index dd9e863..c938cdc 100644 --- a/examples/rails/config/puma.rb +++ b/examples/rails/config/puma.rb @@ -6,16 +6,16 @@ # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads_count = ENV.fetch("RAILS_MAX_THREADS", 5) threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch("PORT", 3000) # Specifies the `environment` that Puma will run in. # -environment ENV.fetch("RAILS_ENV") { "development" } +environment ENV.fetch("RAILS_ENV", "development") # Specifies the number of `workers` to boot in clustered mode. # Workers are forked webserver processes. If using threads and workers together diff --git a/lib/dry/view.rb b/lib/dry/view.rb index b21791f..f9300c7 100644 --- a/lib/dry/view.rb +++ b/lib/dry/view.rb @@ -508,7 +508,7 @@ def layout_locals(locals) # @api private def layout? - !!config.layout # rubocop:disable Style/DoubleNegation + !!config.layout end end end diff --git a/lib/dry/view/exposure.rb b/lib/dry/view/exposure.rb index 6fa6958..72d5512 100644 --- a/lib/dry/view/exposure.rb +++ b/lib/dry/view/exposure.rb @@ -50,15 +50,15 @@ def input_keys end def for_layout? - options.fetch(:layout) { false } + options.fetch(:layout, false) end def decorate? - options.fetch(:decorate) { true } + options.fetch(:decorate, true) end def private? - options.fetch(:private) { false } + options.fetch(:private, false) end def default_value @@ -84,12 +84,10 @@ def call_proc(input, locals) else object.instance_exec(*args, &proc) end + elsif proc.is_a?(Method) + proc.(*args, **keywords) else - if proc.is_a?(Method) - proc.(*args, **keywords) - else - object.instance_exec(*args, **keywords, &proc) - end + object.instance_exec(*args, **keywords, &proc) end end diff --git a/lib/dry/view/exposures.rb b/lib/dry/view/exposures.rb index 099f148..45b836a 100644 --- a/lib/dry/view/exposures.rb +++ b/lib/dry/view/exposures.rb @@ -46,7 +46,6 @@ def bind(obj) end def call(input) - # rubocop:disable Style/MultilineBlockChain tsort.each_with_object({}) { |name, memo| next unless (exposure = self[name]) diff --git a/lib/dry/view/part.rb b/lib/dry/view/part.rb index 15254ca..2add259 100644 --- a/lib/dry/view/part.rb +++ b/lib/dry/view/part.rb @@ -71,9 +71,8 @@ def self.part_name(inflector) # # @api public def initialize( - render_env: RenderEnvironmentMissing.new, - name: self.class.part_name(render_env.inflector), - value: + value:, render_env: RenderEnvironmentMissing.new, + name: self.class.part_name(render_env.inflector) ) @_name = name @_value = value @@ -126,11 +125,9 @@ def _context # @return [String] rendered partial # # @api public - # rubocop:disable Naming/UncommunicativeMethodParamName def _render(partial_name, as: _name, **locals, &block) _render_env.partial(partial_name, _render_env.scope({as => self}.merge(locals)), &block) end - # rubocop:enable Naming/UncommunicativeMethodParamName # Builds a new scope with the part included in its locals. # diff --git a/lib/dry/view/part_builder.rb b/lib/dry/view/part_builder.rb index 2526b54..6841f0a 100644 --- a/lib/dry/view/part_builder.rb +++ b/lib/dry/view/part_builder.rb @@ -108,7 +108,6 @@ def part_class(name:, fallback_class: Part, **options) end end - # rubocop:disable Metrics/PerceivedComplexity def resolve_part_class(name:, fallback_class:) return fallback_class unless namespace @@ -117,7 +116,7 @@ def resolve_part_class(name:, fallback_class:) # Give autoloaders a chance to act begin klass = namespace.const_get(name) - rescue NameError # rubocop:disable Lint/HandleExceptions + rescue NameError end if !klass && namespace.const_defined?(name, false) @@ -130,7 +129,6 @@ def resolve_part_class(name:, fallback_class:) fallback_class end end - # rubocop:enable Metrics/PerceivedComplexity def inflector render_env.inflector diff --git a/lib/dry/view/scope_builder.rb b/lib/dry/view/scope_builder.rb index 6c59631..c8c984a 100644 --- a/lib/dry/view/scope_builder.rb +++ b/lib/dry/view/scope_builder.rb @@ -76,7 +76,7 @@ def resolve_scope_class(name:) # Give autoloaders a chance to act begin klass = namespace.const_get(name) - rescue NameError # rubocop:disable Lint/HandleExceptions + rescue NameError end if !klass && namespace.const_defined?(name, false) diff --git a/spec/integration/context_spec.rb b/spec/integration/context_spec.rb index cde79dc..e692408 100644 --- a/spec/integration/context_spec.rb +++ b/spec/integration/context_spec.rb @@ -15,6 +15,7 @@ def [](path) class Context < Dry::View::Context attr_reader :assets + decorate :assets def initialize(assets:, **options) diff --git a/spec/integration/scope_spec.rb b/spec/integration/scope_spec.rb index 0de5ef9..578e9ff 100644 --- a/spec/integration/scope_spec.rb +++ b/spec/integration/scope_spec.rb @@ -43,7 +43,7 @@ def hello module Test::Scopes class Greeting < Dry::View::Scope def greeting - _locals[:greeting].upcase + "!" + "#{_locals[:greeting].upcase}!" end end end @@ -62,7 +62,7 @@ def greeting module Test::Scopes class Greeting < Dry::View::Scope def greeting - _locals[:greeting].upcase + "!" + "#{_locals[:greeting].upcase}!" end end end @@ -89,7 +89,7 @@ def greeting module Test::Scopes class Greeting < Dry::View::Scope def greeting - _locals[:greeting].upcase + "!" + "#{_locals[:greeting].upcase}!" end end end @@ -108,7 +108,7 @@ def greeting module Test::Scopes class Greeting < Dry::View::Scope def greeting - _locals.fetch(:greeting) { "Howdy" } + _locals.fetch(:greeting, "Howdy") end end end @@ -135,7 +135,7 @@ def greeting module Test::Scopes class Greeting < Dry::View::Scope def greeting - _locals[:greeting] + "!" + "#{_locals[:greeting]}!" end end end diff --git a/spec/integration/testing/testing_parts_spec.rb b/spec/integration/testing/testing_parts_spec.rb index 3d9d105..2ff9ed9 100644 --- a/spec/integration/testing/testing_parts_spec.rb +++ b/spec/integration/testing/testing_parts_spec.rb @@ -9,7 +9,7 @@ specify "Parts can be unit tested without name or rendering (for testing methods that don't require them)" do part_class = Class.new(Dry::View::Part) do def breaking_news_title - title + "!" + "#{title}!" end end diff --git a/spec/integration/view_spec.rb b/spec/integration/view_spec.rb index 07cdd8e..7812ace 100644 --- a/spec/integration/view_spec.rb +++ b/spec/integration/view_spec.rb @@ -91,7 +91,7 @@ def assets klass.setting :paths, default: SPEC_ROOT.join("fixtures/templates") klass.setting :layout, default: "app" - klass.setting :formats, default: { html: :slim } + klass.setting :formats, default: {html: :slim} klass end diff --git a/spec/unit/exposure_spec.rb b/spec/unit/exposure_spec.rb index b1127f4..3445bb1 100644 --- a/spec/unit/exposure_spec.rb +++ b/spec/unit/exposure_spec.rb @@ -116,7 +116,7 @@ def hello(input) describe "#dependency_names" do context "proc provided" do - let(:proc) { -> input, foo, bar { "hi" } } # rubocop:disable Lint/UnusedBlockArgument + let(:proc) { -> input, foo, bar { "hi" } } it "returns an array of exposure dependencies derived from the proc's argument names" do expect(exposure.dependency_names).to eql [:input, :foo, :bar]