Skip to content

Commit

Permalink
🚨 codeclimate
Browse files Browse the repository at this point in the history
  • Loading branch information
josemigallas committed Oct 4, 2024
1 parent 7a08934 commit 68ca266
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions app/helpers/webpack_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ def webpack_manifest
#
# A RuntimeError is raised if one pack is not found in the manifest, possibly pointing out a typo.
#
# ⚠️ This method smells of :reek:NestedIterators and :reek:TooManyStatements
#
def javascript_packs_with_chunks_tag(*packs) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
@packs ||= []
tags = ''
entrypoints = webpack_manifest['entrypoints']

packs.each do |pack|
entrypoint_with_extension = webpack_manifest['entrypoints']["#{pack}.ts"] || {}
entrypoint_without_extension = webpack_manifest['entrypoints'][pack] || {}
entrypoint_with_extension = entrypoints["#{pack}.ts"] || {}
entrypoint_without_extension = entrypoints[pack] || {}

entrypoint = entrypoint_with_extension.deep_merge(entrypoint_without_extension) do |key, this_val, other_val|
(this_val + other_val).uniq
Expand Down Expand Up @@ -65,12 +68,15 @@ def javascript_packs_with_chunks_tag(*packs) # rubocop:disable Metrics/AbcSize,
#
# A RuntimeError is raised if one pack is not found in the manifest, possibly pointing out a typo.
#
# ⚠️ This method smells of :reek:TooManyStatements
#
def stylesheet_packs_chunks_tag(*packs) # rubocop:disable, Metrics/MethodLength, Metrics/CyclomaticComplexity
@packs ||= []
tags = ''
entrypoints = webpack_manifest['entrypoints']

packs.each do |pack|
entrypoint = webpack_manifest['entrypoints'][pack] || {}
entrypoint = entrypoints[pack] || {}
raise "No entrypoint '#{pack}' in manifest" if entrypoint.empty?

assets = entrypoint['assets']
Expand Down
2 changes: 1 addition & 1 deletion lib/developer_portal/lib/liquid/filters/rails_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def stylesheet_link_tag(name)
end

desc "Javascript includes tag."
def javascript_include_tag(name, **options)
def javascript_include_tag(name)
js = RailsHelpers.replace_googleapis(name)
case
when THREESCALE_WEBPACK_PACKS.include?(name) # TODO: This is an intermediate step in order to tackle webpack assets in dev portal. A final solution might be needed easing the update of templates/assets.
Expand Down

0 comments on commit 68ca266

Please sign in to comment.