mileszs/wicked_pdf

View on GitHub
lib/wicked_pdf/wicked_pdf_helper/assets.rb

Summary

Maintainability
B
6 hrs
Test Coverage

File assets.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'net/http'
require 'delegate'
require 'stringio'

class WickedPdf
Severity: Minor
Found in lib/wicked_pdf/wicked_pdf_helper/assets.rb - About 2 hrs to fix

    Method asset_pathname has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def asset_pathname(source)
            if precompiled_or_absolute_asset?(source)
              asset = asset_path(source)
              pathname = prepend_protocol(asset)
              if pathname =~ URI_REGEXP
    Severity: Minor
    Found in lib/wicked_pdf/wicked_pdf_helper/assets.rb - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method read_asset has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def read_asset(source)
            asset = find_asset(source)
            return asset.to_s.force_encoding('UTF-8') if asset
    
            unless precompiled_or_absolute_asset?(source)
    Severity: Minor
    Found in lib/wicked_pdf/wicked_pdf_helper/assets.rb - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method wicked_pdf_stylesheet_pack_tag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def wicked_pdf_stylesheet_pack_tag(*sources)
            return unless defined?(Webpacker)
    
            if running_in_development?
              stylesheet_pack_tag(*sources)
    Severity: Minor
    Found in lib/wicked_pdf/wicked_pdf_helper/assets.rb - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method find_asset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def find_asset(path)
            if Rails.application.assets.respond_to?(:find_asset)
              Rails.application.assets.find_asset(path, :base_path => Rails.application.root.to_s)
            elsif defined?(Propshaft::Assembly) && Rails.application.assets.is_a?(Propshaft::Assembly)
              PropshaftAsset.new(Rails.application.assets.load_path.find(path))
    Severity: Minor
    Found in lib/wicked_pdf/wicked_pdf_helper/assets.rb - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method webpacker_source_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def webpacker_source_url(source)
            return unless webpacker_version
    
            # In Webpacker 3.2.0 asset_pack_url is introduced
            if webpacker_version >= '3.2.0'
    Severity: Minor
    Found in lib/wicked_pdf/wicked_pdf_helper/assets.rb - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method read_from_uri has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def read_from_uri(uri)
            response = Net::HTTP.get_response(URI(uri))
    
            unless response.is_a?(Net::HTTPSuccess)
              raise MissingRemoteAsset.new(uri, response) if WickedPdf.config[:raise_on_missing_assets]
    Severity: Minor
    Found in lib/wicked_pdf/wicked_pdf_helper/assets.rb - About 25 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    There are no issues that match your filters.

    Category
    Status