relaton/relaton-ietf

View on GitHub

Showing 9 of 12 total issues

Class RfcEntry has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class RfcEntry
    #
    # Initalize parser
    #
    # @param [Nokogiri::XML::Element] doc document
Severity: Minor
Found in lib/relaton_ietf/rfc_entry.rb - About 2 hrs to fix

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

        def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
          opts[:date_format] ||= :short
          super(**opts) do |builder|
            if opts[:bibdata] && (doctype || editorialgroup || ics&.any? ||
              structuredidentifier&.presence? || stream)
    Severity: Minor
    Found in lib/relaton_ietf/ietf_bibliographic_item.rb - About 2 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 update_versions has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def update_versions(versions) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
          series = ""
          bib_versions = []
          Dir["#{@output}/*.#{@ext}"].each do |file|
            match = /(?<series>draft-.+)-(?<ver>\d{2})\.#{@ext}$/.match file
    Severity: Minor
    Found in lib/relaton_ietf/data_fetcher.rb - About 2 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 full_name_org has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def full_name_org(name) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
          case name
          when "ISO"
            RelatonBib::Organization.new(abbreviation: name, name: "International Organization for Standardization")
          when "IAB"
    Severity: Minor
    Found in lib/relaton_ietf/bibxml_parser.rb - About 1 hr to fix

      Method render_authors has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def render_authors(builder) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
              @bib.contributor.each do |c|
                next if c.entity.is_a?(RelatonBib::Organization) && c.entity.name.map(&:content).include?("RFC Publisher")
      
                builder.author do |xml|
      Severity: Minor
      Found in lib/relaton_ietf/renderer/bibxml.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

      Consider simplifying this complex logical expression.
      Open

              if opts[:bibdata] && (doctype || editorialgroup || ics&.any? ||
                structuredidentifier&.presence? || stream)
                ext = builder.ext do |b|
                  doctype&.to_xml b
                  b.subdoctype subdoctype if subdoctype
      Severity: Major
      Found in lib/relaton_ietf/ietf_bibliographic_item.rb - About 40 mins to fix

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

            def full_name(fname, sname, inits, lang, script = nil)
        Severity: Minor
        Found in lib/relaton_ietf/bibxml_parser.rb - About 35 mins to fix

          Method fetch_ieft_internet_drafts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def fetch_ieft_internet_drafts # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
                versions = Dir["bibxml-ids/*.xml"].each_with_object([]) do |path, vers|
                  file = File.basename path, ".xml"
                  if file.include?("D.draft-")
                    vers << file.sub(/^reference\.I-D\./, "").downcase
          Severity: Minor
          Found in lib/relaton_ietf/data_fetcher.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 save_doc has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def save_doc(entry, check_duplicate: true) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
                return unless entry
          
                c = case @format
                    when "xml" then entry.to_xml(bibdata: true)
          Severity: Minor
          Found in lib/relaton_ietf/data_fetcher.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