metanorma/metanorma-jis

View on GitHub

Showing 22 of 22 total issues

Class Converter has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Converter < ISO::Converter
      def org_abbrev
        super.merge("Japanese Industrial Standards" => "JIS")
      end

Severity: Minor
Found in lib/metanorma/jis/front.rb - About 2 hrs to fix

    Class PresentationXMLConvert has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class PresentationXMLConvert < IsoDoc::Iso::PresentationXMLConvert
          def inline(docxml)
            super
            strong(docxml)
          end
    Severity: Minor
    Found in lib/isodoc/jis/presentation_xml_convert.rb - About 2 hrs to fix

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

            def middle_title_main(out, style)
              t = @meta.get[:doctitlemain]
              (t && !t.empty?) or return
              ret =
                middle_title_para(style, :doctitleintro, :doctitlemain, :doctitlepart)
      Severity: Major
      Found in lib/isodoc/jis/presentation_section.rb and 1 other location - About 1 hr to fix
      lib/isodoc/jis/presentation_section.rb on lines 101..111

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

      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 middle_subtitle_main(out, style)
              t = @meta.get[:docsubtitlemain]
              (t && !t.empty?) or return
              ret = middle_title_para(style, :docsubtitleintro, :docsubtitlemain,
                                      :docsubtitlepart)
      Severity: Major
      Found in lib/isodoc/jis/presentation_section.rb and 1 other location - About 1 hr to fix
      lib/isodoc/jis/presentation_section.rb on lines 88..98

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

      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 list2para_style has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def list2para_style(listtype, depth)
            case listtype
            when "ol"
              ret = case depth
                    when "1" then "margin-left: 36.0pt;"
      Severity: Minor
      Found in lib/html2doc/lists.rb - About 1 hr to fix

        Method norm_ref has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def norm_ref(node, out)
                node["hidden"] != "true" or return
                out.div class: "normref_div" do |div|
                  clause_name(node, node.at(ns("./title")), div, nil)
                  if node.name == "clause"
        Severity: Minor
        Found in lib/isodoc/jis/word_convert.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

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

              when "ul"
                ret = case depth
                      when "1" then "margin-left: 36.0pt;"
                      when "2" then "margin-left: 45.95pt;"
                      when "3" then "margin-left: 72.0pt;"
        Severity: Minor
        Found in lib/html2doc/lists.rb and 1 other location - About 50 mins to fix
        lib/html2doc/lists.rb on lines 67..79

        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

              when "ol"
                ret = case depth
                      when "1" then "margin-left: 36.0pt;"
                      when "2" then "margin-left: 54.0pt;"
                      when "3" then "margin-left: 72.0pt;"
        Severity: Minor
        Found in lib/html2doc/lists.rb and 1 other location - About 50 mins to fix
        lib/html2doc/lists.rb on lines 80..92

        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

        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/jis/table.rb - About 35 mins to fix

          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/jis/xref.rb - About 35 mins to fix

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

                  def xref_init(lang, script, _klass, labels, options)
            Severity: Minor
            Found in lib/isodoc/jis/init.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/jis/base_convert.rb - About 35 mins to fix

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

                      def output(xml, inname, outname, format, options = {})
                Severity: Minor
                Found in lib/metanorma/jis/processor.rb - About 35 mins to fix

                  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/jis/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 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 =
                  Severity: Minor
                  Found in lib/isodoc/jis/xref.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

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

                        def make_table_footnote_target(out, fnid, fnref)
                          attrs = { id: fnid, class: "TableFootnoteRef" }
                          out.span do |s|
                            s << @i18n.table_footnote
                            out.span **attrs do |a|
                  Severity: Minor
                  Found in lib/isodoc/jis/table.rb and 1 other location - About 30 mins to fix
                  lib/isodoc/jis/html_convert.rb on lines 38..45

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

                  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

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

                        def make_table_footnote_target(out, fnid, fnref)
                          attrs = { id: fnid, class: "TableFootnoteRef" }
                          out.span do |s|
                            s << @i18n.table_footnote
                            out.span **attrs do |a|
                  Severity: Minor
                  Found in lib/isodoc/jis/html_convert.rb and 1 other location - About 30 mins to fix
                  lib/isodoc/jis/table.rb on lines 4..11

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

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

                        def back_clauses_anchor_names(xml)
                          clause_order_back(xml).each do |a|
                            xml.xpath(ns(a[:path])).each do |c|
                              if c["commentary"] == "true" then commentary_names(c)
                              else preface_names(c)
                  Severity: Minor
                  Found in lib/isodoc/jis/xref.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 organization has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def organization(xml, org, node = nil, default_org = nil)
                          org.is_a?(Hash) && org[:name] or org = { name: org }
                          abbrevs = org_abbrev
                          name_str = org[:name].is_a?(Hash) ? org[:name]["en"] : org[:name]
                          n = abbrevs.invert[org[:name]] and org = { name: n, abbr: org[:name] }
                  Severity: Minor
                  Found in lib/metanorma/jis/front.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 3 locations. Consider refactoring.
                  Open

                          out.div **attr_code(annex_attrs(node)) do |s|
                            node.elements.each do |c1|
                              if c1.name == "title" then annex_name(node, c1, s)
                              else parse(c1, s) end
                  Severity: Minor
                  Found in lib/isodoc/jis/base_convert.rb and 2 other locations - About 15 mins to fix
                  lib/isodoc/jis/base_convert.rb on lines 49..52
                  lib/isodoc/jis/word_convert.rb on lines 151..154

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

                  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