relaton/relaton-iec

View on GitHub

Showing 12 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

      Severity
      Category
      Status
      Source
      Language