mileszs/wicked_pdf

View on GitHub
lib/wicked_pdf/option_parser.rb

Summary

Maintainability
B
6 hrs
Test Coverage

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 parse_others has 34 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 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

      There are no issues that match your filters.

      Category
      Status