relaton/relaton-iec

View on GitHub

Showing 17 of 17 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 to_hash has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_hash(embedded: false) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
          hash = super
          hash["function"] = function if function
          if updates_document_type
            hash["updates_document_type"] = updates_document_type
    Severity: Minor
    Found in lib/relaton_iec/iec_bibliographic_item.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 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

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

        class Alignment
          ALIGNS = %w[left right center justified].freeze
      
          #
          # @param [String] content
      Severity: Minor
      Found in lib/relaton_iec/basic_block/alignment.rb and 1 other location - About 35 mins to fix
      lib/relaton_iec/basic_block/reference_format.rb on lines 10..35

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

      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

        class ReferenceFormat
          FORMATS = %w[external inline footnote callout].freeze
      
          #
          # @param [String] format
      Severity: Minor
      Found in lib/relaton_iec/basic_block/reference_format.rb and 1 other location - About 35 mins to fix
      lib/relaton_iec/basic_block/alignment.rb on lines 2..27

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

      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 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.warn "(#{id}) Not found."
      
      
      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 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

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

            if args[:width] && !args[:width].is_a?(Integer) && args[:width] != "auto"
              warn "[basic-block] WARNING: Invalid image width attribute: \"#{args[:width]}"
              warn "[basic-block] Image width should be integer or \"auto\""
            end
      Severity: Minor
      Found in lib/relaton_iec/basic_block/image.rb and 1 other location - About 15 mins to fix
      lib/relaton_iec/basic_block/image.rb on lines 19..22

      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

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

            if args[:height] && !args[:height].is_a?(Integer) && args[:height] != "auto"
              warn "[basic-block] WARNING: Invalid image height attribute: \"#{args[:height]}"
              warn "[basic-block] Image height should be integer or \"auto\""
            end
      Severity: Minor
      Found in lib/relaton_iec/basic_block/image.rb and 1 other location - About 15 mins to fix
      lib/relaton_iec/basic_block/image.rb on lines 15..18

      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

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

              if args[:valign] && !VALIGNS.include?(args[:valign])
                warn "[basic-block] WARNING: invalid table/tr/td valign \"#{args[:valign]}\""
                warn "[basic-block] 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

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

              if args[:align] && !ALIGNS.include?(args[:align])
                warn "[basic-block] WARNING: invalid table/tr/td align \"#{args[:align]}\""
                warn "[basic-block] 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

      Severity
      Category
      Status
      Source
      Language