metanorma/isodoc

View on GitHub

Showing 82 of 82 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def termsource1(elem)
      while elem&.next_element&.name == "termsource"
        elem << "; #{to_xml(elem.next_element.remove.children)}"
      end
      elem.children = l10n("[#{@i18n.source}: #{to_xml(elem.children).strip}]")
Severity: Minor
Found in lib/isodoc/presentation_function/terms.rb and 1 other location - About 25 mins to fix
lib/isodoc/presentation_function/block.rb on lines 207..211

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 31.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def source1(elem)
      while elem&.next_element&.name == "source"
        elem << "; #{to_xml(elem.next_element.remove.children)}"
      end
      elem.children = l10n("[#{@i18n.source}: #{to_xml(elem.children).strip}]")
Severity: Minor
Found in lib/isodoc/presentation_function/block.rb and 1 other location - About 25 mins to fix
lib/isodoc/presentation_function/terms.rb on lines 169..173

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 31.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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 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 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 agency1 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def agency1(xml)
      agency = ""
      publisher = []
      xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = 'publisher']/" \
                   "organization")).each do |org|
Severity: Minor
Found in lib/isodoc/metadata_contributor.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 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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

      def move_comment_link_to_from(docxml)
        docxml.xpath('//span[@style="MsoCommentReference"][@from]').each do |x|
          attrs = comment_attributes(docxml, x) || next
          move_comment_link_to_from1(x, attrs[:from])
          insert_comment_cont(attrs[:from], x["to"], x["target"])
Severity: Minor
Found in lib/isodoc/html_function/comments.rb and 1 other location - About 25 mins to fix
lib/isodoc/word_function/comments.rb on lines 117..121

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      def para_attrs(node)
        attrs = { class: para_class(node), id: node["id"], style: "" }
        unless node["align"].nil?
          attrs[:align] = node["align"] unless node["align"] == "justify"
          attrs[:style] += "text-align:#{node['align']};"
Severity: Minor
Found in lib/isodoc/word_function/body.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 boilerplate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def boilerplate(node, out)
        @bare and return
        boilerplate = node.at(ns("//boilerplate")) or return
        out.div class: "authority" do |s|
          boilerplate.children.each do |n|
Severity: Minor
Found in lib/isodoc/function/to_word_html.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 biblio_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def biblio_list(refs, div, biblio)
        i = 0
        refs.children.each do |b|
          if b.name == "bibitem"
            b["hidden"] == "true" and next
Severity: Minor
Found in lib/isodoc/function/references.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 sequence_increment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def sequence_increment(node)
        if node["branch-number"]
          @prefix_override = node["branch-number"]
        elsif node["number"]
          @base = @letter_override = @number_override = ""
Severity: Minor
Found in lib/isodoc/xref/xref_counter.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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

      def move_comment_link_to_from(docxml)
        docxml.xpath('//span[@style="MsoCommentReference"][@from]').each do |x|
          attrs = comment_attributes(docxml, x) || next
          move_comment_link_to_from1(x, attrs[:from])
          insert_comment_cont(attrs[:from], x["to"], x["target"])
Severity: Minor
Found in lib/isodoc/word_function/comments.rb and 1 other location - About 25 mins to fix
lib/isodoc/html_function/comments.rb on lines 109..113

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      def ol_type(list, depth)
        return list["type"].to_sym if list["type"]
        return :arabic if [2, 7].include? depth
        return :alphabet if [1, 6].include? depth
        return :alphabet_upper if [4, 9].include? depth
Severity: Minor
Found in lib/isodoc/xref/xref_counter.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 prefix_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def prefix_name(node, delim, number, elem)
      number.nil? || number.empty? and return
      unless name = node.at(ns("./#{elem}"))
        node.add_first_child "<#{elem}></#{elem}>"
        name = node.children.first
Severity: Minor
Found in lib/isodoc/presentation_function/block.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      def suffix_url(url)
        return url if url.nil? || %r{^https?://|^#}.match?(url)
        return url unless File.extname(url).empty?

        url.sub(/#{File.extname(url)}$/, ".html")
Severity: Minor
Found in lib/isodoc/function/inline.rb and 1 other location - About 20 mins to fix
lib/isodoc/word_function/inline.rb on lines 74..78

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 27.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      def suffix_url(url)
        return url if url.nil? || %r{^https?://|^#}.match?(url)
        return url unless File.extname(url).empty?

        url.sub(/#{File.extname(url)}$/, ".doc")
Severity: Minor
Found in lib/isodoc/word_function/inline.rb and 1 other location - About 20 mins to fix
lib/isodoc/function/inline.rb on lines 50..54

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 27.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language