metanorma/isodoc

View on GitHub

Showing 70 of 112 total issues

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

      def make_tr_attr_style(cell, row, rowmax, totalrows, opt)
        top = row.zero? ? "#{SW1} 1.5pt;" : "none;"
        bottom = "#{SW1} #{rowmax >= totalrows ? '1.5' : '1.0'}pt;"
        ret = <<~STYLE.gsub(/\n/, "")
          border-top:#{top}mso-border-top-alt:#{top}
Severity: Minor
Found in lib/isodoc/word_function/table.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 figure_parse1 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def figure_parse1(node, out)
        out.div **figure_attrs(node) do |div|
          node.children.each do |n|
            figure_key(out) if n.name == "dl"
            parse(n, div) unless n.name == "name"
Severity: Minor
Found in lib/isodoc/function/blocks.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 trim_hash1 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def trim_hash1(hash)
      hash.is_a?(Hash) or return hash
      hash.each_with_object({}) do |(k, v), g|
        blank?(v) and next
        g[k] = case v
Severity: Minor
Found in lib/isodoc/presentation_function/metadata.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 case_with_markup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def case_with_markup(linkend, casing, script, firstonly: true)
      seen = false
      xml = Nokogiri::XML("<root>#{linkend}</root>")
      xml.traverse do |b|
        next unless b.text? && !seen
Severity: Minor
Found in lib/isodoc/class_utils.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 para_parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def para_parse(node, out)
        out.p **attr_code(para_attrs(node)) do |p|
          unless @termdomain.empty?
            p << "&#x3c;#{@termdomain}&#x3e; "
            @termdomain = ""
Severity: Minor
Found in lib/isodoc/word_function/body.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 passthrough_xslt has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def passthrough_xslt
      @output_formats.nil? and return nil
      @output_formats.empty? and return nil
      @output_formats.each_key.with_object([]) do |k, m|
        m << <<~XSLT
Severity: Minor
Found in lib/isodoc/presentation_function/metadata.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 list_item_anchor_names has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list)
        c = Counter.new(list["start"] ? list["start"].to_i - 1 : 0)
        list.xpath(ns("./li")).each do |li|
          bare_label, label =
            list_item_value(li, c, depth, { list_anchor: list_anchor, prev_label: prev_label,
Severity: Minor
Found in lib/isodoc/xref/xref_gen.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

Avoid too many return statements within this method.
Open

        n = node["class"] and return n
Severity: Major
Found in lib/isodoc/word_function/body.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return anchor_linkend1(node) || "???"
    Severity: Major
    Found in lib/isodoc/presentation_function/xrefs.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return :roman_upper if [5, 10].include? depth
      Severity: Major
      Found in lib/isodoc/xref/xref_counter.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return :roman if [3, 8].include? depth
        Severity: Major
        Found in lib/isodoc/xref/xref_counter.rb - About 30 mins to fix

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

              def localpath(path)
                return path if %r{^[A-Z]:|^/|^file:/}.match?(path)
                return path unless (@sourcedir || @localdir) && path
          
                File.expand_path(File.join((@sourcedir || @localdir), path))
          Severity: Minor
          Found in lib/isodoc/css.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 docstatus has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def docstatus(xml, _out)
                set(:unpublished, true)
                return unless s = xml.at(ns("//bibdata/status/stage#{NOLANG}"))
          
                s1 = xml.at(ns("//bibdata/status/stage#{currlang}")) || s
          Severity: Minor
          Found in lib/isodoc/metadata.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 insert_comment_cont has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def insert_comment_cont(from, upto, target)
                  # includes_to = from.at(".//*[@id='#{upto}']")
                  while !from.nil? && from["id"] != upto
                    following = from.xpath("./following::*")
                    (from = following.shift) && incl_to = from.at(".//*[@id='#{upto}']")
          Severity: Minor
          Found in lib/isodoc/html_function/comments.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 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/isodoc/function/utils.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 anchor_struct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def anchor_struct(lbl, container, elem, type, unnumb = false)
                  ret = {}
                  ret[:label] = unnumb == "true" ? nil : anchor_struct_label(lbl, elem)
                  ret[:xref] = anchor_struct_xref(unnumb == "true" ? "(??)" : lbl, elem)
                  ret[:xref].gsub!(/ $/, "")
          Severity: Minor
          Found in lib/isodoc/xref/xref_anchor.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 i8n_name1 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def i8n_name1(hash, pref)
                hash.reject { |_k, v| blank?(v) }.each_with_object([]) do |(k, v), g|
                  case v
                  when Hash then i8n_name(v, i18n_safe(k)).each { |x| g << x }
                  when Array
          Severity: Minor
          Found in lib/isodoc/presentation_function/metadata.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 insert_comment_cont has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def insert_comment_cont(from, upto, target)
                  # includes_to = from.at(".//*[@id='#{upto}']")
                  while !from.nil? && from["id"] != upto
                    following = from.xpath("./following::*")
                    (from = following.shift) && incl_to = from.at(".//*[@id='#{upto}']")
          Severity: Minor
          Found in lib/isodoc/word_function/comments.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 example_table_parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def example_table_parse(node, out)
                  out.table **example_table_attr(node) do |t|
                    t.tr do |tr|
                      tr.td **EXAMPLE_TBL_ATTR do |td|
                        example_label(node, td, node.at(ns("./name")))
          Severity: Minor
          Found in lib/isodoc/function/blocks_example_note.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 case_strict has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def case_strict(text, casing, script, firstonly: true)
                return text unless %w(Latn Cyrl Grek Armn).include?(script)
          
                seen = false
                text.split(/(\s+)/).map do |w|
          Severity: Minor
          Found in lib/isodoc/class_utils.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