relaton/relaton-iec

View on GitHub

Showing 14 of 14 total issues

Method to_xml has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    def to_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
      super(**opts) do |b|
        if opts[:bibdata]
          ext = b.ext do
            doctype&.to_xml b
Severity: Minor
Found in lib/relaton_iec/iec_bibliographic_item.rb - About 6 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 to_xml has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def to_xml(builder) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
      tab = builder.table id: @id do |b|
        b.name { @tname.to_xml b } if @tname
        b.thead { @thead.to_xml b } if @thead
        @tbody.each { |tb| tb.to_xml b }
Severity: Minor
Found in lib/relaton_iec/basic_block/table.rb - About 1 hr 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 to_xml has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def to_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
      super(**opts) do |b|
        if opts[:bibdata]
          ext = b.ext do
            doctype&.to_xml b
Severity: Minor
Found in lib/relaton_iec/iec_bibliographic_item.rb - About 1 hr to fix

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

        def hash_to_bib(hash)
          ret = super
          ret[:function] = ret[:ext][:function] if ret.dig(:ext, :function)
          ret[:updates_document_type] = ret[:ext][:updates_document_type] if ret.dig(:ext, :updates_document_type)
          unless ret.dig(:ext, :accessibility_color_inside).nil?
    Severity: Minor
    Found in lib/relaton_iec/hash_converter.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

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

        def to_hash(embedded: false) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
          hash = super
          hash["ext"]["function"] = function if function
          if updates_document_type
            hash["ext"]["updates_document_type"] = updates_document_type
    Severity: Minor
    Found in lib/relaton_iec/iec_bibliographic_item.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 urn_to_code has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def urn_to_code(urn) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
          fields = urn.upcase.split ":"
          return if fields.size < 5
    
          head, num, date, type, deliv, lang = fields[3, 8]
    Severity: Minor
    Found in lib/relaton_iec.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 match_result has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def match_result(result, code, year, amd, consv) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
    Severity: Minor
    Found in lib/relaton_iec/iec_bibliography.rb - About 35 mins to fix

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

            def get(code, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
              opts[:all_parts] ||= code.match?(/\s\(all parts\)/)
              ref = code.sub(/\s\(all parts\)/, "")
              year ||= ref_parts(ref)[:year]
              return iev if ref.casecmp("IEV").zero?
      Severity: Minor
      Found in lib/relaton_iec/iec_bibliography.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 ajanct_to_code has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def ajanct_to_code(fields)
            return "" if fields.nil? || fields.empty?
      
            rel, type, num, date = fields[0..3]
            code = (rel.empty? ? "/" : "+") + type + num
      Severity: Minor
      Found in lib/relaton_iec.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 match_result has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def match_result(result, code, year, amd, consv) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
              missed_parts = false
              res = result.select do |h|
                h_codes, h_years, h_amds, h_consv = codes_years h.hit[:code]
                match_code = h_codes.include? code
      Severity: Minor
      Found in lib/relaton_iec/iec_bibliography.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 to_xml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_xml(builder) # rubocop:disable Metrics/CyclomaticComplexity
            img = builder.image id: @id, src: @src, mimetype: @mimetype
            img[:filename] = @filename if @filename
            img[:width] = @width if @width
            img[:height] = @height if @height
      Severity: Minor
      Found in lib/relaton_iec/basic_block/image.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 fetch_ref_err has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
              id = ref_with_year(code, year)
      
              Util.info "Not found.", key: id
      
      
      Severity: Minor
      Found in lib/relaton_iec/iec_bibliography.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

              if args[:align] && !ALIGNS.include?(args[:align])
                Util.warn "invalid table/tr/td align `#{args[:align]}`\n" \
                  "alloved aligns are: `#{ALIGNS.join '`, `'}`"
              end
      Severity: Minor
      Found in lib/relaton_iec/basic_block/table.rb and 1 other location - About 15 mins to fix
      lib/relaton_iec/basic_block/table.rb on lines 80..83

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

      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

              if args[:valign] && !VALIGNS.include?(args[:valign])
                Util.warn "invalid table/tr/td valign `#{args[:valign]}`\n" \
                  "alloved valigns are: `#{VALIGNS.join '`, `'}`"
              end
      Severity: Minor
      Found in lib/relaton_iec/basic_block/table.rb and 1 other location - About 15 mins to fix
      lib/relaton_iec/basic_block/table.rb on lines 76..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 25.

      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