afast/map_print

View on GitHub

Showing 9 of 11 total issues

Method initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(args)
      @format = args[:format]
      @pdf_options = args[:pdf_options]
      @png_options = args[:png_options]
      @map = args[:map]
Severity: Minor
Found in lib/map_print/core.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 print has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def print
      raise ParameterError.new('Missing png_options width attribute') unless @context.png_options && @context.png_options[:width]
      raise ParameterError.new('Missing png_options height attribute') unless @context.png_options[:height]
      `convert -density 300 -size #{@context.png_options[:width]}x#{@context.png_options[:height]} xc:#{@context.png_options[:background_color] || 'transparent'} #{@context.output_path}`
      @png = MiniMagick::Image.new @context.output_path
Severity: Minor
Found in lib/map_print/png_handler.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def initialize(base_url, type, sw_lat_lng, ne_lat_lng, zoom)
Severity: Minor
Found in lib/map_print/tiles/tile_factory.rb - About 35 mins to fix

    Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def initialize(geojson, sw, ne, width, height)
    Severity: Minor
    Found in lib/map_print/geo_json_handler.rb - About 35 mins to fix

      Method next_step has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def next_step(small_step_value, big_step_value, small_step, big_step, z)
      Severity: Minor
      Found in lib/map_print/legend_handler.rb - About 35 mins to fix

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

            def print_map
              map_image = @context.print_layers
        
              size = @context.map[:size]
              geometry = ''
        Severity: Minor
        Found in lib/map_print/pdf_handler.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 print_map has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def print_map
              map_image = @context.print_layers
        
              size = @context.map[:size]
              geometry = ''
        Severity: Minor
        Found in lib/map_print/png_handler.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 text_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def text_options(text)
                box = {}
        
                if text[:position]
                  box[:at] = text[:position].values
        Severity: Minor
        Found in lib/map_print/pdf_handlers/texts.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 sanitize_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def sanitize_options(options)
                return {} unless options.is_a?(Hash)
                options[:stroke] = options.delete :color if options[:color]
                options[:fill] = options.delete :fill_color if options[:fill_color]
                options[:gravity] ||= 'NorthWest'
        Severity: Minor
        Found in lib/map_print/png_handlers/texts.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