mileszs/wicked_pdf

View on GitHub

Showing 17 of 17 total issues

Method parse_header_footer has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_header_footer(options)
      r = []
      unless options.blank?
        %i[header footer].collect do |hf|
          next if options[hf].blank?
Severity: Minor
Found in lib/wicked_pdf/option_parser.rb - About 2 hrs 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 pdf_from_url has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def pdf_from_url(url, options = {})
    # merge in global config options
    options.merge!(WickedPdf.config) { |_key, option, _config| option }
    generated_pdf_file = WickedPdf::Tempfile.new('wicked_pdf_generated_file.pdf', options[:temp_path])
    command = [@binary.path]
Severity: Minor
Found in lib/wicked_pdf.rb - About 2 hrs 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 make_and_send_pdf has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def make_and_send_pdf(pdf_name, options = {})
      options[:wkhtmltopdf] ||= nil
      options[:layout] ||= false
      options[:template] ||= File.join(controller_path, action_name)
      options[:disposition] ||= 'inline'
Severity: Minor
Found in lib/wicked_pdf/pdf_helper.rb - About 2 hrs 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 render_as_pdf? has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def render_as_pdf?
      request_path_is_pdf = @request.path.match(%r{\.pdf$})

      if request_path_is_pdf && @conditions[:only]
        rules = [@conditions[:only]].flatten
Severity: Minor
Found in lib/wicked_pdf/middleware.rb - About 2 hrs 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 prerender_header_and_footer has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def prerender_header_and_footer(options)
      %i[header footer].each do |hf|
        next unless options[hf] && options[hf][:html] && options[hf][:html][:template]

        @hf_tempfiles = [] unless defined?(@hf_tempfiles)
Severity: Minor
Found in lib/wicked_pdf/pdf_helper.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 call has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def call(env)
      @request = Rack::Request.new(env)
      @render_pdf = false

      set_request_to_render_as_pdf(env) if render_as_pdf?
Severity: Minor
Found in lib/wicked_pdf/middleware.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 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 parse_others has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def parse_others(options)
      r = []
      unless options.blank?
        r += make_options(options, %i[proxy
                                      username
Severity: Minor
Found in lib/wicked_pdf/option_parser.rb - About 1 hr to fix

    Method parse_toc has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def parse_toc(options)
          return [] if options.nil?
    
          r = [valid_option('toc')]
          unless options.blank?
    Severity: Minor
    Found in lib/wicked_pdf/option_parser.rb - About 1 hr to fix

      Method pdf_from_url has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def pdf_from_url(url, options = {})
          # merge in global config options
          options.merge!(WickedPdf.config) { |_key, option, _config| option }
          generated_pdf_file = WickedPdf::Tempfile.new('wicked_pdf_generated_file.pdf', options[:temp_path])
          command = [@binary.path]
      Severity: Minor
      Found in lib/wicked_pdf.rb - About 1 hr to fix

        Method invoke_with_progress has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def invoke_with_progress(command, options)
              output = []
              begin
                PTY.spawn(command.join(' ')) do |stdout, _stdin, pid|
                  begin
        Severity: Minor
        Found in lib/wicked_pdf/progress.rb - About 55 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 make_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def make_options(options, names, prefix = '', type = :string)
              return [] if options.nil?
        
              names.collect do |o|
                if options[o].blank?
        Severity: Minor
        Found in lib/wicked_pdf/option_parser.rb - About 45 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 make_option has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def make_option(name, value, type = :string)
              return value.collect { |v| make_option(name, v, type) } if value.is_a?(Array)
        
              if type == :name_value
                parts = value.to_s.split(' ')
        Severity: Minor
        Found in lib/wicked_pdf/option_parser.rb - About 45 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 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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(binary_path, default_version = WickedPdf::DEFAULT_BINARY_VERSION)
              @path = binary_path || find_binary_path
              @default_version = default_version
        
              raise "Location of #{EXE_NAME} unknown" if @path.empty?
        Severity: Minor
        Found in lib/wicked_pdf/binary.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

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

            def find_binary_path
              exe_path ||= WickedPdf.config[:exe_path] unless WickedPdf.config.empty?
              exe_path ||= possible_which_path
              exe_path ||= possible_locations.map { |l| File.expand_path("#{l}/#{EXE_NAME}") }.find { |location| File.exist?(location) }
              exe_path || ''
        Severity: Minor
        Found in lib/wicked_pdf/binary.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

        Severity
        Category
        Status
        Source
        Language