metanorma/isodoc

View on GitHub

Showing 112 of 112 total issues

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

      def comment_attributes(docxml, span)
        fromlink = docxml.at("//*[@id='#{span['from']}']")
        return(nil) if fromlink.nil?

        tolink = docxml.at("//*[@id='#{span['to']}']") || fromlink
Severity: Minor
Found in lib/isodoc/word_function/comments.rb and 1 other location - About 50 mins to fix
lib/isodoc/html_function/comments.rb on lines 79..85

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 43.

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 comment_attributes(docxml, x)
        fromlink = docxml.at("//*[@id='#{x['from']}']")
        return(nil) if fromlink.nil?

        tolink = docxml.at("//*[@id='#{x['to']}']") || fromlink
Severity: Minor
Found in lib/isodoc/html_function/comments.rb and 1 other location - About 50 mins to fix
lib/isodoc/word_function/comments.rb on lines 82..88

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 43.

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 li_parse(node, out)
        out.li **attr_code(id: node["id"]) do |li|
          if node["uncheckedcheckbox"] == "true"
            li << '<span class="zzMoveToFollowing">&#x2610; </span>'
          elsif node["checkedcheckbox"] == "true"
Severity: Minor
Found in lib/isodoc/word_function/lists.rb and 1 other location - About 45 mins to fix
lib/isodoc/function/lists.rb on lines 65..74

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 41.

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 li_parse(node, out)
        out.li **attr_code(id: node["id"]) do |li|
          if node["uncheckedcheckbox"] == "true"
            li << '<span class="zzMoveToFollowing">' \
                  '<input type="checkbox" checked="checked"/></span>'
Severity: Minor
Found in lib/isodoc/function/lists.rb and 1 other location - About 45 mins to fix
lib/isodoc/word_function/lists.rb on lines 97..104

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 41.

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 norm_ref_entry_code has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def norm_ref_entry_code(_ordinal, idents, _ids, _standard, datefn, _bib)
Severity: Minor
Found in lib/isodoc/presentation_function/refs.rb - About 45 mins to fix

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

          def word_remove_pb_before_annex(docxml)
            docxml.xpath("//div[p/br]").each do |d|
              /^WordSection\d+_\d+$/.match(d["class"]) or next
              (d.elements[0].name == "p" && !d.elements[0].elements.empty?) or next
              (d.elements[0].elements[0].name == "br" &&
    Severity: Minor
    Found in lib/isodoc/word_function/postprocess.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 biblio_ref_entry_code has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def biblio_ref_entry_code(ordinal, ids, _id, _standard, datefn, _bib)
    Severity: Minor
    Found in lib/isodoc/presentation_function/refs.rb - About 45 mins to fix

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

          def anchor_linkend(node, linkend)
            node["style"] == "id" and
              return anchor_id_postproc(node)
            node["citeas"].nil? && node["bibitemid"] and
              return @xrefs.anchor(node["bibitemid"], :xref) || "???"
      Severity: Minor
      Found in lib/isodoc/presentation_function/xrefs.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 preface_move1 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def preface_move1(clause, preface, float, prev, xpath)
            preface.elements.each do |x|
              ((x.name == "floating-title" || x.at(xpath)) &&
              xpath != "./self::*[not(following-sibling::*)]") or prev = x
              # after.include?(x.name) or next
      Severity: Minor
      Found in lib/isodoc/presentation_function/section.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 word_colgroup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def word_colgroup(docxml)
              cells2d = {}
              docxml.xpath("//table[colgroup]").each do |t|
                w = colgroup_widths(t)
                t.xpath(".//tr").each_with_index { |_tr, r| cells2d[r] = {} }
      Severity: Minor
      Found in lib/isodoc/word_function/postprocess_table.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 quote_attribution has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def quote_attribution(node, out)
              author = node.at(ns("./author"))
              source = node.at(ns("./source"))
              return if author.nil? && source.nil?
      
      
      Severity: Minor
      Found in lib/isodoc/function/blocks.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

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

            def ol_parse(node, out)
              out.div **attr_code(class: "ol_wrap") do |div|
                list_title_parse(node, div)
                div.ol **attr_code(ol_attrs(node)) do |ol|
                  node.children.each { |n| n.name == "name" or parse(n, ol) }
      Severity: Minor
      Found in lib/isodoc/function/lists.rb and 1 other location - About 40 mins to fix
      lib/isodoc/function/lists.rb on lines 15..19

      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 38.

      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 ul_parse(node, out)
              out.div **attr_code(class: "ul_wrap") do |div|
                list_title_parse(node, div)
                div.ul **attr_code(ul_attrs(node)) do |ul|
                  node.children.each { |n| n.name == "name" or parse(n, ul) }
      Severity: Minor
      Found in lib/isodoc/function/lists.rb and 1 other location - About 40 mins to fix
      lib/isodoc/function/lists.rb on lines 56..60

      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 38.

      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 list_item_anchor_names has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list)
      Severity: Minor
      Found in lib/isodoc/xref/xref_gen.rb - About 35 mins to fix

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

            def preface_move1(clause, preface, float, prev, xpath)
        Severity: Minor
        Found in lib/isodoc/presentation_function/section.rb - About 35 mins to fix

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

              def swap_renderer(oldklass, newklass, file, input_filename, debug)
          Severity: Minor
          Found in lib/isodoc/convert.rb - About 35 mins to fix

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

                  def make_tr_attr(cell, row, totalrows, header, bordered)
            Severity: Minor
            Found in lib/isodoc/word_function/table.rb - About 35 mins to fix

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

                    def make_tr_attr_style(row, rowmax, totalrows, _header, bordered)
              Severity: Minor
              Found in lib/isodoc/function/table.rb - About 35 mins to fix

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

                      def hierarchical_permission_body(id, block, label, klass, model)
                Severity: Minor
                Found in lib/isodoc/xref/xref_gen_seq.rb - About 35 mins to fix

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

                        def make_tr_attr_style(cell, row, rowmax, totalrows, opt)
                  Severity: Minor
                  Found in lib/isodoc/word_function/table.rb - About 35 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language