metanorma/vectory

View on GitHub

Showing 4 of 8 total issues

Method with_timeout has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

      def with_timeout(*cmd)
        spawn_opts = Hash === cmd.last ? cmd.pop.dup : {}
        opts = {
          :stdin_data => spawn_opts.delete(:stdin_data) || "",
          :binmode    => spawn_opts.delete(:binmode) || false,
Severity: Minor
Found in lib/vectory/capture.rb - About 3 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 with_timeout has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def with_timeout(*cmd)
        spawn_opts = Hash === cmd.last ? cmd.pop.dup : {}
        opts = {
          :stdin_data => spawn_opts.delete(:stdin_data) || "",
          :binmode    => spawn_opts.delete(:binmode) || false,
Severity: Major
Found in lib/vectory/capture.rb - About 2 hrs to fix

    Method build_vector has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_vector(image)
          return Vectory::Svg.from_content(image.to_xml) if image.name == "svg"
    
          return unless image.name == "image"
    
    
    Severity: Minor
    Found in lib/vectory/svg_mapping.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 external_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def external_path(path)
          win = !!((RUBY_PLATFORM =~ /(win|w)(32|64)$/) ||
                   (RUBY_PLATFORM =~ /mswin|mingw/))
          if win
            path.gsub!(%{/}, "\\")
    Severity: Minor
    Found in lib/vectory/inkscape_converter.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