bhollis/maruku

View on GitHub
lib/maruku/output/to_latex.rb

Summary

Maintainability
C
1 day
Test Coverage

File to_latex.rb has 355 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'set'
require 'maruku/output/entity_table'

module MaRuKu::Out::Latex
  module MDDocumentExtensions
Severity: Minor
Found in lib/maruku/output/to_latex.rb - About 4 hrs to fix

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

      def array_to_latex(array, join_char='')
        e = []
        array.each do |c|
          if c.kind_of?(String)
            e << string_to_latex(c)
    Severity: Minor
    Found in lib/maruku/output/to_latex.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 to_latex_entity has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def to_latex_entity
        entity_name = self.entity_name
    
        entity = MaRuKu::Out::EntityTable.instance.entity(entity_name)
        unless entity
    Severity: Minor
    Found in lib/maruku/output/to_latex.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 to_latex_code has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def to_latex_code
        if get_setting(:latex_use_listings)
          @doc.latex_require_package('listings')
    
          s = "\\lstset{columns=fixed,frame=shadowbox}"
    Severity: Minor
    Found in lib/maruku/output/to_latex.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 to_latex_header has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def to_latex_header
        header_levels = %w(section subsection subsubsection)
        h = header_levels[self.level - 1] || 'paragraph'
    
        title = children_to_latex
    Severity: Minor
    Found in lib/maruku/output/to_latex.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 to_latex_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def to_latex_link
        id = self.ref_id || children_to_s
        ref = @doc.refs[sanitize_ref_id(id)] || @doc.refs[sanitize_ref_id(children_to_s)]
        if ref
          url = ref[:url]
    Severity: Minor
    Found in lib/maruku/output/to_latex.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 latex_color has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def latex_color(s, command='color')
        if s =~ /\A\#([1-9A-F]{1,2})([1-9A-F]{1,2})([1-9A-F]{1,2})\z/i
          # convert from 0-255 or 0-15 to 0.0-1.0
          r, g, b = [$1, $2, $3].map {|c| c.hex / (c.length == 1 ? 15.0 : 255.0) }
          "\\#{command}[rgb]{%0.2f,%0.2f,%0.2f}" % [r, g, b]
    Severity: Minor
    Found in lib/maruku/output/to_latex.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